@import url('https://fonts.googleapis.com/css2?family=Silkscreen:wght@400;700&display=swap');

:root {
  --bg-deep: #CFC6B8;
  --bg-sky: #DDD5C9;
  --bg-sky-soft: #EEE8DF;

  --panel: #FFF9F0;
  --panel-mid: #E4DCCE;
  --panel-dark: #BEB4A5;

  --pixel-border: #3B352F;

  --text-main: #312C27;
  --text-dim: #72695F;

  --ghost-blue: #DEDAD3;
  --slime-green: #B9B59F;
  --fire-orange: #E97724;
  --danger-red: #C95F48;
  --twilight: #504840;
  --real-green: #A8B19B;
  --silly-pink: #D8C4BC;

  --shadow: rgba(55, 46, 38, 0.22);
  --round-duration: 20s;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text-main);
  background:
    radial-gradient(circle at 50% -20%, rgba(105, 229, 255, 0.14), transparent 38%),
    linear-gradient(rgba(214, 201, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 201, 255, 0.055) 1px, transparent 1px),
    var(--bg-deep);
  background-size: auto, 28px 28px, 28px 28px, auto;
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 4px solid var(--ghost-blue);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.timer-app {
  width: min(1020px, calc(100% - 28px));
  margin: 28px auto;
}

.screen {
  border: 5px solid var(--pixel-border);
  background: var(--bg-sky);
  box-shadow: 10px 10px 0 var(--shadow);
}

.setup-screen,
.timer-screen {
  padding: clamp(18px, 4vw, 42px);
}

.screen-heading,
.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
}

.eyebrow,
h1,
h2,
h3,
button,
.setup-time-display,
.timer-readout,
.theme-label,
label > span,
.console-label-row span,
#presetCountLabel {
  font-family: "Silkscreen", monospace;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 0.8rem;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

.screen-heading h1 {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.05;
}

.screen-heading p:last-child,
.dialog-heading p:last-child {
  margin: 11px 0 0;
  color: var(--text-dim);
  font-size: 1rem;
}

.icon-button {
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border: 4px solid var(--pixel-border);
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--pixel-border);
  color: var(--gold);
  cursor: pointer;
  font-size: 1.35rem;
}

.icon-button:hover {
  background: var(--panel-mid);
  color: var(--ghost-blue);
}

.time-console {
  padding: clamp(16px, 3vw, 28px);
  border: 5px solid var(--pixel-border);
  background: var(--panel-dark);
  box-shadow: 8px 8px 0 var(--pixel-border);
}

.console-label-row,
.subheading-row,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.console-label-row h2,
.subheading-row h3,
.section-title-row h2,
.custom-preset-area h3,
.preset-form-section h3,
.saved-presets-section h3 {
  margin: 0;
}

.console-label-row h2,
.subheading-row h3,
.custom-preset-area h3,
.preset-form-section h3,
.saved-presets-section h3 {
  color: var(--ghost-blue);
  font-size: 0.82rem;
}

.console-label-row span,
#presetCountLabel {
  color: var(--text-dim);
  font-size: 0.62rem;
}

.setup-time-display {
  display: block;
  width: 100%;
  margin: 16px 0 20px;
  padding: clamp(14px, 3vw, 24px) 10px;
  border: 5px solid var(--pixel-border);
  background: var(--text-main);
  box-shadow: inset 0 -8px 0 rgba(27, 16, 53, 0.12);
  color: var(--bg-deep);
  font-size: clamp(3.3rem, 13vw, 7.6rem);
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  max-width: 650px;
  margin: 0 auto;
}

.keypad-button {
  min-height: 72px;
  border: 4px solid var(--pixel-border);
  background: var(--panel);
  box-shadow: 5px 5px 0 var(--pixel-border);
  color: var(--text-main);
  cursor: pointer;
  font-size: clamp(1.25rem, 4vw, 2rem);
}

.keypad-button:hover {
  background: var(--bg-sky-soft);
  color: var(--gold);
}

.keypad-action {
  background: var(--panel-mid);
  color: var(--text-dim);
  font-size: clamp(0.68rem, 2vw, 0.92rem);
}

.preset-block {
  margin-top: 28px;
  padding-top: 22px;
  border-top: 3px dashed var(--panel);
}

.text-button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-size: 0.66rem;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.text-button:hover {
  color: var(--ghost-blue);
}

.preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.preset-button,
.toolbar-button,
.secondary-button {
  border: 4px solid var(--pixel-border);
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--pixel-border);
  cursor: pointer;
}

.preset-button {
  min-height: 44px;
  padding: 10px 13px;
  color: var(--text-main);
  font-size: 0.67rem;
}

.preset-button:hover,
.toolbar-button:hover,
.secondary-button:hover {
  background: var(--bg-sky-soft);
  color: var(--gold);
}

.preset-button.custom-preset {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 4px 9px;
  align-items: center;
  text-align: left;
}

.preset-button.custom-preset .preset-name {
  grid-column: 1 / -1;
  color: var(--ghost-blue);
}

.preset-button.custom-preset .preset-meta {
  color: var(--text-dim);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.72rem;
}

.custom-preset-area {
  margin-top: 20px;
}

.theme-section {
  margin-top: 38px;
}

.section-title-row {
  align-items: end;
  margin-bottom: 16px;
}

.section-title-row h2 {
  font-size: clamp(1rem, 3vw, 1.35rem);
}

#selectedThemeText {
  color: var(--text-dim);
  font-size: 0.84rem;
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.theme-card {
  min-height: 148px;
  padding: 18px 10px;
  border: 5px solid var(--pixel-border);
  background: var(--panel-mid);
  box-shadow: 6px 6px 0 var(--pixel-border);
  color: var(--text-main);
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease;
}

.theme-card:hover {
  background: var(--panel);
  transform: translateY(-3px);
}

