html,
body {
  margin: 0;
  height: 100%;
  box-sizing: border-box;
  overflow: hidden;
  background: #0b171b;
}

/* Center the canvas, keep it clear of an iPhone notch, and stop the page
   from scrolling, zooming, or selecting text while you play. */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  container-type: size; /* lets the canvas size itself to this box */
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, sans-serif;
}

/*
  The canvas always draws at 1280x720 inside (see config.js).
  Here we only choose how big it looks: as large as fits, always 16:9,
  with dark bars on the leftover sides.
*/
#game {
  display: block;
  width: min(100vw, calc(100vh * 16 / 9)); /* older browsers */
  width: min(100cqw, calc(100cqh * 16 / 9));
  aspect-ratio: 16 / 9;
}

/* --- Touch joystick --------------------------------------------------- */

#touch-area {
  position: fixed;
  inset: 0;
  touch-action: none;
}

/* The ring is 120px wide = 2 x CONFIG.TOUCH.STICK_RADIUS. */
#stick-base {
  position: fixed;
  width: 120px;
  height: 120px;
  box-sizing: border-box;
  margin: -60px 0 0 -60px; /* left/top set in touch.js are the center */
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

#stick-thumb {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
}

/* --- Sound button ---------------------------------------------------- */

#sound-button {
  position: fixed;
  left: 6px; /* moved onto the game's bottom-left corner by sound.js */
  bottom: 6px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  font-size: 18px;
  line-height: 36px;
  touch-action: manipulation;
}

/* While the results screen is showing, touches go to the Restart button only. */
.game-over #touch-area {
  pointer-events: none;
}

/* --- Results screen (sunrise or Game Over) ---------------------------- */

#results {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.6vh, 10px);
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
  color: #ffffff;
  text-align: center;
}

#results[hidden] {
  display: none;
}

#results-title {
  margin: 0;
  max-width: 100%;
  text-wrap: balance;
  font-size: clamp(24px, 8vh, 54px);
  font-weight: bold;
  line-height: 1;
}

.lost #results-title {
  color: #ff4d5e;
  text-shadow: 0 0 16px rgba(255, 77, 94, 0.6);
}

.won #results-title {
  color: #ffd34d;
  text-shadow: 0 2px 0 #7a3b14, 0 0 18px rgba(90, 40, 10, 0.8);
}

#results-subtitle {
  margin: 0;
  font-size: clamp(15px, 4.5vh, 22px);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.7);
}

/* Which night and difficulty, so a screenshot of the results says it. */
#results-tag {
  margin: 0;
  font-size: clamp(12px, 3.4vh, 15px);
  font-weight: bold;
  letter-spacing: 0.06em;
  color: #ffd34d;
}

#results-stats {
  display: flex;
  gap: clamp(8px, 2vw, 20px);
}

.result-stat {
  display: flex;
  flex-direction: column;
  min-width: 96px;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(8, 18, 22, 0.7);
}

.result-value {
  font-size: clamp(18px, 5.5vh, 28px);
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.result-label {
  font-size: 12px;
  color: #bcd6d4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#results-recap {
  margin: 0;
  max-width: 34em;
  font-size: clamp(14px, 4vh, 18px);
  font-style: italic;
  color: #ffffff;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

#results-buttons {
  display: flex;
  gap: 12px;
}

#next-night-button {
  min-width: 160px;
  min-height: 48px;
  padding: 10px 24px;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: #1f7a4c;
  color: #ffffff;
  font: bold 20px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

#next-night-button[hidden] {
  display: none;
}

#results-nights {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
}

/* Sideways phones: the night buttons are smaller, and the "coming soon"
   nights are left out, so the row fits (Build m30.1). */
@media (max-height: 420px) {
  #results-nights .night-chip.soon,
  #title-nights .night-chip.soon {
    display: none;
  }
  #results-nights .night-chip {
    min-height: 28px;
    padding: 3px 9px;
    font-size: 13px;
  }
}

