/* Keep the score rail beside the paper at every viewport size. */
.drawing-area {
  display:grid;
  grid-template-columns:108px minmax(0,1fr) 80px;
  gap:12px;
  min-width:0;
  min-height:0;
}
.drawing-area>#score-timer { transform:translateX(var(--canvas-leading-space,0px)); }
@media(min-width:851px) {
  /* Share unused paper-fitting space across both sides of the whole studio. */
  #draw-view .workspace { grid-template-rows:minmax(0,1fr); transform:translateX(calc(var(--canvas-leading-space,0px) * -.5)); }
  #draw-view .studio-sidebar { grid-template-rows:minmax(0,1fr) auto auto; min-height:0; overflow:visible; padding:0; margin:0; }
  #draw-view .tools-panel,#draw-view .play-reminder { align-self:stretch; }
}
@media(min-width:851px) and (max-height:760px) {
  #draw-view .studio-sidebar { gap:8px; }
  #draw-view .tool-rail { padding:8px 4px; gap:4px; }
  #draw-view .tool-button { min-height:44px; padding:6px 3px; font-size:16px; }
  #draw-view .rail-label { font-size:12px; margin-bottom:2px; }
  #draw-view .tool-options-wrap { padding:10px; }
  #draw-view .options-heading { font-size:14px; margin-bottom:10px; }
  #draw-view .option-label { font-size:15px; margin-bottom:6px; }
  #draw-view .option-label>span,#draw-view .option-label>output { font-size:14px; }
  #draw-view .option-group+.option-group { margin-top:12px; }
  #draw-view .size-buttons button { height:28px; }
  #draw-view .opacity-buttons button { height:26px; }
  #draw-view .color-palette { gap:6px; }
  #draw-view .palette-swatch { width:22px; height:22px; justify-self:center; }
  #draw-view .drawing-actions .button { min-height:44px; padding:8px; font-size:16px; }
  #draw-view .play-reminder { padding:10px 12px; }
  #draw-view .play-reminder h2 { font-size:18px; }
  #draw-view .play-reminder p { margin-top:6px; font-size:16px; line-height:1.35; }
}
.score-timer {
  --timer-ink:#122f55;
  --timer-clock-height:54px;
  --timer-scale-min-height:220px;
  --timer-track-left:8px;
  --timer-track-width:28px;
  --timer-stone-height:48px;
  --timer-bulb-size:54px;
  position:relative;
  display:grid;
  grid-template-rows:var(--timer-clock-height) minmax(var(--timer-scale-min-height),1fr) calc(var(--timer-stone-height) + var(--timer-bulb-size));
  min-height:calc(var(--timer-clock-height) + var(--timer-scale-min-height) + var(--timer-stone-height) + var(--timer-bulb-size) + 16px);
  padding:8px 10px;
  border-radius:18px;
  background:#edf6ff;
  color:var(--timer-ink);
  user-select:none;
  pointer-events:none;
}
.score-timer::before {
  content:'';
  position:absolute;
  inset:0;
  border:3.8px solid #8999a9;
  border-radius:inherit;
  filter:var(--ui-outline-filter);
  pointer-events:none;
}
.timer-clock {
  width:44px;
  height:44px;
  align-self:center;
  stroke-width:3.6;
  overflow:visible;
}
/* Grain belongs to the drawn strokes, leaving the clock face fully opaque. */
.timer-clock-face { fill:#ffda59; stroke:none; }
.timer-clock-outline,.timer-clock-hand { fill:none; filter:var(--ui-outline-filter); }
/* Decorative sweep only; scoring still uses the drawing clock. */
.timer-clock-hand {
  transform-origin:24px 30px;
  animation:timer-hand-sweep 10s linear infinite;
  animation-play-state:paused;
}
.score-timer[data-state=running] .timer-clock-hand { animation-play-state:running; }
@keyframes timer-hand-sweep { to { transform:rotate(-360deg); } }
@media(prefers-reduced-motion:reduce) {
  .timer-clock-hand { animation:none; }
}
.timer-scale { position:relative; min-height:var(--timer-scale-min-height); }
.timer-track {
  position:absolute;
  top:0;
  bottom:0;
  left:var(--timer-track-left);
  width:var(--timer-track-width);
  border-radius:13px 13px 0 0;
  background:#c6ddf3;
}
.timer-track::after {
  content:'';
  position:absolute;
  inset:-4px -4px 0;
  border:8px solid var(--timer-ink);
  border-bottom:0;
  border-radius:17px 17px 0 0;
  filter:var(--ui-outline-filter);
  pointer-events:none;
}
.timer-fill {
  position:absolute;
  inset:0;
  border-radius:inherit;
  /* The full-height gradient stays anchored as time drains from the top. */
  background:linear-gradient(to bottom,#81c86c 0%,#ffda59 100%);
  clip-path:inset(var(--elapsed,0%) 0 0 0);
}
.timer-tick {
  position:absolute;
  left:34px;
  top:var(--at);
  width:15px;
  height:4px;
  border-radius:3px;
  background:var(--timer-ink);
  transform:translateY(-50%) rotate(-3deg);
  filter:var(--ui-outline-filter);
}
.time-medal {
  position:absolute;
  left:46px;
  top:var(--at);
  width:40px;
  height:52px;
  transform:translateY(-50%) rotate(5deg) scale(1);
  opacity:.6;
  transition:transform 180ms cubic-bezier(.2,.8,.2,1),opacity 180ms ease,filter 180ms ease;
}
.time-medal.is-current {
  z-index:1;
  opacity:1;
  transform:translateY(-50%) rotate(0deg) scale(1.24);
  filter:drop-shadow(0 2px 0 #eaf6ffc0);
}
/* Ease only at the ends of each swing, passing smoothly through the center.
   The quarter-cycle offset starts upright; pausing preserves the outgoing angle. */
.time-medal .medal-icon {
  transform-origin:50% 35%;
  animation:time-medal-sway 3.2s cubic-bezier(.37,0,.63,1) infinite;
  animation-delay:-.8s;
  animation-play-state:paused;
}
.time-medal.is-current .medal-icon { animation-play-state:running; }
@keyframes time-medal-sway {
  0%,100% { transform:rotate(-6deg); }
  50% { transform:rotate(6deg); }
}
@media(prefers-reduced-motion:reduce) {
  .time-medal { transition:none; }
  .time-medal .medal-icon { animation:none; }
}
.timer-stone { position:relative; }
.timer-stone .time-medal { top:calc(var(--timer-stone-height) / 2); }
.timer-reservoir {
  position:absolute;
  left:calc(var(--timer-track-left) + var(--timer-track-width) / 2 - var(--timer-bulb-size) / 2);
  top:0;
  width:var(--timer-bulb-size);
  height:100%;
  overflow:visible;
}
/* The infinity reservoir stays full after the finite scoring bar drains. */
.timer-reservoir-fill { fill:#ffda59; stroke:none; }
.timer-reservoir-outline { fill:none; stroke:var(--timer-ink); stroke-width:8; filter:var(--ui-outline-filter); }
.timer-infinity { fill:none; stroke:var(--timer-ink); stroke-width:3.3; filter:var(--ui-outline-filter); }
.medal-icon { display:block; width:100%; height:100%; overflow:visible; stroke-width:2.7; }
.medal-outline { fill:none; stroke:var(--medal-ink); filter:var(--ui-outline-filter); }
.medal-hands { stroke-width:3.6; }
.medal-dial-ticks { stroke-width:2.2; }
/* Keep the original facets visible behind the stronger clock hands. */
.medal-stone-facets { stroke-width:1.7; opacity:.65; }
[data-medal=gold] { --medal-fill:#ffda59; --medal-ink:#715018; --medal-light:#fff1a6; --medal-ribbon:#e77857; }
[data-medal=silver] { --medal-fill:#a6d8ff; --medal-ink:#3d6487; --medal-light:#e8f6ff; --medal-ribbon:#7bb4e5; }
[data-medal=bronze] { --medal-fill:#d89b6c; --medal-ink:#744633; --medal-light:#f2c49b; --medal-ribbon:#d77e62; }
[data-medal=stone] { --medal-fill:#9caaa7; --medal-ink:#455956; --medal-light:#c5cfca; --medal-ribbon:#7f9697; }
@media(max-width:850px) {
  .drawing-area { grid-template-columns:82px minmax(0,1fr) 64px; gap:8px; }
  .history-controls { width:68px; padding:6px 8px 6px 16px; gap:8px; }
  #draw-view .history-button { padding:4px 2px; gap:3px; font-size:13px; min-height:44px; }
  .score-timer {
    --timer-clock-height:56px;
    --timer-scale-min-height:180px;
    --timer-track-left:6px;
    --timer-track-width:23px;
    --timer-stone-height:38px;
    --timer-bulb-size:44px;
    padding:8px;
    border-radius:14px;
  }
  .timer-clock { width:34px; height:38px; }
  .timer-track { border-radius:11px 11px 0 0; }
  .timer-track::after { border-width:7px; border-bottom:0; border-radius:15px 15px 0 0; }
  .timer-reservoir-outline { stroke-width:8.6; }
  .timer-tick { left:28px; width:11px; }
  .time-medal { left:36px; width:30px; height:42px; }
}