.theme-card.is-selected {
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--gold);
  color: var(--gold);
}

.theme-card > span:last-child {
  display: block;
  margin-top: 11px;
  font-size: clamp(0.68rem, 1.8vw, 0.88rem);
}

.theme-preview {
  display: block;
  font-size: clamp(2.7rem, 7vw, 4.3rem);
  line-height: 1;
  filter: drop-shadow(4px 4px 0 var(--pixel-border));
}

.primary-button {
  border: 5px solid var(--pixel-border);
  background: var(--fire-orange);
  box-shadow: 6px 6px 0 var(--pixel-border);
  color: var(--bg-deep);
  cursor: pointer;
  font-weight: 700;
}

.primary-button:hover {
  background: var(--gold);
}

.start-button {
  width: 100%;
  margin-top: 30px;
  padding: 18px 22px;
  font-size: clamp(1rem, 3vw, 1.35rem);
}

.keypad-button:active,
.preset-button:active,
.toolbar-button:active,
.secondary-button:active,
.primary-button:active,
.theme-card:active,
.icon-button:active {
  box-shadow: none;
  transform: translate(4px, 4px);
}

.error-message {
  margin: 16px 0 0;
  color: var(--danger-red);
  font-weight: 700;
  text-align: center;
}

/* Timer screen */
.timer-screen {
  min-height: 720px;
}

.timer-toolbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
}

.toolbar-button {
  padding: 10px 12px;
  color: var(--text-main);
  font-size: 0.68rem;
}

#muteButton {
  justify-self: end;
}

.theme-label {
  padding: 9px 12px;
  border: 4px solid var(--pixel-border);
  background: var(--gold);
  color: var(--bg-deep);
  font-size: 0.72rem;
  text-align: center;
}

.timer-readout {
  margin: 26px 0 14px;
  text-align: center;
}

.timer-readout p {
  margin: 0 0 5px;
  color: var(--text-dim);
  font-size: 0.72rem;
}

#timeDisplay {
  display: block;
  color: var(--text-main);
  font-size: clamp(4rem, 15vw, 8.5rem);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-shadow: 5px 5px 0 var(--pixel-border);
}

.timer-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 350px;
  overflow: hidden;
  border: 5px solid var(--pixel-border);
  background:
    linear-gradient(rgba(214, 201, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(214, 201, 255, 0.055) 1px, transparent 1px),
    var(--panel-dark);
  background-size: 22px 22px;
  box-shadow: 8px 8px 0 var(--pixel-border);
}

.timer-visual {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, 560px);
  height: 320px;
}

.timer-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.timer-controls button,
.finished-actions button,
.dialog-footer button {
  min-height: 54px;
  padding: 11px 8px;
  font-size: 0.72rem;
}

.finished-panel {
  margin-top: 24px;
  padding: 24px;
  border: 5px solid var(--pixel-border);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--pixel-border);
  text-align: center;
}

.finished-panel h2 {
  margin: 0 0 18px;
  color: var(--gold);
  font-size: clamp(1.4rem, 4vw, 2rem);
}

.finished-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
}

.keyboard-help {
  margin: 24px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  text-align: center;
}

/* Preset settings dialog */
.preset-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: min(880px, calc(100vh - 30px));
  padding: 0;
  border: 5px solid var(--pixel-border);
  background: var(--bg-sky);
  color: var(--text-main);
  box-shadow: 12px 12px 0 var(--shadow);
}

.preset-dialog::backdrop {
  background: rgba(9, 5, 15, 0.82);
}

.dialog-shell {
  padding: clamp(18px, 4vw, 32px);
}

.dialog-heading {
  margin-bottom: 24px;
}

.dialog-heading h2 {
  margin: 0;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
}

.preset-form-section,
.saved-presets-section {
  padding: 20px;
  border: 4px solid var(--pixel-border);
  background: var(--panel-dark);
}

.saved-presets-section {
  margin-top: 18px;
}

.preset-form-grid {
  display: grid;
  grid-template-columns: 1.25fr 0.8fr 1fr;
  gap: 13px;
  margin-top: 16px;
}

.preset-form-grid label {
  display: grid;
  gap: 7px;
}

.preset-form-grid label > span {
  color: var(--text-dim);
  font-size: 0.62rem;
}

.preset-form-grid input,
.preset-form-grid select {
  width: 100%;
  min-width: 0;
  padding: 12px;
  border: 4px solid var(--pixel-border);
  border-radius: 0;
  background: var(--text-main);
  color: var(--bg-deep);
}

.form-help {
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
}

.dialog-primary {
  margin-top: 16px;
  padding: 12px 18px;
}

.dialog-message {
  min-height: 1.2em;
  margin: 12px 0 0;
  color: var(--slime-green);
  font-size: 0.85rem;
}

.saved-preset-list {
  display: grid;
  gap: 10px;
  margin-top: 15px;
}

.saved-preset-empty {
  margin: 0;
  padding: 16px;
  border: 3px dashed var(--panel);
  color: var(--text-dim);
  text-align: center;
}

.saved-preset-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 3px solid var(--pixel-border);
  background: var(--panel-mid);
}

.saved-preset-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: center;
}

.saved-preset-info strong {
  grid-column: 1 / -1;
  color: var(--ghost-blue);
  font-family: "Silkscreen", monospace;
  font-size: 0.75rem;
}

.saved-preset-info span {
  color: var(--text-dim);
  font-size: 0.8rem;
}

.delete-preset-button {
  min-height: 42px;
  padding: 8px 11px;
  border: 3px solid var(--pixel-border);
  background: var(--danger-red);
  box-shadow: 3px 3px 0 var(--pixel-border);
  color: var(--bg-deep);
  cursor: pointer;
  font-size: 0.62rem;
}

.dialog-footer {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 18px;
}

/* Traffic light */
.traffic-scene {
  display: grid;
  justify-items: center;
}