.night-chip {
  white-space: nowrap; /* "Night 2 ✓" stays on one line */
  min-height: 32px;
  padding: 4px 12px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 16px;
  background: rgba(8, 18, 22, 0.7);
  color: #ffffff;
  font: bold 14px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.night-chip.current {
  border: 2px solid #ffd34d;
}

.night-chip:disabled {
  color: #8fa5a6;
  cursor: default;
}

#restart-button {
  min-width: 160px;
  min-height: 48px;
  padding: 10px 28px;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: #c9302c;
  color: #ffffff;
  font: bold 20px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

#restart-button:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

#results-hint {
  margin: 0;
  font-size: 13px;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#results-best {
  margin: 0;
  font-size: 14px;
  font-weight: bold;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

#results-best.new-best {
  color: #ffd34d;
}

#results-chapter {
  margin: 0;
  max-width: 34em;
  font-size: clamp(13px, 3.6vh, 16px);
  color: #ffe9a8;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

#results-chapter[hidden] {
  display: none;
}

/* The souvenir counter at the end of a run: a little stand with a striped
   awning, and two big buttons (the gift shop, and back to Mellow Valley).
   Play again stays the main button above it. */
#souvenir {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: min(560px, 100%);
  box-sizing: border-box;
  padding: 18px 14px 12px;
  border: 2px solid #7a4b2a;
  border-radius: 12px;
  background: linear-gradient(#3b2416, #24160d);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
}

#souvenir::before { /* the awning */
  content: "";
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  height: 10px;
  border-radius: 12px 12px 0 0;
  background: repeating-linear-gradient(90deg, #d6333a 0 18px, #f7efe2 18px 36px);
}

#souvenir[hidden] {
  display: none;
}

#souvenir-kicker {
  margin: 0;
  font-size: 12px;
  font-weight: bold;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #ffd34d;
}

#souvenir-line {
  margin: 0;
  font-size: clamp(13px, 3.6vh, 16px);
  color: #ffe9c8;
}

#souvenir-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  width: 100%;
}

.souvenir-button {
  flex: 1 1 200px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 8px 14px;
  box-sizing: border-box;
  border: 2px solid #ffd34d;
  border-radius: 10px;
  background: #13292d;
  color: #ffffff;
  font: bold 17px system-ui, -apple-system, sans-serif;
  text-align: center;
  text-decoration: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(255, 211, 77, 0.3);
}

#gift-shop-link {
  background: #7a3b14;
}

.souvenir-button:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

/* The results screen can scroll if a small screen can't fit it all, and
   sideways phones leave out the quote and the hint line to make room. */
#results {
  overflow-y: auto;
  touch-action: pan-y;
}

@media (max-height: 420px) {
  #results {
    justify-content: flex-start;
    gap: 3px;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  #results-recap,
  #results-hint {
    display: none;
  }
  #results-title {
    font-size: clamp(20px, 7vh, 30px);
  }
  #results-subtitle {
    font-size: 14px;
  }
  .result-stat {
    min-width: 0;
    padding: 2px 10px;
  }
  .result-value {
    font-size: 18px;
  }
  .result-label {
    font-size: 10px;
    white-space: nowrap;
  }
  #results-nights .night-chip {
    min-height: 26px;
  }
  #souvenir {
    padding: 14px 10px 8px;
    gap: 4px;
  }
  #souvenir-line {
    display: none;
  }
  .souvenir-button {
    min-height: 46px;
    font-size: 15px;
  }
}

@media (max-height: 360px) {
  #results-subtitle,
  #results-best {
    display: none; /* the title, stats and choices matter most here */
  }
  #results-tag {
    font-size: 11px;
  }
  #next-night-button,
  #restart-button {
    min-height: 44px;
    padding: 4px 18px;
    font-size: 17px;
  }
  #souvenir {
    padding-top: 12px;
  }
  .souvenir-button {
    min-height: 44px;
    font-size: 14px;
  }
}

