:root {
  color-scheme: only light;
  font-family: "Trebuchet MS", Arial, sans-serif;
  /* Desktop phone-frame ratio (classic mobile 9:16) */
  --game-ar-w: 9;
  --game-ar-h: 16;
}
* { box-sizing: border-box; }
html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #3a2010;
}
@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}
body { display: grid; place-items: center; user-select: none; -webkit-user-select: none; }
button { border: 0; padding: 0; background-color: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }

/* Phones fill the screen — no side/top letterboxing */
#game {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: url("assets/bg-wood-vertical.png") center/cover no-repeat;
  box-shadow: 0 0 60px #071817;
}

/* Desktop / wide: lock a centered 9:16 phone frame */
@media (min-width: 480px) {
  #game {
    width: min(100vw, calc(100vh * var(--game-ar-w) / var(--game-ar-h)));
    height: min(100vh, calc(100vw * var(--game-ar-h) / var(--game-ar-w)));
  }
  @supports (height: 100dvh) {
    #game {
      width: min(100vw, calc(100dvh * var(--game-ar-w) / var(--game-ar-h)));
      height: min(100dvh, calc(100vw * var(--game-ar-h) / var(--game-ar-w)));
    }
  }
}
#game.hard-theme { background-image: url("assets/bg-wood-purple.png"); }

.screen { position: absolute; inset: 0; display: none; }
.screen.active { display: flex; }