.traffic-housing {
  display: grid;
  gap: 13px;
  width: 126px;
  padding: 17px;
  border: 5px solid var(--pixel-border);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 7px 7px 0 var(--pixel-border);
}

.traffic-bulb {
  width: 82px;
  height: 82px;
  border: 5px solid var(--pixel-border);
  border-radius: 50%;
  background: var(--bg-deep);
  opacity: 0.28;
}

.traffic-bulb.is-on { opacity: 1; }
.traffic-bulb.red.is-on { background: var(--danger-red); }
.traffic-bulb.yellow.is-on { background: var(--gold); }
.traffic-bulb.green.is-on { background: var(--slime-green); }
.traffic-bulb.red.is-finished { animation: flash 0.55s steps(2, end) infinite; }

.traffic-post {
  width: 18px;
  height: 54px;
  border-right: 5px solid var(--pixel-border);
  border-left: 5px solid var(--pixel-border);
  background: var(--panel);
}

.traffic-base {
  width: 110px;
  height: 18px;
  border: 5px solid var(--pixel-border);
  background: var(--panel);
}

/* Dinosaur egg */
.egg-scene {
  position: relative;
  display: grid;
  place-items: end center;
  width: 260px;
  height: 280px;
}

.egg-shell {
  position: relative;
  width: 165px;
  height: 220px;
  border: 5px solid var(--pixel-border);
  border-radius: 50% 50% 45% 45% / 58% 58% 42% 42%;
  background: var(--text-main);
  box-shadow: inset -18px -12px 0 rgba(45, 30, 79, 0.2);
  transform-origin: bottom center;
}

.egg-shell.is-rocking { animation: egg-rock 0.42s steps(2, end) infinite; }

.egg-spot {
  position: absolute;
  width: 26px;
  height: 19px;
  border: 3px solid var(--pixel-border);
  border-radius: 50%;
  background: var(--slime-green);
}

.egg-spot.one { top: 55px; left: 32px; transform: rotate(-18deg); }
.egg-spot.two { right: 26px; bottom: 52px; transform: rotate(22deg); }
.egg-spot.three { right: 33px; top: 36px; width: 18px; height: 15px; }

.crack {
  position: absolute;
  width: 4px;
  background: var(--pixel-border);
  opacity: 0;
  transform-origin: top center;
}

.crack.is-visible { opacity: 1; }
.crack.one { top: 38px; left: 82px; height: 54px; transform: rotate(25deg); }
.crack.two { top: 86px; left: 62px; height: 47px; transform: rotate(-37deg); }
.crack.three { top: 98px; left: 102px; height: 43px; transform: rotate(43deg); }

.dino-character {
  position: absolute;
  bottom: 18px;
  display: none;
  font-size: 8.5rem;
  line-height: 1;
}

.egg-scene.is-hatched .egg-shell { display: none; }
.egg-scene.is-hatched .dino-character { display: block; animation: hatch-pop 0.55s cubic-bezier(.2, 1.4, .4, 1); }

/* Ice cube */
.ice-scene { position: relative; width: 330px; height: 280px; }

.ice-puddle {
  position: absolute;
  bottom: 36px;
  left: 50%;
  width: 240px;
  height: 45px;
  border: 5px solid var(--pixel-border);
  border-radius: 50%;
  background: var(--ghost-blue);
  transform: translateX(-50%) scaleX(0.12);
  transform-origin: center;
}

.ice-cube {
  position: absolute;
  bottom: 70px;
  left: 50%;
  width: 170px;
  height: 170px;
  border: 5px solid var(--pixel-border);
  background: #bff3ff;
  box-shadow: inset -22px -18px 0 rgba(105, 229, 255, 0.36);
  transform: translateX(-50%);
}

.ice-shine {
  position: absolute;
  top: 23px;
  left: 25px;
  width: 47px;
  height: 19px;
  border-top: 8px solid rgba(255, 255, 255, 0.9);
  border-left: 8px solid rgba(255, 255, 255, 0.9);
}

/* Balloon */
.balloon-scene { position: relative; display: grid; place-items: start center; width: 320px; height: 300px; }
.balloon-wrap { position: relative; width: 120px; height: 240px; transform-origin: 50% 170px; }

.balloon-body {
  position: absolute;
  top: 5px;
  left: 10px;
  width: 100px;
  height: 125px;
  border: 5px solid var(--pixel-border);
  border-radius: 52% 48% 47% 53% / 58% 58% 42% 42%;
  background: var(--silly-pink);
  box-shadow: inset -12px -8px 0 rgba(27, 16, 53, 0.17);
}

.balloon-knot {
  position: absolute;
  top: 124px;
  left: 51px;
  width: 18px;
  height: 16px;
  border: 4px solid var(--pixel-border);
  background: var(--silly-pink);
  transform: rotate(45deg);
}

.balloon-string { position: absolute; top: 141px; left: 59px; width: 3px; height: 95px; background: var(--text-main); }
.balloon-wrap.is-shaking { animation: balloon-shake 0.18s steps(2, end) infinite; }
.balloon-burst { position: absolute; top: 55px; display: none; font-size: 8rem; line-height: 1; }
.balloon-scene.is-popped .balloon-wrap { display: none; }
.balloon-scene.is-popped .balloon-burst { display: block; animation: hatch-pop 0.35s ease-out; }

/* Rocket */
.rocket-scene { position: relative; width: 390px; height: 310px; }

.fuel-meter {
  position: absolute;
  left: 24px;
  top: 44px;
  width: 48px;
  height: 200px;
  border: 5px solid var(--pixel-border);
  background: var(--panel-mid);
}