/* "Get the shirt" link (only shown once CONFIG.SHOP.URL is set). */
.shop-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 10px 20px;
  box-sizing: border-box;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: #24212b;
  color: #ffffff;
  font: bold 18px system-ui, -apple-system, sans-serif;
  text-decoration: none;
  touch-action: manipulation;
}

.shop-button[hidden] {
  display: none;
}

/* --- Title screen ------------------------------------------------------ */

.title-screen #touch-area {
  pointer-events: none;
}

#title {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1.8vh, 12px);
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 18, 22, 0.78);
  color: #ffffff;
  text-align: center;
}

/* The title screen's language buttons sit in the top-right corner, out of
   the way of everything else. */
#title-langs {
  position: absolute;
  top: max(8px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
}

#title[hidden] {
  display: none;
}

#title-kicker {
  margin: 0;
  font-size: clamp(13px, 3.6vh, 18px);
  font-weight: bold;
  letter-spacing: 0.3em;
  color: #ff4d5e;
  text-shadow: 0 0 10px rgba(255, 77, 94, 0.7);
}

#title-name {
  margin: 0;
  font-size: clamp(26px, 9vh, 56px);
  font-weight: bold;
  line-height: 1;
  color: #ffd34d;
  text-shadow: 0 2px 0 #7a3b14, 0 0 18px rgba(90, 40, 10, 0.8);
}

#title-tagline {
  margin: 0;
  font-size: clamp(14px, 4.2vh, 20px);
  font-style: italic;
}

#title-howto {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#title-howto li {
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  font-size: clamp(12px, 3.4vh, 15px);
}

#title-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

#play-button {
  min-width: 170px;
  min-height: 48px;
  padding: 10px 28px;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: #1f7a4c;
  color: #ffffff;
  font: bold 22px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

.scores-button,
#scores-close {
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  background: rgba(8, 18, 22, 0.7);
  color: #ffffff;
  font: bold 18px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

#title-nights {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 8px;
}

/* Decaf / Regular / Double Shot (difficulty.js): the chosen one is lit. */
#title-difficulty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.difficulty-label {
  font-size: 13px;
  font-weight: bold;
  color: #bcd6d4;
}

#title-difficulty .night-chip.current {
  background: #ffd34d;
  color: #1a1206;
}

#title-footer {
  margin: 0;
  font-size: 12px;
  color: #bcd6d4;
}

/* --- Scoreboard ---------------------------------------------------------- */

#scores {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center; /* top-aligned (and scrollable) when it doesn't fit */
  overflow-y: auto;
  touch-action: pan-y;
  gap: clamp(6px, 2vh, 14px);
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 18, 22, 0.92);
  color: #ffffff;
  text-align: center;
}

#scores[hidden] {
  display: none;
}

#scores-title {
  margin: 0;
  font-size: clamp(22px, 7vh, 36px);
  font-weight: bold;
  color: #ffd34d;
}

#scores-close {
  position: sticky; /* stays reachable while the list scrolls */
  bottom: 4px;
}

#scores-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.scores-night {
  min-width: 200px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  text-align: left;
}

.scores-heading {
  margin: 0 0 4px;
  font-weight: bold;
  color: #ffd34d;
}

.scores-empty {
  margin: 0;
  color: #8fa5a6;
  font-size: 13px;
}

.scores-night ol {
  margin: 0;
  padding-left: 20px;
  font-size: clamp(11px, 3.2vh, 14px);
  line-height: 1.4;
}

/* --- Pause screen ------------------------------------------------------ */

.paused-screen #touch-area {
  pointer-events: none;
}

#paused {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 2vh, 12px);
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 18, 22, 0.8);
  color: #ffffff;
  text-align: center;
}

#paused[hidden] {
  display: none;
}

#paused-title {
  margin: 0;
  font-size: clamp(28px, 9vh, 56px);
  font-weight: bold;
  letter-spacing: 0.06em;
  color: #ffd34d;
}

#paused-subtitle,
#paused-hint {
  margin: 0;
  font-size: clamp(14px, 4vh, 18px);
  color: #bcd6d4;
}