/* Start screen */
#start-screen {
  isolation: isolate;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(9%, env(safe-area-inset-top)) 7% max(7%, env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, #3a160018 0%, transparent 26%, transparent 72%, #3a160030 100%),
    url("assets/bg-wood-vertical.png") center/cover no-repeat;
}
#start-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: radial-gradient(ellipse 74% 52% at 50% 34%, #ffe89c80 0%, #f7b84a24 46%, transparent 72%);
  animation: homeBreathe 4.8s ease-in-out infinite;
}
#start-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  box-shadow: inset 0 0 70px #4c1d005e;
}
.home-light {
  position: absolute;
  top: -18%; left: 50%;
  width: 86%; aspect-ratio: 1;
  translate: -50%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, #fff8cc92 0%, #ffd76e38 42%, transparent 72%);
  filter: blur(8px);
  animation: homeLight 5.5s ease-in-out infinite alternate;
}
.home-hero {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding-top: 2%;
  animation: homeEnter .7s cubic-bezier(.2,.8,.2,1) both;
}
.home-kicker {
  padding: .42em 1.25em;
  border: 1px solid #71371580;
  border-radius: 999px;
  color: #6a3014;
  background: #fff3c79c;
  box-shadow: 0 3px 10px #6c2d1426, inset 0 1px #fff9;
  font-size: clamp(10px, 1.45vh, 15px);
  font-weight: 900;
  letter-spacing: .18em;
}
.logo { width: 77%; height: auto; margin-top: 4%; filter: drop-shadow(0 9px 7px #5d321d70); }
.tagline { margin: 1% 0 3%; color: #4d2b19; font-size: clamp(15px, 2.25vh, 25px); font-weight: 900; letter-spacing: .025em; text-shadow: 0 2px #fff7; }
.home-rule { position: relative; width: 46%; height: 9px; border-radius: 99px; background: #5a2a1660; box-shadow: inset 0 2px 3px #2f130766; }
.home-rule i { display: block; width: 42%; height: 100%; margin: auto; border-radius: inherit; background: linear-gradient(90deg, #e4a62f, #ffe276, #e4a62f); box-shadow: 0 0 10px #ffd55e99; animation: homeRule 2.8s ease-in-out infinite; }
.home-actions {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 25%;
  grid-template-rows: auto auto;
  align-items: center;
  width: 100%;
  padding: 5% 5% 3%;
  border: 2px solid #f7d99480;
  border-radius: clamp(22px, 6vw, 34px);
  background: linear-gradient(180deg, #fff2c43d, #6d2e0b18);
  box-shadow: 0 15px 30px #51220738, inset 0 1px #fff9;
  backdrop-filter: blur(2px);
  animation: homeEnter .7s .14s cubic-bezier(.2,.8,.2,1) both;
}
.image-button { background-repeat: no-repeat; background-position: center; background-size: contain; width: 68%; aspect-ratio: 3.25; transition: transform .08s ease, filter .08s ease; }
.image-button:active, .icon-button:active, .footer-button:active { transform: scale(.94); filter: brightness(.9); }
.play-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7%;
  width: 100%;
  min-height: clamp(66px, 10.5vh, 94px);
  padding: 4% 8%;
  border: clamp(3px, .7vw, 5px) solid #f6d278;
  border-radius: clamp(20px, 5vw, 30px);
  color: #fff8dc;
  background: linear-gradient(180deg, #159a91 0%, #087f78 54%, #05645f 100%);
  box-shadow: 0 8px 0 #704018, 0 13px 18px #3e1b0755, inset 0 2px #8ef1d3aa, inset 0 -3px #003f3b88;
  text-shadow: 0 3px 0 #174b47;
  animation: playPulse 2.4s ease-in-out infinite;
}
.play-button::after { content: ""; position: absolute; inset: 6px; border: 1px solid #b9f2da80; border-radius: inherit; pointer-events: none; }
.play-button:active { animation: none; transform: translateY(5px) scale(.98); box-shadow: 0 3px 0 #704018, 0 6px 10px #3e1b0744, inset 0 2px #8ef1d3aa; }
.play-icon { width: clamp(27px, 7vw, 40px); aspect-ratio: 1; clip-path: polygon(25% 10%, 88% 50%, 25% 90%); background: linear-gradient(135deg, #fff8d7, #ffd05c); filter: drop-shadow(0 3px 0 #8b5a18); }
.play-copy { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.play-copy strong { font-size: clamp(25px, 4.5vh, 43px); letter-spacing: .04em; }
.play-copy small { margin-top: .45em; color: #d8fff4; font-size: clamp(8px, 1.15vh, 12px); font-weight: 900; letter-spacing: .18em; }
.settings-button { color: #583019; font-family: inherit; font-weight: 900; }
.home-settings-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  gap: 2px;
  margin-left: 12%;
  border: 3px solid #f3d486;
  border-radius: clamp(18px, 5vw, 28px);
  background: linear-gradient(#fff5cf, #dfaa5d);
  box-shadow: 0 7px 0 #74421c, 0 11px 15px #3e1b0744, inset 0 2px #fff;
}
.home-settings-button span { font-size: clamp(27px, 6vh, 45px); line-height: 1; text-shadow: 0 2px #fff8; }
.home-settings-button small { font-size: clamp(7px, 1vh, 10px); letter-spacing: .06em; }
.home-settings-button:active { translate: 0 4px; box-shadow: 0 3px 0 #74421c, 0 6px 8px #3e1b0733; }
.home-meta { grid-column: 1 / -1; margin: 4% 0 0; color: #673416b8; font-size: clamp(9px, 1.25vh, 13px); font-weight: 900; letter-spacing: .12em; text-align: center; }
.home-plank {
  position: absolute;
  z-index: 1;
  width: 43%; height: 5.2%;
  border: 2px solid #55250f;
  border-radius: 9px;
  background: linear-gradient(#d77b35, #9b471d 45%, #743013);
  box-shadow: 0 7px 10px #4b1d0755, inset 0 2px #f5b067, inset 0 -2px #59210e;
  opacity: .72;
}
.home-plank::after { content: ""; position: absolute; inset: 24% 8%; border-top: 1px solid #5b270d77; border-bottom: 1px solid #f0a25a55; }
.home-plank i,
.home-screw { width: clamp(20px, 6vw, 32px); aspect-ratio: 1; border-radius: 50%; background: url("assets/screw-head.png") center/contain no-repeat; filter: drop-shadow(0 3px 2px #35130688); }
.home-plank i { position: absolute; top: 50%; translate: 0 -50%; }
.home-plank i:first-child { left: 5%; }
.home-plank i:last-child { right: 5%; }
.home-plank-left { left: -17%; top: 47%; rotate: -27deg; animation: plankFloatLeft 5.2s ease-in-out infinite; }
.home-plank-right { right: -18%; top: 38%; rotate: 22deg; animation: plankFloatRight 5.8s ease-in-out infinite; }
.home-screw { position: absolute; z-index: 1; opacity: .62; }
.home-screw-one { left: 11%; top: 31%; animation: screwDrift 5s ease-in-out infinite; }
.home-screw-two { right: 12%; top: 57%; animation: screwDrift 5s 1.4s ease-in-out infinite reverse; }

@keyframes homeEnter { from { opacity: 0; translate: 0 22px; scale: .97; } to { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes homeBreathe { 50% { opacity: .72; scale: 1.04; } }
@keyframes homeLight { to { translate: -50% 4%; scale: 1.08; opacity: .76; } }
@keyframes homeRule { 0%,100% { translate: -48%; } 50% { translate: 48%; } }
@keyframes playPulse { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-3px) scale(1.018); } }
@keyframes plankFloatLeft { 50% { translate: 7px -10px; rotate: -22deg; } }
@keyframes plankFloatRight { 50% { translate: -7px 11px; rotate: 17deg; } }
@keyframes screwDrift { 50% { translate: 0 -13px; rotate: 110deg; } }

@media (prefers-reduced-motion: reduce) {
  #start-screen *, #start-screen::before { animation: none !important; }
}

/* Play screen */
#play-screen { flex-direction: column; padding: max(env(safe-area-inset-top), 10px) 3% max(env(safe-area-inset-bottom), 10px); }

.hud {
  height: 10.5%;
  position: relative;
  display: block;
  padding: 0;
  background: none;
  filter: none;
  z-index: 2;
}
.icon-button {
  position: absolute;
  width: 11.5%;
  aspect-ratio: 1;
  background: center/contain no-repeat;
  transition: transform .08s;
}
.pause-button {
  left: 10.1%;
  top: 49%;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  border: 2px solid #eacb81;
  border-radius: 50%;
  background: linear-gradient(#fff8d8, #dfaa5d);
  box-shadow: 0 3px 0 #78431e, 0 5px 8px #32150655, inset 0 2px #fff;
}
.pause-glyph { display: flex; gap: clamp(4px, 1vw, 7px); height: 42%; }
.pause-glyph i { display: block; width: clamp(5px, 1.4vw, 8px); height: 100%; border-radius: 3px; background: linear-gradient(#68452f, #342319); box-shadow: inset 1px 0 #9c7658; }
.game-settings-button {
  right: 3.5%;
  top: 49%;
  translate: 0 -50%;
  display: grid;
  place-items: center;
  border: 2px solid #eacb81;
  border-radius: 50%;
  color: #54301d;
  background: linear-gradient(#fff8d8, #dfaa5d);
  box-shadow: 0 3px 0 #78431e, 0 5px 8px #32150655;
  font-size: clamp(19px, 3vh, 30px);
  font-weight: 900;
}

.hud-center {
  position: absolute;
  left: 19%;
  right: 17%;
  top: 9%;
  bottom: 14%;
}
.level-badge {
  position: absolute;
  left: 50%;
  top: 0;
  translate: -50% 0;
  display: flex;
  align-items: baseline;
  gap: .35em;
  padding: 2px 16px 4px;
  background: url("assets/level-badge.png") center/100% 100% no-repeat;
  color: #3a2010;
  font-size: clamp(14px, 2vh, 22px);
  font-weight: 900;
  width: 48%;
  height: 39%;
  justify-content: center;
}
.level-label { font-size: .82em; opacity: .75; }
.level-badge strong { font-size: 1.15em; }

.progress-track {
  position: absolute;
  left: 50%;
  top: 48%;
  translate: -50% 0;
  width: 62%;
  height: clamp(7px, 1.1vh, 12px);
  overflow: hidden;
  border: 2px solid #6b4020;
  border-radius: 99px;
  background: #8a8078;
  box-shadow: inset 0 2px 3px #28160e66;
}
.progress-track i {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(#87ef4f, #31b52d);
  box-shadow: inset 0 2px #d8ff9e;
  transition: width .3s ease-out;
}

#timer {
  position: absolute;
  left: 50%;
  top: 67%;
  translate: -50% 0;
  min-width: 58px;
  padding: 1px 10px 2px;
  border-radius: 8px;
  color: white;
  background: #38231a;
  font-size: clamp(13px, 1.8vh, 20px);
  line-height: 1;
  font-weight: 900;
  text-align: center;
  text-shadow: 0 2px #140a06;
  box-shadow: 0 2px 0 #160a06;
}

.hard-banner {
  position: absolute;
  left: 10%;
  bottom: 18.2%;
  width: auto;
  max-width: 76%;
  padding: 5px 12px 6px;
  border: 2px solid #f5c85c;
  border-radius: 999px;
  background: linear-gradient(180deg, #51256f, #281137);
  box-shadow: 0 3px 0 #17091f, 0 5px 12px #220b2f66, inset 0 1px #ffffff42;
  color: #ffe47a;
  font-size: clamp(10px, 1.45vh, 15px);
  font-weight: 1000;
  letter-spacing: .055em;
  line-height: 1;
  text-align: left;
  text-shadow: 0 2px #17091f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  opacity: 0;
  transform: translateY(6px) scale(.94);
  transition: opacity .35s ease, transform .35s ease;
  z-index: 3;
}
.hard-banner.show { opacity: 1; transform: translateY(0) scale(1); }

#game-canvas { width: 100%; height: 75%; touch-action: none; }

.footer-bar {
  height: 14.5%;
  position: relative;
  display: block;
  padding: 0;
  background: none;
  filter: none;
  z-index: 5;
}
.footer-button {
  position: absolute;
  top: 48%;
  width: 19.5%;
  aspect-ratio: 1;
  translate: -50% -50%;
  background: center/contain no-repeat;
  transition: transform .08s;
  filter: drop-shadow(0 5px 5px #2a14086e);
}
.footer-button:active { filter: drop-shadow(0 1px 2px #2a140888) brightness(.92); }
.footer-button.control-denied { animation: controlDenied .34s ease-out; }
@keyframes controlDenied {
  0%, 100% { transform: translateX(0); filter: grayscale(0); }
  25% { transform: translateX(-7px); filter: grayscale(.7); }
  50% { transform: translateX(6px); filter: grayscale(.7); }
  75% { transform: translateX(-3px); filter: grayscale(.35); }
}
.undo-button { left: 36.5%; background-image: url("assets/undo-btn-v2.png"); }
.hint-button { left: 63.5%; background-image: url("assets/hint-btn-v2.png"); }
.count-badge {
  position: absolute;
  right: -1%;
  top: -1%;
  min-width: 34%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: radial-gradient(circle at 35% 30%, #ff6b55, #e03a28 55%, #c42a1a);
  font-weight: 900;
  font-size: clamp(11px, 1.5vh, 17px);
  box-shadow: 0 2px 0 #8a2218, 0 3px 6px #3a100888;
  border: 2px solid #fff6;
  line-height: 1;
}
.plus-badge {
  position: absolute;
  right: -2%;
  top: -2%;
  min-width: 28%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: #31b52d;
  font-weight: 900;
  font-size: clamp(11px, 1.5vh, 17px);
  box-shadow: 0 2px 0 #1a6020;
}

/* Level complete */
.level-complete-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2%;
  padding: 8% 6%;
  background: #222226ee;
}
.coin-display {
  position: absolute;
  top: 4%;
  right: 5%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: white;
  color: #222;
  font-weight: 900;
  font-size: clamp(16px, 2.2vh, 24px);
  box-shadow: 0 3px 8px #0004;
}
.coin-display img { width: clamp(22px, 3vh, 32px); height: auto; }
.complete-title { width: 88%; height: auto; }
.feature-unlock {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 2% 0 4%;
}
.feature-label {
  margin: 0;
  color: white;
  font-size: clamp(11px, 1.5vh, 15px);
  font-weight: 900;
  letter-spacing: .12em;
}
.feature-unlock img {
  width: clamp(72px, 10vh, 110px);
  height: auto;
  background: white;
  border: 3px solid #222;
  padding: 6px;
}
.feature-progress-track {
  width: min(60vw, 220px);
  height: clamp(10px, 1.4vh, 16px);
  overflow: hidden;
  border: 3px solid white;
  border-radius: 4px;
  background: #111;
}
.feature-progress-track i {
  display: block;
  width: 50%;
  height: 100%;
  background: #31d84a;
  transition: width .4s ease-out;
}
#feature-percent { color: white; font-weight: 900; font-size: clamp(14px, 2vh, 20px); }

.continue-reward-button {
  position: relative;
  width: 72%;
  background-image: url("assets/continue-btn.png");
}
.reward-cost {
  position: absolute;
  left: 50%;
  bottom: 14%;
  translate: -50%;
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-weight: 900;
  font-size: clamp(14px, 2vh, 20px);
  text-shadow: 0 2px 0 #1a4080;
  pointer-events: none;
}
.reward-cost img { width: clamp(18px, 2.5vh, 26px); }
.continue-reward-button.collecting { pointer-events: none; filter: brightness(.82) saturate(.8); transform: scale(.96); }
.coin-display.collecting { animation: coinCounterReady 1s ease-in-out; }
.flying-coin {
  --mid-x: 0px;
  --mid-y: -60px;
  --end-x: 0px;
  --end-y: -300px;
  position: absolute;
  z-index: 20;
  width: clamp(22px, 5.5vw, 34px);
  aspect-ratio: 1;
  pointer-events: none;
  filter: drop-shadow(0 4px 4px #0007);
  opacity: 0;
  animation: coinFly 520ms cubic-bezier(.18,.72,.28,1) forwards;
}
@keyframes coinFly {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.55) rotate(0deg); }
  12% { opacity: 1; }
  48% { opacity: 1; transform: translate(calc(-50% + var(--mid-x)), calc(-50% + var(--mid-y))) scale(1.15) rotate(190deg); }
  100% { opacity: .9; transform: translate(calc(-50% + var(--end-x)), calc(-50% + var(--end-y))) scale(.55) rotate(420deg); }
}
@keyframes coinCounterReady {
  0%, 100% { transform: scale(1); }
  55% { transform: scale(1.09); box-shadow: 0 0 0 8px #ffd34e26, 0 5px 14px #0005; }
}

/* Modal / result screen */
.modal { position: absolute; inset: 0; display: none; place-items: center; padding: 7%; background: #142b2bd9; backdrop-filter: blur(5px); z-index: 10; }
.modal.open { display: grid; animation: tutorialFadeIn .2s ease-out; }
.modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 520px);
  padding: clamp(28px, 5vh, 46px) clamp(18px, 6vw, 38px) clamp(24px, 5vh, 38px);
  text-align: center;
  border: 3px solid #e2b85f;
  border-radius: clamp(24px, 6vw, 36px);
  background: linear-gradient(155deg, #673217 0%, #3c1b0f 54%, #24100a 100%);
  box-shadow: 0 20px 45px #000a, inset 0 2px #f1c67b66, inset 0 -4px #16090588;
}
.modal-card::before { content: ""; position: absolute; inset: 8px; border: 1px solid #f7da9460; border-radius: inherit; pointer-events: none; }
.modal-icon { display: grid; place-items: center; width: clamp(68px, 18vw, 92px); aspect-ratio: 1; margin-top: -1%; border: 3px solid #f1d18a; border-radius: 50%; color: #fff1bd; background: linear-gradient(#159b91, #066c68); box-shadow: 0 6px 0 #1f1009, inset 0 3px #87e1cb, 0 9px 18px #16090477; font-size: clamp(30px, 7vh, 52px); font-weight: 900; }
.modal-level { margin-top: 16px; padding: 4px 14px; border-radius: 99px; color: #6b3418; background: #f5d68d; font-size: clamp(10px, 1.35vh, 13px); font-weight: 900; letter-spacing: .12em; }
.modal-card h2 { margin: 10px 0 4px; color: #ffd34f; font-size: clamp(30px, 5vh, 52px); line-height: 1; text-shadow: 0 3px #351406; }
.modal-card p { min-height: 2.5em; margin: 8px 0 clamp(22px, 4vh, 34px); color: #f6e9d6; font-size: clamp(13px, 1.8vh, 18px); font-weight: 800; }
.modal-actions { display: grid; grid-template-columns: minmax(0, .82fr) minmax(0, 1.18fr); gap: 12px; width: 100%; }
.modal-action-button { display: flex; align-items: center; justify-content: center; gap: 8px; min-width: 0; min-height: clamp(52px, 8vh, 68px); padding: 8px 10px; border: 2px solid #f1cf7c; border-radius: 16px; color: white; font-family: inherit; font-size: clamp(12px, 1.8vh, 18px); text-shadow: 0 2px #3b170a; box-shadow: 0 5px 0 #4d210f, inset 0 2px #ffffff66; }
.modal-action-button span { font-size: 1.45em; line-height: 1; }
.primary-modal-button { background: linear-gradient(#16a197, #087b75); }
.secondary-modal-button { background: linear-gradient(#d88a3b, #ad5d25); }
.modal-action-button:active { translate: 0 3px; box-shadow: 0 2px 0 #4d210f; }
.modal.time-up .modal-icon { background: linear-gradient(#ef9f35, #b75822); }
.modal.time-up .modal-card { animation: resultCardIn .38s cubic-bezier(.2,.85,.2,1.12); }
@keyframes resultCardIn { from { opacity: 0; transform: translateY(24px) scale(.94); } to { opacity: 1; transform: none; } }

/* Settings */
.settings-modal {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: none;
  place-items: center;
  padding: 8%;
  background: #241207c9;
  backdrop-filter: blur(5px);
}
.settings-modal.open { display: grid; animation: tutorialFadeIn .2s ease-out; }
.settings-card {
  position: relative;
  width: min(100%, 470px);
  padding: clamp(28px, 7vh, 52px) clamp(18px, 5vw, 32px) clamp(24px, 5vh, 38px);
  border: 3px solid #edc874;
  border-radius: clamp(22px, 6vw, 34px);
  background: linear-gradient(155deg, #6f361a, #3c1c10 52%, #26110b);
  box-shadow: 0 20px 45px #0009, inset 0 2px #f4c37b66;
  text-align: center;
}
.settings-card::before { content: ""; position: absolute; inset: 7px; border: 1px solid #f7d99342; border-radius: inherit; pointer-events: none; }
.settings-close {
  position: absolute;
  top: 12px; right: 14px;
  width: clamp(36px, 9vw, 46px); aspect-ratio: 1;
  border: 2px solid #f3d384;
  border-radius: 50%;
  color: #5b2b16;
  background: linear-gradient(#fff7d5, #dba75c);
  box-shadow: 0 3px 0 #6a3518;
  font-size: clamp(24px, 5vh, 36px);
  font-weight: 900;
  line-height: 1;
}
.settings-kicker { color: #e5b65f; font-size: clamp(9px, 1.2vh, 12px); font-weight: 900; letter-spacing: .18em; }
.settings-card h2 { margin: 4px 0 clamp(20px, 4vh, 32px); color: #fff1bd; font-size: clamp(28px, 5vh, 46px); text-shadow: 0 3px #1d0c07; }
.settings-row {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: clamp(70px, 11vh, 92px);
  margin-top: 14px;
  padding: 10px 15px;
  border: 2px solid #c99043;
  border-radius: 18px;
  color: #4d2817;
  background: linear-gradient(180deg, #fff4ce, #e5b86f);
  box-shadow: 0 5px 0 #6b3519, inset 0 2px #fff;
  text-align: left;
}
.settings-row:active { translate: 0 3px; box-shadow: 0 2px 0 #6b3519; }
.settings-row-icon { display: grid; place-items: center; width: clamp(42px, 11vw, 56px); aspect-ratio: 1; border-radius: 50%; color: #fff4c7; background: linear-gradient(#159b91, #076c67); box-shadow: inset 0 2px #8ce6d1, 0 3px 0 #50301d; font-size: clamp(22px, 4vh, 32px); font-weight: 900; }
.settings-row > span:nth-child(2) { display: flex; flex-direction: column; gap: 5px; }
.settings-row strong { font-size: clamp(15px, 2.2vh, 21px); }
.settings-row small { color: #79513a; font-size: clamp(10px, 1.4vh, 13px); font-weight: 800; }
.settings-row > i:not(.sound-switch) { font-size: clamp(30px, 5vh, 42px); font-style: normal; }
.sound-switch { position: relative; width: clamp(48px, 13vw, 64px); height: clamp(27px, 6.5vw, 34px); border-radius: 99px; background: #159b78; box-shadow: inset 0 2px 4px #073d34aa; transition: background .2s; }
.sound-switch b { position: absolute; top: 4px; right: 4px; height: calc(100% - 8px); aspect-ratio: 1; border-radius: 50%; background: white; box-shadow: 0 2px 4px #32150777; transition: translate .2s; }
.settings-row[aria-pressed="false"] .sound-switch { background: #8f8177; }
.settings-row[aria-pressed="false"] .sound-switch b { left: 4px; right: auto; }

/* Tutorial */
.game-tutorial {
  --tutorial-x: 50%;
  --tutorial-y: 42%;
  position: absolute;
  inset: 0;
  z-index: 9;
  display: none;
  pointer-events: none;
  opacity: 0;
}
.game-tutorial.show { display: block; animation: tutorialFadeIn .35s ease-out forwards; }
.game-tutorial.closing { opacity: 0; transition: opacity .2s ease-out; }
.tutorial-shade {
  position: absolute;
  inset: 0;
  background: #1b0e08aa;
  -webkit-mask: radial-gradient(circle 54px at var(--tutorial-x) var(--tutorial-y), transparent 0 55%, #000 76%);
  mask: radial-gradient(circle 54px at var(--tutorial-x) var(--tutorial-y), transparent 0 55%, #000 76%);
}
.tutorial-bubble {
  position: absolute;
  left: var(--tutorial-x);
  top: calc(var(--tutorial-y) - 92px);
  translate: -50% -100%;
  width: max-content;
  max-width: 78%;
  padding: 14px 24px 17px;
  border-radius: 14px;
  color: #087cf0;
  background: white;
  box-shadow: 0 5px 0 #c9c2b9, 0 10px 20px #35170a66;
  font-size: clamp(17px, 2.4vh, 24px);
  font-weight: 900;
  text-align: center;
}
.tutorial-bubble::after {
  content: "";
  position: absolute;
  left: 50%; bottom: -13px;
  translate: -50%;
  border: 14px solid transparent;
  border-top-color: white;
  border-bottom: 0;
}
.tutorial-hand {
  position: absolute;
  left: calc(var(--tutorial-x) + 13px);
  top: calc(var(--tutorial-y) + 24px);
  width: clamp(58px, 9vh, 86px);
  aspect-ratio: 2 / 3;
  background: url("assets/tutorial-hand.png") center/contain no-repeat;
  animation: tutorialTap 1s ease-in-out infinite;
  filter: drop-shadow(0 4px 2px #35170a88);
}
.tutorial-instruction {
  position: absolute;
  left: 10%; right: 10%; bottom: 16%;
  margin: 0;
  color: white;
  font-size: clamp(16px, 2.2vh, 23px);
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 3px 0 #3d2113, 0 0 7px #201006;
}
@keyframes drillPulse { 0%,100% { scale: 1; } 50% { scale: 1.06; } }
@keyframes tutorialFadeIn { to { opacity: 1; } }
@keyframes tutorialTap { 0%,100% { translate: 0 8px; scale: 1; } 55% { translate: 0 0; scale: .92; } }

@media (orientation: landscape) and (max-height: 600px) {
  #game {
    width: min(calc(100dvh * var(--game-ar-w) / var(--game-ar-h)), 100vw);
    height: min(100dvh, calc(100vw * var(--game-ar-h) / var(--game-ar-w)));
  }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