.fuel-fill { position: absolute; right: 0; bottom: 0; left: 0; height: 0%; background: var(--slime-green); }
.fuel-label { position: absolute; left: -6px; bottom: -31px; font-family: "Silkscreen", monospace; font-size: 0.63rem; }
.rocket-platform { position: absolute; right: 32px; bottom: 28px; width: 220px; height: 22px; border: 5px solid var(--pixel-border); background: var(--panel); }
.rocket-character { position: absolute; right: 76px; bottom: 48px; font-size: 8.5rem; line-height: 1; transform: rotate(-45deg); transform-origin: center; }
.rocket-flame { position: absolute; right: 171px; bottom: 43px; display: none; font-size: 3.4rem; transform: rotate(135deg); }
.rocket-flame.is-visible { display: block; animation: flame-pulse 0.25s steps(2, end) infinite; }
.rocket-scene.is-launched .rocket-character { animation: rocket-launch 1.1s ease-in forwards; }
.rocket-scene.is-launched .rocket-flame { display: block; }

/* Bomb */
.bomb-scene { position: relative; width: 390px; height: 290px; }
.bomb-character { position: absolute; left: 80px; bottom: 30px; font-size: 9rem; line-height: 1; transform-origin: center; }
.bomb-character.is-danger { animation: danger-shake 0.16s steps(2, end) infinite; }

.fuse-track {
  position: absolute;
  top: 74px;
  left: 190px;
  width: 150px;
  height: 16px;
  border: 4px solid var(--pixel-border);
  background: var(--panel-mid);
  transform: rotate(-13deg);
  transform-origin: left center;
}

.fuse-inner { width: 100%; height: 100%; background: var(--fire-orange); transform-origin: left center; }
.bomb-spark { position: absolute; top: 34px; right: 22px; font-size: 3rem; animation: spark-pulse 0.32s steps(2, end) infinite; }
.bomb-explosion { position: absolute; inset: 0; display: none; place-items: center; font-size: 9rem; }
.bomb-scene.is-exploded .bomb-character,
.bomb-scene.is-exploded .fuse-track,
.bomb-scene.is-exploded .bomb-spark { display: none; }
.bomb-scene.is-exploded .bomb-explosion { display: grid; animation: hatch-pop 0.35s ease-out; }

@keyframes flash { 0%, 45% { opacity: 1; } 46%, 100% { opacity: 0.25; } }
@keyframes egg-rock { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
@keyframes hatch-pop { from { opacity: 0; transform: scale(0.35); } to { opacity: 1; transform: scale(1); } }
@keyframes balloon-shake { from { translate: -5px 0; rotate: -2deg; } to { translate: 5px 0; rotate: 2deg; } }
@keyframes rocket-launch { 0% { transform: translate(0, 0) rotate(-45deg); } 18% { transform: translate(-5px, 6px) rotate(-45deg); } 100% { transform: translate(180px, -390px) rotate(-45deg); } }
@keyframes flame-pulse { from { scale: 0.82; } to { scale: 1.15; } }
@keyframes danger-shake { from { transform: translateX(-5px) rotate(-2deg); } to { transform: translateX(5px) rotate(2deg); } }
@keyframes spark-pulse { from { scale: 0.8; rotate: -8deg; } to { scale: 1.18; rotate: 8deg; } }

@media (max-width: 760px) {
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .section-title-row { align-items: flex-start; flex-direction: column; }
  .timer-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .preset-form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
  .timer-app { width: min(100% - 16px, 1020px); margin: 8px auto; }
  .screen { box-shadow: 6px 6px 0 var(--shadow); }
  .setup-screen, .timer-screen { padding: 15px; }
  .screen-heading { align-items: center; }
  .icon-button { width: 46px; height: 46px; }
  .console-label-row { align-items: flex-start; flex-direction: column; }
  .setup-time-display { letter-spacing: 0; }
  .keypad { gap: 8px; }
  .keypad-button { min-height: 60px; box-shadow: 4px 4px 0 var(--pixel-border); }
  .theme-grid { gap: 11px; }
  .theme-card { min-height: 126px; padding: 14px 7px; box-shadow: 4px 4px 0 var(--pixel-border); }
  .timer-toolbar { grid-template-columns: 1fr 1fr; }
  .theme-label { grid-column: 1 / -1; grid-row: 1; }
  #backButton, #muteButton { grid-row: 2; }
  .timer-stage { min-height: 300px; }
  .timer-visual { transform: scale(0.82); }
  .keyboard-help { line-height: 1.6; }
  .preset-dialog { width: calc(100% - 12px); }
  .dialog-shell { padding: 14px; }
  .dialog-heading { align-items: center; }
  .dialog-footer { grid-template-columns: 1fr; }
  .saved-preset-item { grid-template-columns: 1fr; }
  .delete-preset-button { justify-self: start; }
}

/* Version 3 setup layout: phone keypad beside timer choices */
body {
  overflow-x: hidden;
}

.timer-app {
  width: min(1180px, calc(100% - 28px));
}

.setup-workspace {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  gap: clamp(20px, 3vw, 32px);
  align-items: start;
}

.time-console,
.setup-actions-column,
.theme-section {
  min-width: 0;
}

.setup-actions-column {
  display: flex;
  flex-direction: column;
}

.setup-time-display {
  margin: 14px 0 16px;
  padding: clamp(13px, 2vw, 20px) 8px;
  font-size: clamp(3rem, 6.3vw, 5.7rem);
}

.keypad {
  width: 100%;
  max-width: none;
  gap: 10px;
}

.keypad-button {
  min-height: clamp(58px, 6.5vw, 72px);
}

.preset-block {
  margin-top: 22px;
  padding-top: 18px;
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: 9px;
  width: 100%;
}

.preset-button {
  width: 100%;
  min-width: 0;
}

.preset-button.custom-preset {
  display: grid;
}

.theme-section {
  margin-top: 0;
  padding: clamp(16px, 2.5vw, 26px);
  border: 5px solid var(--pixel-border);
  background: var(--panel-dark);
  box-shadow: 8px 8px 0 var(--pixel-border);
}

.theme-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.theme-card {
  min-height: clamp(122px, 13vw, 154px);
  padding: 16px 8px;
}

.theme-preview {
  font-size: clamp(2.7rem, 5.8vw, 4.2rem);
}

.start-button {
  margin-top: 24px;
}

@media (max-width: 880px) {
  .setup-workspace {
    grid-template-columns: 1fr;
  }

  .setup-actions-column {
    margin-top: 4px;
  }

  .setup-time-display {
    font-size: clamp(3.4rem, 13vw, 6.6rem);
  }

  .theme-card {
    min-height: 135px;
  }
}

@media (max-width: 520px) {
  .setup-workspace {
    gap: 18px;
  }

  .time-console,
  .theme-section {
    padding: 14px;
    box-shadow: 5px 5px 0 var(--pixel-border);
  }

  .preset-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preset-button:last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .theme-grid {
    gap: 10px;
  }

  .theme-card {
    min-height: 118px;
  }
}


/* Physical keyboard / numeric keypad feedback */
.keypad-button.is-key-pressed {
  transform: translateY(4px);
  box-shadow: 0 2px 0 var(--pixel-border);
  background: var(--gold);
  color: var(--pixel-border);
}


/* Version 5: readable clock, hours, compact selector, and fullscreen toolbar */
.setup-workspace {
  grid-template-columns: minmax(0, 1.7fr) minmax(275px, 0.95fr);
}

.setup-time-display,
#timeDisplay {
  font-family: "Arial Rounded MT Bold", "Trebuchet MS", Arial, Helvetica, sans-serif;
  font-weight: 800;
  font-variant-numeric: tabular-nums lining-nums;
}