#paused-buttons,
#about-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  position: sticky; /* stays on screen while the card scrolls */
  bottom: 0;
  padding: 6px 0 2px;
  background: linear-gradient(transparent, rgba(8, 18, 22, 0.96) 35%);
}

#quit-button,
#reset-button {
  min-height: 48px;
  padding: 10px 20px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  background: rgba(8, 18, 22, 0.7);
  color: #ffffff;
  font: bold 18px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

/* The pause button sits beside the sound button, and only during a run. */
#pause-button {
  position: fixed;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #ffffff;
  font-size: 16px;
  line-height: 36px;
  touch-action: manipulation;
}

/* Throw buttons: frying pan and brownies, bottom-right of the game, during
   a run, on every device. The badge shows how many are carried; with keys
   or a controller, a label shows the key (kitchen.js). */
.throw-button {
  display: block;
  position: fixed;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 3px solid #ffd34d;
  border-radius: 50%;
  background: rgba(11, 17, 20, 0.55) center / 48px 48px no-repeat;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.throw-button::after {
  content: attr(data-count);
  position: absolute;
  right: -4px;
  bottom: -4px;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  background: #ffd34d;
  color: #0b1114;
  font: bold 14px/22px sans-serif;
}

.throw-button.empty {
  opacity: 0.4;
  border-color: #9aa1a8;
}

.throw-button::before {
  content: attr(data-key);
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  padding: 0 5px;
  border-radius: 6px;
  background: rgba(11, 17, 20, 0.85);
  color: #ffd34d;
  font: bold 11px/16px sans-serif;
  white-space: nowrap;
}

.throw-button[data-key=""]::before {
  display: none;
}

.throw-button {
  cursor: pointer;
}

.demo-mode .throw-button,
.title-screen .throw-button,
.game-over .throw-button,
.paused-screen .throw-button,
.leveling .throw-button {
  display: none;
}

/* The demo keeps the picture clean for recording. */
.demo-mode #pause-button,
.demo-mode #sound-button {
  display: none;
}

.title-screen #pause-button,
.game-over #pause-button,
.paused-screen #pause-button,
.leveling #pause-button {
  display: none;
}

/* --- How to play --------------------------------------------------------- */

#howto {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px max(12px, env(safe-area-inset-right, 0px)) 10px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 18, 22, 0.88);
  color: #ffffff;
}

#howto[hidden] {
  display: none;
}

#howto-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(4px, 1.4vh, 10px);
  width: min(820px, 100%);
  max-height: 100%;
  overflow-y: auto;
  touch-action: pan-y; /* the page blocks touch scrolling; this card may scroll */
  box-sizing: border-box;
  padding: clamp(8px, 2.5vh, 20px) clamp(12px, 3vw, 26px);
  border: 2px solid #3d6f74;
  border-radius: 16px;
  background: #13292d;
  text-align: center;
}

#howto-card p {
  margin: 0;
}

/* The language menu (a globe and a dropdown), on the How to play card and
   the title screen (renderLangButtons in i18n.js). */
.lang-row {
  display: flex;
  justify-content: center;
}

.lang-picker {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 4px 0 10px;
  border: 1.5px solid #ffd34d;
  border-radius: 999px;
  background: rgba(19, 41, 45, 0.92);
  color: #ffffff;
  font: bold 14px system-ui, -apple-system, sans-serif;
  cursor: pointer;
}

.lang-picker select {
  min-height: 30px;
  padding: 0 6px;
  border: none;
  background: transparent;
  color: #ffffff;
  font: inherit;
  cursor: pointer;
}

.lang-picker select option {
  color: #13292d;
  background: #ffffff;
}

.lang-picker:focus-within {
  outline: 3px solid #ffd166;
  outline-offset: 2px;
}

#howto-kicker {
  font-size: 12px;
  letter-spacing: 0.14em;
  color: #ff6b6b;
}

#howto-title {
  font-size: clamp(20px, 5.5vh, 30px);
  font-weight: bold;
  color: #ffd34d;
}

