.holiday-reaction-rail {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 2px;
  gap: 1px;
  box-sizing: border-box;
  border: 1px solid rgba(143,135,175,.54);
  border-radius: 17px;
  background: linear-gradient(145deg, #fffdf9 0%, #f5f2fc 52%, #e6f5f2 100%);
  box-shadow: inset 0 1px 0 #fff, 0 2px 6px #35275719;
  user-select: none;
}
.holiday-reaction-rail[hidden],
.stage-wrap:has(.stage.editing) > .holiday-reaction-rail,
body.family:has(#audience-stage[hidden]) > .holiday-reaction-rail {
  display: none;
}
.holiday-reaction-rail button:is([data-holiday-reaction], [data-ink-tool]) {
  --reaction-tint: #ffe3d9;
  display: grid;
  place-items: center;
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 44px;
  height: 44px;
  padding: 0;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .18s, border-color .18s, transform .15s;
}
.holiday-reaction-rail button[data-holiday-reaction="basket"] { --reaction-tint: #ffead7; }
.holiday-reaction-rail button[data-holiday-reaction="code"] { --reaction-tint: #e0e1f6; }
.holiday-reaction-rail button[data-holiday-reaction="mask"] { --reaction-tint: #e3dff3; }
.holiday-reaction-rail button[data-ink-tool="pen"] { --reaction-tint: #e9e1f7; }
.holiday-reaction-rail button[data-ink-tool="eraser"] { --reaction-tint: #d7efef; }
.holiday-reaction-rail button[data-ink-tool="pen"] { margin-top: 6px; }
.holiday-reaction-rail button[data-ink-tool="pen"]::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 7px;
  right: 7px;
  height: 1px;
  background: #c6c3d1;
}
.holiday-reaction-rail button[data-ink-tool][aria-pressed="true"] {
  background: var(--reaction-tint);
  border-color: #797098;
  box-shadow: inset 0 0 0 1px #fff9;
}
.holiday-reaction-rail button[data-ink-tool][aria-pressed="true"]::after {
  content: '';
  position: absolute;
  bottom: 2px;
  width: 10px;
  height: 2px;
  border-radius: 2px;
  background: #5b5789;
}
.holiday-reaction-rail button > img {
  display: block;
  width: 38px;
  height: 38px;
  max-width: none;
  pointer-events: none;
  transform-origin: 50% 68%;
  animation: holiday-icon-float 6s ease-in-out infinite;
}
.holiday-reaction-rail button[data-holiday-reaction="basket"] > img {
  animation-name: holiday-ball-float;
  animation-delay: -1.8s;
}
.holiday-reaction-rail button[data-holiday-reaction="code"] > img {
  animation-delay: -3.6s;
  animation-duration: 6.8s;
}
.holiday-reaction-rail button[data-holiday-reaction="mask"] > img {
  animation-delay: -4.8s;
  animation-duration: 7.4s;
}
.holiday-reaction-rail button[data-ink-tool="pen"] > img { animation-delay: -2.8s; }
.holiday-reaction-rail button[data-ink-tool="eraser"] > img { animation-delay: -4.1s; }
@keyframes holiday-icon-float {
  0%, 48%, 100% { transform: translateY(0) rotate(0); }
  65% { transform: translateY(-1.1px) rotate(-2.5deg); }
  81% { transform: translateY(-.3px) rotate(1deg); }
}
@keyframes holiday-ball-float {
  0%, 56%, 100% { transform: translateY(0) rotate(0); }
  71% { transform: translateY(-1.5px) rotate(3deg); }
}
@media (hover:hover) {
  .holiday-reaction-rail button:is([data-holiday-reaction], [data-ink-tool]):hover {
    border-color: #bdb4d177;
    background-color: var(--reaction-tint);
  }
}
.holiday-reaction-rail button:is([data-holiday-reaction], [data-ink-tool]):focus-visible {
  outline: 2px solid #5c418b;
  outline-offset: -2px;
  background-color: var(--reaction-tint);
}
.holiday-reaction-rail button:is([data-holiday-reaction], [data-ink-tool]):active {
  transform: scale(.94);
  background-color: var(--reaction-tint);
}

@media screen {
  /* Keep all 1280 × 720 artwork and ink inside their original shared frame.
     The studio's resize routine already measures the wrapper's inner padding. */
  body .stage-wrap:has(> .holiday-reaction-rail:not([hidden])):not(:has(.stage.editing)) {
    position: relative;
    padding-left: 58px;
  }
  .stage-wrap > .holiday-reaction-rail {
    position: absolute;
    z-index: 8;
    left: 4px;
    top: 50%;
    transform: translateY(-50%);
    max-height: calc(100% - 4px);
  }
  .stage-wrap > .holiday-reaction-rail button { flex-shrink: 1; }
  .stage-wrap > .holiday-reaction-rail button > img { max-height: 100%; }

  /* Place the controls beside the projection, using its letterbox first.
     Reserve only the extra width actually needed on 16:9 monitors. */
  body.family:has(> .holiday-reaction-rail) {
    --reaction-space: 58px;
    --reaction-art-width: min(calc(100vw - var(--reaction-space)), calc(100dvh * 16 / 9));
    --reaction-art-left: max(var(--reaction-space), calc((100vw - var(--reaction-art-width)) / 2));
  }
  body.family:has(> .holiday-reaction-rail) #audience-stage {
    justify-self: start;
    width: var(--reaction-art-width);
    margin-left: var(--reaction-art-left);
  }
  body.family > .holiday-reaction-rail {
    position: fixed;
    z-index: 18;
    left: calc(var(--reaction-art-left) - 54px);
    top: 50%;
    transform: translateY(-50%);
    max-height: calc(100dvh - 8px);
    max-width: calc(100vw - 10px);
  }
  .holiday-reaction-rail button > img { max-width: 100%; max-height: 100%; object-fit: contain; }
}
@media screen and (max-width:680px) {
  /* The temporary, text-only popup notice can span the mobile control row. */
  body.presenter:has(.holiday-reaction-rail) #toast { pointer-events: none; }
  body .stage-wrap:has(> .holiday-reaction-rail:not([hidden])):not(:has(.stage.editing)) {
    padding-left: 5px;
    padding-bottom: 54px;
  }
  /* The narrow presenter uses an aspect-ratio wrapper. Count the band
     outside that ratio so the picture can still use the entire column. */
  body.presenter .stage-wrap:has(> .holiday-reaction-rail:not([hidden])):not(:fullscreen) {
    box-sizing: content-box;
  }
  body .stage-wrap:fullscreen:has(> .holiday-reaction-rail:not([hidden])):not(:has(.stage.editing)) {
    padding-left: 0;
  }
  .stage-wrap > .holiday-reaction-rail {
    flex-direction: row;
    top: auto;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    max-width: calc(100% - 8px);
  }
  .stage-wrap > .holiday-reaction-rail button[data-ink-tool="pen"] {
    margin: 0 0 0 6px;
  }
  .stage-wrap > .holiday-reaction-rail button[data-ink-tool="pen"]::before {
    left: -5px; top: 7px; bottom: 7px; width: 1px; height: auto;
  }
}
@media screen and (max-aspect-ratio:8/5) {
  /* Stack controls in the upper letterbox on tablets and phones.
     The lower letterbox stays clear for the audience's pen and navigation. */
  body.family:has(> .holiday-reaction-rail) {
    --reaction-art-width: min(100vw, calc((100dvh - var(--reaction-space)) * 16 / 9));
    --reaction-art-top: max(var(--reaction-space), calc((100dvh - var(--reaction-art-width) * 9 / 16) / 2));
  }
  body.family:has(> .holiday-reaction-rail) #audience-stage {
    justify-self: center;
    align-self: start;
    margin-left: 0;
    margin-top: var(--reaction-art-top);
  }
  body.family > .holiday-reaction-rail {
    flex-direction: row;
    top: calc(var(--reaction-art-top) - 54px);
    left: max(5px, calc((100vw - var(--reaction-art-width)) / 2 + 5px));
    transform: none;
  }
  body.family > .holiday-reaction-rail button[data-ink-tool="pen"] { margin: 0 0 0 6px; }
  body.family > .holiday-reaction-rail button[data-ink-tool="pen"]::before {
    left: -5px; top: 7px; bottom: 7px; width: 1px; height: auto;
  }
}
@media (prefers-reduced-motion:reduce) {
  .holiday-reaction-rail button:is([data-holiday-reaction], [data-ink-tool]) { transition: none; }
  .holiday-reaction-rail button > img { animation: none; }
}
@media print {
  .holiday-reaction-rail { display: none !important; }
}

/* A single private scoreboard in the header shared by both teaching modes. */
.top-actions .basket-score-control {
  display:inline-flex;
  align-items:stretch;
  flex:0 0 auto;
  min-height:44px;
  border:1px solid #b5b4cc;
  border-radius:12px;
  background:linear-gradient(115deg,#fffaf3,#f7f7fb 70%,#e9f4f4);
  box-shadow:inset 0 1px #fff,0 1px 3px #29284812;
  color:#352950;
}
.basket-score-total {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:4px;
  padding-inline:8px 9px;
  font-size:16px;
  font-weight:750;
  font-variant-numeric:tabular-nums;
  line-height:1;
}
.basket-score-total img {display:block;}
.basket-score-total output {min-width:1ch;text-align:center;}
.top-actions #basket-score-reset {
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  min-width:42px;
  padding:0 10px;
  border:0;
  border-inline-start:1px solid #c8c6d4;
  border-radius:0 11px 11px 0;
  box-shadow:none;
  background:transparent;
  color:#51436f;
  font:inherit;
  font-size:13px;
  font-weight:650;
  line-height:1.2;
  touch-action:manipulation;
}
#basket-score-reset svg {
  display:block;
  width:18px;
  height:18px;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.top-actions #basket-score-reset:hover:enabled {background:#e7e4f4;}
.top-actions #basket-score-reset:disabled {opacity:1;color:#827b91;cursor:default;}
@media screen and (max-width:1370px) {
  #basket-score-reset span {display:none;}
}
@media screen and (max-width:650px) {
  .topbar .top-actions:has(.basket-score-control) {flex-wrap:wrap;}
  /* The menu handle uses the title row. The buttons below get the full
     header width, even when the sidebar is closed. */
  body:not(.presenter) #shell > .workspace > .topbar .top-actions:has(.basket-score-control) {
    flex:0 0 calc(100% + 42px);
    width:calc(100% + 42px);
    margin-inline-start:-42px;
  }
}
@media screen and (max-width:380px) {
  body:not(.presenter) #shell .topbar .top-actions:has(.basket-score-control) {gap:5px;}
  .basket-score-total {padding-inline:5px;gap:2px;font-size:14px;}
  .basket-score-total img {width:23px;height:23px;}
  .top-actions #basket-score-reset {min-width:44px;padding:0 7px;}
  body:not(.presenter) .top-actions:has(.basket-score-control) #show-family {
    flex:1 1 116px;
    min-width:0;
    line-height:1.15;
    padding:7px 8px;
  }
  body.presenter .top-actions:has(.basket-score-control) :is(#presenter-back,#stop-family) {padding-inline:8px;}
  body.presenter .top-actions:has(.basket-score-control) #presentation-status {
    max-width:56px;
    gap:4px;
    margin-inline-end:0;
    font-size:10px;
  }
}
@media (forced-colors:active) {
  .holiday-reaction-rail button[data-ink-tool][aria-pressed="true"] {border:2px solid Highlight;}
  .top-actions .basket-score-control {border-color:CanvasText;}
  .top-actions #basket-score-reset {color:ButtonText;border-color:ButtonBorder;}
  .top-actions #basket-score-reset:disabled {color:GrayText;}
}