.setup-time-display {
  margin-bottom: 8px;
  font-size: clamp(2.75rem, 5.25vw, 5.25rem);
  letter-spacing: 0.015em;
  white-space: nowrap;
}

.time-unit-labels {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 0 4px 16px;
  color: var(--text-dim);
  font-family: "Silkscreen", monospace;
  font-size: clamp(0.48rem, 0.9vw, 0.64rem);
  text-align: center;
}

.preset-row {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.theme-section {
  padding: clamp(14px, 2vw, 20px);
}

.theme-grid {
  gap: 10px;
}

.theme-card {
  min-height: clamp(94px, 9.5vw, 112px);
  padding: 11px 6px;
  border-width: 4px;
  box-shadow: 4px 4px 0 var(--pixel-border);
}

.theme-preview {
  font-size: clamp(2.1rem, 4vw, 3rem);
  filter: drop-shadow(3px 3px 0 var(--pixel-border));
}

.theme-card > span:last-child {
  margin-top: 7px;
  font-size: clamp(0.58rem, 1.25vw, 0.72rem);
}

#timeDisplay {
  font-size: clamp(3.4rem, 11vw, 7.25rem);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.timer-toolbar {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

#muteButton {
  justify-self: auto;
}

@media (max-width: 880px) {
  .setup-workspace {
    grid-template-columns: 1fr;
  }

  .setup-time-display {
    font-size: clamp(2.8rem, 10vw, 5.8rem);
  }
}

@media (max-width: 620px) {
  .timer-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .theme-label {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  #backButton {
    grid-column: 1;
    grid-row: 2;
  }

  .toolbar-actions {
    grid-column: 2;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .toolbar-actions .toolbar-button {
    width: 100%;
  }

  .preset-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .preset-button:last-child:nth-child(odd) {
    grid-column: auto;
  }
}

@media (max-width: 390px) {
  .setup-time-display {
    font-size: clamp(2.2rem, 12vw, 3.2rem);
  }

  #timeDisplay {
    font-size: clamp(2.75rem, 13vw, 4rem);
  }
}


/* Version 6: optional YouTube music player */
.music-slot {
  margin-top: clamp(22px, 3vw, 34px);
}

.music-panel {
  min-width: 0;
  padding: clamp(16px, 2.5vw, 26px);
  border: 5px solid var(--pixel-border);
  background: var(--panel-dark);
  box-shadow: 8px 8px 0 var(--pixel-border);
}

.music-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.music-heading h2 {
  margin: 0;
  color: var(--text-main);
  font-size: clamp(1.15rem, 2.4vw, 1.7rem);
}

.music-heading p:last-child {
  max-width: 670px;
  margin: 8px 0 0;
  color: var(--text-dim);
}

.music-state-badge {
  flex: 0 0 auto;
  padding: 9px 11px;
  border: 3px solid var(--pixel-border);
  background: var(--panel-mid);
  color: var(--text-dim);
  font-family: "Silkscreen", monospace;
  font-size: 0.62rem;
  text-align: center;
}

.music-state-badge[data-state="ready"],
.music-state-badge[data-state="paused"] {
  background: var(--gold);
  color: var(--pixel-border);
}

.music-state-badge[data-state="playing"] {
  background: var(--real-green);
  color: var(--pixel-border);
}

.music-state-badge[data-state="error"] {
  background: var(--danger-red);
  color: var(--text-main);
}

.music-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: clamp(18px, 3vw, 30px);
  align-items: start;
}

.music-layout:not(:has(.music-player-area:not([hidden]))) {
  grid-template-columns: 1fr;
}

.music-url-label,
.music-end-label > span,
.music-volume > span {
  display: block;
  margin-bottom: 8px;
  color: var(--ghost-blue);
  font-family: "Silkscreen", monospace;
  font-size: 0.7rem;
}

.music-url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.music-url-row input,
.music-end-label select {
  width: 100%;
  min-width: 0;
  border: 4px solid var(--pixel-border);
  background: var(--text-main);
  color: var(--bg-deep);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.12);
}

.music-url-row input {
  padding: 12px 14px;
}

.music-end-label select {
  margin-top: 0;
  padding: 9px 10px;
}