#howto-goal {
  font-size: clamp(12px, 3.4vh, 16px);
  line-height: 1.3;
  color: #d9ecea;
  max-width: 52ch;
}

/* Controls and tips side by side when there's room, stacked when not. */
#howto-columns {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(4px, 1.4vh, 10px) 22px;
  width: 100%;
}

#howto-controls,
#howto-tips {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(2px, 0.9vh, 6px) 12px;
  margin: 0;
  flex: 1 1 260px;
  max-width: 350px;
  align-content: start;
  text-align: left;
  font-size: clamp(12px, 3.3vh, 15px);
  line-height: 1.25;
}

#howto-controls dt,
#howto-tips dt {
  font-weight: bold;
  color: #ffd34d;
  text-align: right;
}

#howto-controls dd,
#howto-tips dd {
  margin: 0;
  color: #f2eee6;
}

#howto-go {
  min-width: 170px;
  min-height: 44px;
  padding: 8px 28px;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: #1f7a4c;
  color: #ffffff;
  font: bold 20px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

/* "Let's go", and the optional hands-on practice night next to it. */
#howto-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

#howto-practice {
  min-height: 44px;
  padding: 8px 18px;
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 10px;
  background: rgba(8, 18, 22, 0.7);
  color: #ffffff;
  font: bold 16px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

#howto-other {
  font-size: 12px;
  color: #9fbcb9;
}

/* Short screens (a phone held sideways): drop the small heading above the
   title to make room for the language buttons. */
@media (max-height: 420px) {
  #howto-kicker {
    display: none;
  }
}

/* Very short and narrow (an iPhone SE on its side): keep the two lists side
   by side, a little smaller, so the buttons stay on screen. */
@media (max-height: 360px) {
  #howto-card {
    padding: 6px 10px;
    gap: 4px;
  }
  #howto-columns {
    flex-wrap: nowrap;
    gap: 4px 12px;
  }
  #howto-controls,
  #howto-tips {
    flex: 1 1 0;
    gap: 0 8px;
    font-size: 10.5px;
    line-height: 1.15;
  }
  #howto-goal {
    font-size: 11px;
    line-height: 1.2;
  }
  #howto-title {
    font-size: 19px;
  }
  .lang-picker {
    min-height: 28px;
  }
  #howto-other {
    display: none; /* the small "also works with..." line */
  }
  #howto-go,
  #howto-practice {
    min-height: 38px;
    padding: 4px 16px;
    font-size: 16px;
  }
}

/* --- About page ------------------------------------------------------- */

#about {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 18, 22, 0.92);
  color: #ffffff;
}

#about[hidden] {
  display: none;
}

#about-card {
  max-width: 44em;
  max-height: 100%;
  overflow-y: auto;
  touch-action: pan-y; /* the page blocks touch scrolling; this card may scroll */
  font-size: clamp(11px, 3vh, 15px);
  line-height: 1.3;
  text-align: center;
}

#about-card p {
  margin: 0 0 4px;
}

#about-title {
  font-size: clamp(16px, 5vh, 28px);
  font-weight: bold;
  color: #ffd34d;
}

.about-heading {
  margin-top: 6px !important;
  font-weight: bold;
  color: #ffd34d;
}

#about-card a {
  color: #8fd8ff;
}

#about-legal,
#about-build {
  font-size: 11px;
  color: #bcd6d4;
}

#about-buttons button {
  min-height: 40px;
  font-size: 16px;
}

#resume-button {
  min-width: 160px;
  min-height: 48px;
  padding: 10px 28px;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: #1d7a4a;
  color: #ffffff;
  font: bold 20px system-ui, -apple-system, sans-serif;
  cursor: pointer;
  touch-action: manipulation;
}

#resume-button:focus-visible {
  outline: 3px solid #ffd166;
  outline-offset: 3px;
}

/* --- Level-up cards ---------------------------------------------------- */

/* While choosing, touches go to the cards only. */
.leveling #touch-area {
  pointer-events: none;
}