.music-load-button {
  min-width: 154px;
  padding-inline: 16px;
}

.music-status {
  min-height: 1.4em;
  margin: 12px 0 18px;
  color: var(--text-dim);
  font-size: 0.92rem;
}

.music-status[data-tone="error"] {
  color: #ffd6dc;
}

.music-status[data-tone="success"] {
  color: var(--real-green);
}

.music-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.music-check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 43px;
  padding: 9px 10px;
  border: 3px solid var(--pixel-border);
  background: var(--panel-mid);
  cursor: pointer;
}

.music-check input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--fire-orange);
}

.music-check span {
  font-family: "Silkscreen", monospace;
  font-size: 0.62rem;
}

.music-end-label {
  grid-column: 1 / -1;
}

.music-player-area {
  min-width: 0;
}

.youtube-player-shell {
  width: 100%;
  min-height: 200px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 5px solid var(--pixel-border);
  background: #000;
  box-shadow: 6px 6px 0 var(--pixel-border);
}

.youtube-player-shell iframe,
.youtube-player-shell > div {
  display: block;
  width: 100% !important;
  height: 100% !important;
  min-height: 200px;
  border: 0;
}

.music-transport {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.music-transport button {
  min-width: 0;
  padding: 10px 7px;
  font-size: 0.58rem;
}

.danger-outline {
  color: var(--danger-red);
}

.music-volume {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 15px;
}

.music-volume > span {
  margin: 0;
}

.music-volume input {
  width: 100%;
  accent-color: var(--fire-orange);
}

.music-volume output {
  min-width: 44px;
  color: var(--gold);
  font-family: "Silkscreen", monospace;
  font-size: 0.66rem;
  text-align: right;
}

.timer-music-slot .music-panel {
  background: var(--panel-dark);
}

.timer-music-slot .music-heading p:last-child,
.timer-music-slot .music-url-label,
.timer-music-slot .music-url-row,
.timer-music-slot .music-options {
  display: none;
}

.timer-music-slot .music-heading {
  margin-bottom: 14px;
}

.timer-music-slot .music-layout {
  grid-template-columns: 1fr;
}

.timer-music-slot .music-status {
  margin-top: 0;
}

@media (max-width: 880px) {
  .music-layout {
    grid-template-columns: 1fr;
  }

  .youtube-player-shell {
    max-width: 520px;
    margin-inline: auto;
  }
}

@media (max-width: 560px) {
  .music-panel {
    padding: 14px;
    box-shadow: 5px 5px 0 var(--pixel-border);
  }

  .music-heading {
    flex-direction: column;
    gap: 10px;
  }

  .music-url-row {
    grid-template-columns: 1fr;
  }

  .music-load-button {
    width: 100%;
  }

  .music-options {
    grid-template-columns: 1fr;
  }

  .music-end-label {
    grid-column: auto;
  }

  .music-transport {
    grid-template-columns: 1fr;
  }
}

/* =========================================================
   QUICK TUTORIAL + HELP
   ========================================================= */

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.help-dialog,
.tutorial-welcome-dialog {
  width: min(620px, calc(100% - 28px));
  max-width: none;
  padding: 0;
  border: 5px solid var(--pixel-border);
  background: var(--bg-sky);
  color: var(--text-main);
  box-shadow: 10px 10px 0 var(--shadow);
}

.help-dialog::backdrop,
.tutorial-welcome-dialog::backdrop {
  background: rgba(1, 22, 30, 0.76);
}

.help-shell,
.welcome-shell {
  padding: clamp(20px, 4vw, 34px);
}

.compact-heading {
  margin-bottom: 20px;
}

.tutorial-launch-button {
  width: 100%;
  margin-bottom: 22px;
}

.help-reference {
  padding-top: 20px;
  border-top: 3px dashed var(--panel);
}

.help-reference h3 {
  margin: 0 0 14px;
  color: var(--ghost-blue);
  font-size: 0.78rem;
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
  color: var(--text-dim);
}

.shortcut-grid span {
  display: flex;
  align-items: center;
  gap: 9px;
}

kbd {
  min-width: 48px;
  padding: 5px 7px;
  border: 3px solid var(--pixel-border);
  background: var(--panel-dark);
  box-shadow: 3px 3px 0 var(--pixel-border);
  color: var(--gold);
  font-family: "Silkscreen", monospace;
  font-size: 0.68rem;
  text-align: center;
}

.welcome-shell h2 {
  margin: 0;
  font-family: "Silkscreen", monospace;
  font-size: clamp(1.45rem, 4vw, 2rem);
}

.welcome-shell > p:not(.eyebrow) {
  margin: 16px 0 0;
  color: var(--text-dim);
  line-height: 1.55;
}

.welcome-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.4fr;
  gap: 12px;
  margin-top: 24px;
}

.tutorial-layer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: visible;
  background: transparent;
  pointer-events: none;
}

.tutorial-mask {
  position: fixed;
  background: rgba(1, 20, 28, 0.72);
  pointer-events: none;
  transition: top 160ms ease, left 160ms ease, width 160ms ease, height 160ms ease;
}

.tutorial-bubble {
  position: fixed;
  z-index: 3;
  width: min(390px, calc(100vw - 24px));
  padding: 18px;
  border: 4px solid var(--pixel-border);
  background: var(--panel-dark);
  box-shadow: 7px 7px 0 var(--pixel-border);
  color: var(--text-main);
  pointer-events: auto;
}

.tutorial-progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--gold);
  font-family: "Silkscreen", monospace;
  font-size: 0.66rem;
}

.tutorial-exit-button {
  padding: 3px 0;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-family: "Silkscreen", monospace;
  font-size: 0.62rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.tutorial-bubble h2 {
  margin: 0;
  color: var(--ghost-blue);
  font-family: "Silkscreen", monospace;
  font-size: 1.05rem;
}

.tutorial-bubble p {
  margin: 12px 0 0;
  color: var(--text-main);
  line-height: 1.48;
}

.tutorial-bubble .tutorial-hint {
  color: var(--text-dim);
  font-size: 0.86rem;
}

.tutorial-continue-button {
  width: 100%;
  margin-top: 16px;
}

.is-tutorial-target {
  position: relative !important;
  z-index: 2 !important;
  outline: 5px solid var(--gold) !important;
  outline-offset: 5px !important;
  box-shadow:
    0 0 0 9px rgba(253, 252, 220, 0.18),
    0 0 28px rgba(101, 227, 242, 0.72) !important;
}

@media (max-width: 640px) {
  .header-actions {
    gap: 8px;
  }

  .shortcut-grid {
    grid-template-columns: 1fr;
  }

  .welcome-actions {
    grid-template-columns: 1fr;
  }

  .tutorial-bubble {
    padding: 15px;
  }
}

/* =========================================================
   V14 — SETUP SCREEN FULLSCREEN WIDTH
   Normal browser layout stays unchanged. When fullscreen is
   active, the setup workspace expands to use more display
   space while keeping a comfortable outer margin.
   ========================================================= */

html:fullscreen .timer-app,
html:-webkit-full-screen .timer-app {
  width: min(94vw, 1500px);
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

html:fullscreen .setup-screen,
html:-webkit-full-screen .setup-screen {
  padding-left: clamp(24px, 3vw, 54px);
  padding-right: clamp(24px, 3vw, 54px);
}

html:fullscreen .setup-workspace,
html:-webkit-full-screen .setup-workspace {
  grid-template-columns:
    minmax(0, 1.65fr)
    minmax(380px, 0.95fr);
  gap: clamp(24px, 2.5vw, 42px);
}

html:fullscreen .music-slot,
html:-webkit-full-screen .music-slot {
  width: 100%;
}



/* Last Bell Studio website integration */
.site-return-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border: 4px solid var(--pixel-border);
  color: var(--text-main);
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--shadow);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1.15;
  text-decoration: none;
  white-space: nowrap;
}
.site-return-link:hover { transform: translate(-1px,-1px); filter: brightness(1.04); }
.site-return-link:active { transform: translate(3px,3px); box-shadow: 0 0 0 var(--shadow); }
.site-return-link:focus-visible { outline: 4px solid var(--ghost-blue); outline-offset: 3px; }
.toolbar-site-return { min-height: 38px; padding: 7px 10px; font-size: 0.66rem; }
.video-tutorial-link { display:flex; width:100%; margin-top:10px; text-decoration:none; justify-content:center; }
@media (max-width: 720px) {
  .site-return-link { min-height: 38px; padding: 7px 9px; font-size: 0.62rem; }
}


/* V13 QA — independent BGM + projector readability */
#timeDisplay{text-shadow:none!important;}
.music-status{color:var(--pixel-border);font-weight:800;}
.music-options-independent{grid-template-columns:minmax(150px,220px) 1fr;align-items:center;}
.music-independent-note{margin:0;color:var(--text-dim);font-size:.8rem;font-weight:700;line-height:1.5;}
@media(max-width:650px){.music-options-independent{grid-template-columns:1fr;}}

/* =========================================================
   V14 QA ROUND 2 — compact-window timer artwork scaling
   All theme art can shrink for floating/split-screen use,
   but stops at 50% so the illustrations keep their character.
   ========================================================= */
.timer-visual{transform-origin:center center;transition:transform .16s ease;}
@media (max-width:900px), (max-height:820px){.timer-visual{transform:scale(.78);}}
@media (max-width:700px), (max-height:700px){.timer-visual{transform:scale(.64);}}
@media (max-width:560px), (max-height:600px){.timer-visual{transform:scale(.50);}}

/* =========================================================
   V14.3 — compact-window timer container scaling
   The artwork already shrinks in V14. This patch also lets
   the surrounding timer stage and timer screen shrink with it,
   while preserving the artwork's 50% lower clamp.
   ========================================================= */

/* Short laptop / split-screen windows */
@media (max-height: 760px) {
  .timer-screen {
    min-height: 0;
    padding-top: 14px;
    padding-bottom: 14px;
  }

  .timer-toolbar {
    gap: 9px;
  }

  .timer-readout {
    margin: 14px 0 8px;
  }

  .timer-stage {
    min-height: clamp(210px, 40vh, 280px);
    box-shadow: 6px 6px 0 var(--pixel-border);
  }

  .timer-visual {
    height: clamp(185px, 36vh, 250px);
  }

  .timer-controls {
    gap: 8px;
    margin-top: 14px;
  }
}

/* Very compact floating-window mode */
@media (max-height: 610px) {
  .timer-screen {
    min-height: 0;
    padding: 10px 12px 12px;
  }

  .timer-toolbar {
    gap: 7px;
  }

  .timer-readout {
    margin: 8px 0 6px;
  }

  .timer-readout p {
    margin-bottom: 2px;
  }

  .timer-stage {
    min-height: clamp(155px, 34vh, 205px);
    border-width: 4px;
    box-shadow: 5px 5px 0 var(--pixel-border);
  }

  .timer-visual {
    height: clamp(140px, 31vh, 185px);
  }

  .timer-controls {
    gap: 7px;
    margin-top: 10px;
  }

  .timer-controls button {
    min-height: 46px;
  }
}

/* Tiny floating window: preserve the art at its V14 50% floor,
   but remove any leftover empty stage height. */
@media (max-height: 500px) {
  .timer-stage {
    min-height: 145px;
  }

  .timer-visual {
    height: 135px;
  }

  .timer-readout {
    margin-top: 5px;
  }
}

/* =========================================================
   V16 — readable YouTube track title/status
   ========================================================= */