#levelup {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px));
  background: rgba(8, 18, 22, 0.72);
  color: #ffffff;
}

#levelup[hidden] {
  display: none;
}

#levelup-title {
  margin: 0;
  font-size: clamp(20px, 5vh, 34px);
  font-weight: bold;
  color: #ffd34d;
  text-shadow: 0 0 12px rgba(255, 211, 77, 0.6);
}

#levelup-cards {
  display: flex;
  gap: 12px;
  width: min(100%, 720px);
}

.upgrade-card {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 10px;
  border: 2px solid #ffffff;
  border-radius: 10px;
  background: #1d3a40;
  color: #ffffff;
  font: inherit;
  text-align: left;
  cursor: pointer;
  touch-action: manipulation;
}

.upgrade-card:focus-visible,
.upgrade-card:hover,
.upgrade-card.focused {
  border-color: #ffd34d;
}

/* The card a controller (or the arrow keys) would pick. */
.upgrade-card.focused {
  box-shadow: 0 0 0 3px #ffd34d;
}

/* Cards can't be picked for a moment after they appear. */
.waiting .upgrade-card {
  opacity: 0.55;
}

.card-key {
  font-size: 12px;
  color: #bcd6d4;
}

.card-name {
  font-size: clamp(15px, 4.2vh, 20px);
  font-weight: bold;
  color: #ffd34d;
}

.card-rank {
  font-size: 12px;
  color: #bcd6d4;
}

.card-line {
  font-size: clamp(13px, 3.6vh, 16px);
  line-height: 1.25;
}

#levelup-hint {
  margin: 0;
  font-size: 13px;
  color: #bcd6d4;
}

/* --- Portrait warning (doesn't block play) ---------------------------- */

/* "Controller ready", for a moment when one is plugged in. */
#pad-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  margin: 0;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(11, 17, 20, 0.85);
  color: #ffffff;
  font: bold 16px sans-serif;
  pointer-events: none;
}

#pad-toast[hidden] {
  display: none;
}

#rotate-hint {
  display: none;
}

@media (orientation: portrait) and (pointer: coarse) {
  #rotate-hint {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(24px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    text-align: center;
    color: #bcd6d4;
    font-size: 15px;
    pointer-events: none;
  }
}

/* Very short screens (an iPhone SE on its side): drop the title's tagline
   and quick tips (the How to play card covers them) and tighten up, so everything
   fits under the language buttons in every language. */
@media (max-height: 360px) {
  #title-howto,
  #title-tagline {
    display: none;
  }
  #title {
    gap: 6px;
    padding-top: 44px;
    padding-bottom: 4px;
  }
  #title-name {
    font-size: 30px;
  }
  #title-buttons {
    gap: 6px;
  }
  #title-nights .night-chip.soon {
    display: none; /* "coming soon" nights don't fit on a very short screen */
  }
  /* Eight nights (Build m32) have to fit one row on a 568 px-wide phone. */
  #title-nights .night-chip {
    min-height: 26px;
    padding: 2px 3px;
    font-size: 11px;
  }
  #title-nights {
    gap: 4px 2px;
  }
  #title-buttons #play-button,
  #title-buttons .scores-button {
    min-height: 42px;
    padding: 6px 14px;
  }
}

/* Tester code (Build m32.4): a small field at the bottom of About, and a skip
   button on the pause screen that only shows once the code has been entered. */
#tester-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 10px 0 4px;
}
#tester-code {
  width: 150px;
  min-height: 34px;
  padding: 4px 10px;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: rgba(8, 18, 22, 0.6);
  color: #ffffff;
  font: 14px system-ui, -apple-system, sans-serif;
}
#tester-go,
#skip-button {
  min-height: 34px;
  padding: 4px 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: rgba(8, 18, 22, 0.7);
  color: #ffffff;
  font: bold 14px system-ui, -apple-system, sans-serif;
  cursor: pointer;
}
#tester-msg {
  margin: 4px 0 0;
  font-size: 13px;
  color: #ffd34d;
  text-align: center;
}