.music-status,
.timer-music-slot .music-status{
  color:#09199A!important;
  font-weight:800;
}
.music-status[data-tone="error"]{
  color:#b42332!important;
}

/* =========================================================
   V16.2 — classroom QA: fullscreen access, compact artwork,
   music controls, and stronger timer labels
   ========================================================= */
.theme-label{
  color:#09199A!important;
  font-weight:900;
}

/* When the active timer itself enters fullscreen, keep the whole timer
   vertically scrollable so music controls/video are always reachable. */
#timerScreen:fullscreen,
#timerScreen:-webkit-full-screen{
  width:100vw;
  height:100vh;
  max-height:100vh;
  overflow-x:hidden;
  overflow-y:auto;
  overscroll-behavior:contain;
  box-sizing:border-box;
  scrollbar-gutter:stable;
}

/* On short laptop viewports, center the full character canvas instead of
   relying on the old fixed -90px art offset. This prevents feet/bottom art
   from being clipped while keeping the normal desktop composition unchanged. */
@media (max-height:760px){
  #timerVisual [data-art-scene]{
    width:92%!important;
    height:92%!important;
  }
  #timerVisual [data-timer-art]{
    top:0!important;
    width:100%!important;
    height:100%!important;
    max-width:100%!important;
    max-height:100%!important;
    object-position:center center!important;
  }
}

/* Music actions live above the YouTube preview. Volume intentionally remains
   below the video. Icons carry the action at classroom-glance distance. */
.music-transport{
  margin-top:0;
  margin-bottom:14px;
}
.music-transport .music-icon-button{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  min-height:52px;
}
.music-action-icon{
  display:inline-grid;
  place-items:center;
  min-width:1.6em;
  font-family:Arial,sans-serif;
  font-size:1.22rem;
  font-weight:900;
  line-height:1;
}
.music-action-label{
  font-family:"Silkscreen",monospace;
  font-size:.56rem;
  line-height:1.1;
}
.keypad-clear{
  font-weight:900;
}
.motion-help p{
  margin:.55rem 0 0;
  line-height:1.5;
}

@media (max-width:650px){
  .music-transport .music-icon-button{
    gap:6px;
    min-height:48px;
  }
  .music-action-icon{font-size:1.05rem;}
  .music-action-label{font-size:.5rem;}
}


/* =========================================================
   V16.8 — ONE-PIECE ACTIVE TIMER SCALING
   The artwork box is gone. The active timer uses a fixed classroom
   composition that is uniformly scaled to fit the available window.
   ========================================================= */
body.timer-running-view {
  overflow: auto;
}
body.timer-running-view .timer-app {
  width: min(1020px, calc(100% - 10px));
  margin: 5px auto;
}
#timerScreen {
  min-height: 0 !important;
  padding: 6px !important;
  overflow: visible;
}
.timer-fit-frame {
  position: relative;
  margin: 0 auto;
  overflow: visible;
}
.timer-active-composition {
  position: absolute;
  top: 0;
  left: 0;
  width: 940px;
  padding: 12px;
  transform-origin: top left;
  will-change: transform;
}
.timer-active-composition .timer-toolbar {
  gap: 14px;
}
.timer-active-composition .timer-readout {
  margin: 18px 0 8px;
}
.timer-active-composition #timeDisplay {
  font-size: 7.4rem;
  line-height: 1;
  text-shadow: none !important;
}
.timer-visual-open,
.timer-active-composition .timer-visual-open {
  position: relative;
  display: grid;
  place-items: center;
  width: 100% !important;
  height: 300px !important;
  min-height: 0 !important;
  margin: 0 auto;
  overflow: visible;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  transform: none !important;
}
#timerVisual [data-art-scene] {
  width: 100% !important;
  height: 100% !important;
  overflow: visible !important;
}
#timerVisual [data-timer-art] {
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: 720px !important;
  max-height: 300px !important;
  object-fit: contain !important;
  object-position: center center !important;
}
.timer-active-composition .timer-controls {
  gap: 12px;
  margin-top: 12px;
}
.timer-active-composition .keyboard-help {
  margin: 12px 0 0;
}
.timer-active-composition .finished-panel {
  margin-top: 12px;
}
/* The old V14/V14.3 viewport rules resized only the illustration. Once the
   whole composition is scaled, those transforms would double-shrink it. */
@media (max-width: 900px), (max-height: 820px),
       (max-width: 700px), (max-height: 700px),
       (max-width: 560px), (max-height: 600px) {
  .timer-active-composition .timer-visual { transform: none !important; }
}
@media (max-width: 520px) {
  .timer-active-composition .timer-controls { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Keep the fixed composition from reflowing under the setup/mobile media
   queries. The viewport is handled by the single outer scale instead. */
.timer-active-composition .timer-toolbar {
  grid-template-columns: 1fr auto 1fr !important;
}
.timer-active-composition .theme-label {
  grid-column: auto !important;
  grid-row: auto !important;
}
.timer-active-composition #backButton,
.timer-active-composition #muteButton {
  grid-row: auto !important;
}
.timer-active-composition .timer-controls {
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}
.timer-active-composition .timer-controls button {
  min-height: 54px !important;
  padding: 11px 8px !important;
  font-size: .72rem !important;
}
.timer-active-composition .toolbar-button {
  min-height: initial;
  padding: 10px 12px !important;
  font-size: .68rem !important;
}
.timer-active-composition .toolbar-site-return {
  min-height: 38px !important;
  padding: 7px 10px !important;
  font-size: .66rem !important;
}
.timer-active-composition .theme-label {
  padding: 9px 12px !important;
  font-size: .72rem !important;
}
.timer-active-composition .timer-readout p {
  display: block !important;
  margin: 0 0 5px !important;
  font-size: .72rem !important;
}
.timer-active-composition .keyboard-help {
  display: block !important;
  font-size: .78rem !important;
  line-height: normal !important;
}
