/* Nunito (SIL OFL 1.1, see vendor/nunito/OFL.txt) */
@font-face { font-family: 'Nunito'; font-style: normal; font-weight: 600 900; font-display: swap; src: url(vendor/nunito/nunito-latin.woff2) format('woff2'); }
/* Every word on the screen is at least 15 px (第八批 point 1), dark navy on cream. */
:root {
  --cream: rgba(255, 252, 245, 0.94);
  --frost: #8cbfe0;
  --frost-dark: #5f97c0;
  --ink: #1f3d5c;
  --ink-soft: #3f6283;
  --accent: #e2643f;
  --accent-dark: #b44a2c;
  --gold: #f2b53a;
  --shadow: 0 3px 0 rgba(40, 80, 120, 0.22), 0 10px 24px rgba(20, 50, 80, 0.16);
  --radius: 16px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #cfe6f2; color: var(--ink);
  font-family: 'Nunito', system-ui, -apple-system, 'PingFang TC', sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { -webkit-tap-highlight-color: transparent; }
button:focus { outline: none; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
b { font-weight: 900; }

.card {
  background: var(--cream);
  border: 2px solid var(--frost);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- HUD: score | daylight + bays | freezes ---------- */
#hud {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  pointer-events: none;
  padding-right: 164px; /* room for the corner buttons */
}
#hud > .card { padding: 6px 14px; display: flex; align-items: center; gap: 10px; min-height: 48px; }
.stat { display: flex; align-items: center; gap: 7px; font-size: 24px; }
.stat svg { width: 28px; height: 28px; flex: none; }
#hud-score { font-variant-numeric: tabular-nums; min-width: 40px; }
.hud-mid { flex-direction: column; gap: 3px !important; padding-top: 5px !important; padding-bottom: 6px !important; }
.clock-row { display: flex; align-items: center; gap: 7px; font-size: 20px; font-variant-numeric: tabular-nums; }
.clock-row b { min-width: 46px; }
.clock-row svg { width: 24px; height: 24px; flex: none; }
.bar { position: relative; width: 120px; height: 10px; border-radius: 999px; background: #dcebf5; border: 1.5px solid var(--frost-dark); overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; width: 100%; border-radius: 999px; background: linear-gradient(90deg, #f08a3c, #ffd36a); transition: width 0.25s linear; }
.hud-mid.late .clock-row b { color: var(--accent-dark); animation: pop 1s ease-out infinite; }
.hud-mid.late .bar i { background: var(--accent); }
/* the eight bays: done ones filled, this one ringed; and "Bay 3 of 8" in words */
.bays { display: flex; align-items: center; gap: 5px; font-size: 15px; font-weight: 900; color: var(--ink-soft); }
.bays i { width: 11px; height: 11px; border-radius: 50%; background: #dcebf5; border: 1.5px solid var(--frost-dark); }
.bays i.done { background: var(--frost-dark); }
.bays i.now { background: #ffd36a; border-color: #c98d1c; box-shadow: 0 0 0 2px rgba(242, 181, 58, 0.45); }
.bays span { margin-left: 4px; }
.hud-right b { min-width: 18px; font-variant-numeric: tabular-nums; }
.hud-right.low b { color: var(--accent-dark); }
.hud-right.pop, .stat.pop { animation: pop 0.4s ease-out; }
.hud-right.shake { animation: shiver 0.3s linear 2; }
@keyframes pop { 40% { transform: scale(1.25); } }
@keyframes shiver { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.corner {
  position: fixed; top: max(12px, env(safe-area-inset-top)); right: 16px;
  display: flex; gap: 8px;
  /* over the title, pause and end cards (10), so music and sound can be switched there too; the leaderboard (20) covers them */
  z-index: 11;
}
.icon-btn {
  width: 48px; height: 48px; display: grid; place-items: center;
  background: var(--cream); border: 2px solid var(--frost); border-radius: 12px;
  box-shadow: 0 3px 0 rgba(40, 80, 120, 0.25); color: var(--ink); padding: 0;
}
.icon-btn:hover { background: #fff; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(40, 80, 120, 0.25); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn .off { display: none; }
.icon-btn[aria-pressed="false"] { color: var(--ink-soft); opacity: 0.85; }
.icon-btn[aria-pressed="false"] .off { display: inline; }

/* ---------- the message strip: under the bay, one line at a time ---------- */
.strip {
  position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 24px);
  padding: 6px 18px 6px 8px; border-radius: 22px; background: rgba(255, 252, 245, 0.96); border: 2px solid var(--frost); box-shadow: var(--shadow);
  font-size: 17px; font-weight: 800; line-height: 1.25; color: var(--ink); pointer-events: none; z-index: 4;
  animation: stripIn 0.35s cubic-bezier(.2, 1.4, .5, 1);
}
.strip.news { border-color: #e9b24a; }
.strip.news #strip-text { color: #8a4a12; }
.strip.bad #strip-text { color: var(--accent-dark); }
.strip.plain { padding-left: 18px; }
.strip.plain .mom-face { display: none; }
@keyframes stripIn { from { opacity: 0; transform: translate(-50%, 10px) scale(0.95); } }
/* Mom's face beside her words */
.mom-face { width: 34px; height: 34px; flex: none; border-radius: 50%; background: #e8f3fa center / 30px no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cellipse cx='16' cy='19' rx='11' ry='12' fill='%23233041'/%3E%3Cellipse cx='16' cy='21' rx='7.5' ry='8.5' fill='%23fff8ec'/%3E%3Cpath d='M8 13c2-3 5-3 8-1 3-2 6-2 8 1-1 3-4 4-8 4s-7-1-8-4z' fill='%23fff8ec'/%3E%3Ccircle cx='12.5' cy='14' r='1.6' fill='%23233041'/%3E%3Ccircle cx='19.5' cy='14' r='1.6' fill='%23233041'/%3E%3Cpath d='M14 17.2l2 2.6 2-2.6z' fill='%23f2a23a'/%3E%3Cpath d='M6 9c3-6 17-6 20 0-6-2-14-2-20 0z' fill='%23d94a5a'/%3E%3Ccircle cx='16' cy='4.8' r='2.4' fill='%23fff8ec'/%3E%3C/svg%3E"); border: 1.5px solid var(--frost); }

/* ---------- screens ---------- */
.overlay {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(230, 245, 255, 0.12), rgba(20, 50, 80, 0.3));
  z-index: 10; animation: fade 0.3s ease-out; overscroll-behavior: contain;
}
@keyframes fade { from { opacity: 0; } }
.panel {
  width: min(480px, 100%); padding: 24px 28px 22px; text-align: center;
  max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  animation: rise 0.35s cubic-bezier(.2, 1.3, .5, 1);
}
.panel.small { width: min(340px, 100%); }
@keyframes rise { from { transform: translateY(16px) scale(0.97); } }
h1 { margin: 0 0 4px; font-size: 46px; font-weight: 900; letter-spacing: 0.5px; color: var(--ink); line-height: 1.1; }
h1::after { content: ''; display: block; width: 76px; height: 6px; margin: 8px auto 0; border-radius: 4px; background: repeating-linear-gradient(90deg, var(--frost-dark) 0 10px, #fff 10px 13px, #ffd36a 13px 23px, #fff 23px 26px); }
h2 { margin: 0 0 10px; font-size: 28px; font-weight: 900; }
.tag-line { margin: 10px 0 16px; color: var(--ink-soft); font-weight: 700; font-size: 17px; line-height: 1.35; }
.how { list-style: none; margin: 0 0 18px; padding: 0; text-align: left; display: grid; gap: 10px; font-weight: 700; font-size: 16px; line-height: 1.35; }
.how li { display: flex; align-items: center; gap: 12px; }
.ic { width: 36px; height: 36px; flex: none; background-size: contain; background-repeat: no-repeat; background-position: center; }
.ic-tap { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36'%3E%3Crect x='2' y='14' width='15' height='15' rx='3' fill='%2357a7d6'/%3E%3Cpath d='M4 21c2-1.5 4 1.5 6 0s4 1.5 6 0' stroke='%23bfe6ff' stroke-width='1.6' fill='none'/%3E%3Crect x='19' y='14' width='15' height='15' rx='3' fill='%23eef8ff' stroke='%238cbfe0' stroke-width='1.6'/%3E%3Cpath d='M26.5 16.5v10M22 19l9 5M22 24l9-5' stroke='%235f97c0' stroke-width='1.6' stroke-linecap='round'/%3E%3Cpath d='M15 18l4 0M17 16l2 2-2 2' stroke='%23e2643f' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3Cpath d='M8 3c2 0 3 1 3 3v6c0 1-1 2-2 2H7c-1 0-2-1-2-2V6c0-2 1-3 3-3z' fill='%23e35b4f'/%3E%3C/svg%3E"); }
.ic-chick { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36'%3E%3Cellipse cx='18' cy='31' rx='12' ry='3' fill='%23bcd8ea'/%3E%3Cellipse cx='18' cy='20' rx='9' ry='10.5' fill='%237d8b99'/%3E%3Cellipse cx='18' cy='22' rx='6' ry='7.5' fill='%23eef1f4'/%3E%3Ccircle cx='18' cy='11' r='7' fill='%23233041'/%3E%3Cellipse cx='18' cy='12.5' rx='5' ry='3.6' fill='%23fff8ec'/%3E%3Ccircle cx='15.8' cy='11.6' r='1.1' fill='%23233041'/%3E%3Ccircle cx='20.2' cy='11.6' r='1.1' fill='%23233041'/%3E%3Cpath d='M16.8 13.6h2.4L18 15.2z' fill='%23f2a23a'/%3E%3Cpath d='M11 17h14v3H11z' fill='%23e35b4f'/%3E%3C/svg%3E"); }
.ic-seal { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36'%3E%3Cellipse cx='18' cy='29' rx='15' ry='4' fill='%2357a7d6'/%3E%3Cpath d='M5 27c0-7 6-12 14-12 5 0 8-3 9-6 3 1 4 4 3 7-1 5-4 11-12 12z' fill='%23a3b1bd'/%3E%3Ccircle cx='27' cy='12' r='1.2' fill='%23233041'/%3E%3Cpath d='M30 14.5c1.5 0 3 .5 4 1' stroke='%23233041' stroke-width='.8'/%3E%3Cpath d='M29 4l1.6 1.6M33 6l-2 1' stroke='%23e2643f' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.big-btn {
  min-height: 50px; padding: 10px 32px; border: 0; border-radius: 14px;
  background: var(--accent); color: #fff; font-size: 20px; font-weight: 900;
  box-shadow: 0 4px 0 var(--accent-dark);
}
.big-btn:hover { filter: brightness(1.05); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent-dark); }
.big-btn.ghost { background: #fff; color: var(--ink); border: 2px solid var(--frost); box-shadow: 0 4px 0 var(--frost-dark); }
.best { margin: 14px 0 0; color: var(--ink-soft); font-weight: 800; font-size: 16px; min-height: 1em; }
.best:empty { display: none; }
.newbest { margin: -2px 0 8px; color: var(--accent-dark); font-weight: 900; font-size: 19px; animation: pop 0.6s ease-out; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.stats div { background: #fff; border: 1.5px solid #cfe3f0; border-radius: 12px; padding: 7px 8px; }
.stats dt { font-size: 15px; font-weight: 800; color: var(--ink-soft); }
.stats dd { margin: 1px 0 0; font-size: 25px; font-weight: 900; font-variant-numeric: tabular-nums; }
.ends { margin: 0 0 6px; font-weight: 800; font-size: 15px; color: var(--ink-soft); line-height: 1.35; }
.ends:empty { display: none; }
.score { margin: 4px 0 0; font-size: 19px; font-weight: 800; }
.score b { font-size: 32px; color: var(--accent-dark); margin-left: 6px; font-variant-numeric: tabular-nums; }
.col-btns { display: grid; gap: 10px; }
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.row-btns .big-btn { padding-left: 24px; padding-right: 24px; }

/* the end card sits beside the homecoming, not over it: on the left of a wide screen (Mom and the chicks are on the
   right), at the bottom of an upright phone (they are at the top) */
.overlay.side { justify-items: start; padding-left: max(24px, env(safe-area-inset-left)); background: linear-gradient(90deg, rgba(20, 50, 80, 0.32), rgba(20, 50, 80, 0.04) 60%); }
.overlay.side .panel { width: min(440px, 46vw); }

/* ---------- online leaderboard ---------- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.post { margin: 12px 0 0; padding: 12px 12px 10px; border-radius: 12px; background: rgba(255, 255, 255, 0.85); border: 1.5px dashed var(--frost-dark); }
.post-rank { margin: 0 0 8px; font-weight: 800; font-size: 16px; }
.post-form { display: flex; gap: 8px; justify-content: center; }
.post-form input {
  flex: 1; min-width: 0; max-width: 180px; min-height: 46px; padding: 6px 12px; border-radius: 12px;
  border: 2px solid var(--frost); background: #fff; color: var(--ink); font-family: inherit; font-weight: 800; font-size: 17px; line-height: 1.2; text-align: center;
}
.post-form input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.mid-btn {
  min-height: 46px; padding: 6px 18px; border: 0; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: #fff; font-family: inherit; font-weight: 900; font-size: 17px; line-height: 1; box-shadow: 0 3px 0 var(--accent-dark);
}
.mid-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--accent-dark); }
.mid-btn:disabled { opacity: 0.6; cursor: default; }
.post-msg { margin: 8px 0 0; min-height: 1.2em; font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.post-msg:empty { display: none; }
.post-msg.bad { color: var(--accent-dark); }
.overlay.top { z-index: 20; background: rgba(20, 50, 80, 0.45); }
/* solid, not see-through like the other cards: the end card is right behind it */
.board-panel { display: flex; flex-direction: column; padding-bottom: 20px; background: #fffcf5; }
.board-panel .big-btn { align-self: center; }
.board-panel h2 { margin: 0 0 8px; }
.board-state { margin: 0; min-height: 1.4em; color: var(--ink-soft); font-weight: 700; font-size: 16px; }
.board-state:empty { display: none; }
.board-list { list-style: none; margin: 6px 0 0; padding: 0; text-align: left; max-height: min(46dvh, 380px); overflow: auto; overscroll-behavior: contain; border-radius: 10px; }
.board-list:empty { display: none; }
.board-list li { display: grid; grid-template-columns: 38px 30px 1fr auto; gap: 8px; align-items: center; padding: 7px 12px; font-weight: 800; font-size: 16px; border-bottom: 1px dashed rgba(95, 151, 192, 0.4); }
.board-list li:last-child { border-bottom: 0; }
.board-list .rk { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.board-list .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .sc { font-variant-numeric: tabular-nums; }
.board-list li.me { background: rgba(242, 181, 58, 0.28); border-radius: 8px; }
.board-me { margin: 8px 0 0; padding: 7px 12px; border-radius: 8px; background: rgba(242, 181, 58, 0.28); font-weight: 800; font-size: 16px; }
.board-account { margin: 14px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.board-account small { font-size: 15px; }
/* Google's sign-in button, light theme, as its branding guide asks */
.g-btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px 0 12px; border-radius: 22px;
  background: #fff; color: #1f1f1f; border: 1px solid #747775; text-decoration: none; font: 500 15px/20px Roboto, Arial, sans-serif;
}
.g-btn:hover { background: #f6f8fa; }
.g-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.g-btn svg { width: 18px; height: 18px; flex: none; }
.link-btn { min-height: 44px; padding: 2px 8px; border: 0; background: none; cursor: pointer; color: var(--accent-dark); font-family: inherit; font-weight: 800; font-size: 15px; line-height: 1; text-decoration: underline; }
.plain-link { color: var(--ink-soft); font-weight: 800; }
.plain-link:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
/* the leaderboard's Privacy link: a 44 px tall target (inline padding: the text around it does not move) */
.board-account .plain-link { display: inline-block; line-height: 20px; padding: 12px 4px; margin: -12px -4px; }
.post-who { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.post-who[hidden] { display: none; }
.post-who .or { display: flex; align-items: center; gap: 10px; width: 100%; font-size: 15px; }
.post-who .or::before, .post-who .or::after { content: ''; flex: 1; border-top: 1.5px dashed var(--frost); }
.av { width: 30px; height: 30px; border-radius: 50%; border: 1.5px solid var(--frost); object-fit: cover; background: #fff; flex: none; display: block; }
.av.dflt { display: grid; place-items: center; }
.av.dflt svg { width: 22px; height: 22px; }
.who { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- the link to the other games: under the buttons of the title, pause and end cards ---------- */
.more-games { display: flex; width: max-content; max-width: 100%; align-items: center; justify-content: center; gap: 5px; min-height: 44px; margin: 2px auto -8px; padding: 0 14px; border-radius: 14px;
  color: var(--ink-soft); font-weight: 800; font-size: 15px; text-decoration: none; -webkit-tap-highlight-color: transparent; }
.more-games b { color: var(--ink); font-weight: 900; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--frost); }
.more-games svg { width: 16px; height: 16px; flex: none; transition: transform 0.15s; }
.more-games:hover { background: rgba(95, 151, 192, 0.14); color: var(--ink); }
.more-games:hover svg { transform: translateX(3px); }
.more-games:active { background: rgba(95, 151, 192, 0.24); }
.more-games:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.row-btns > .more-games { flex: 0 0 100%; margin: -6px 0 -10px; }
@media (prefers-reduced-motion: reduce) { .more-games svg { transition: none; } }

/* ---------- a phone held upright ---------- */
@media (max-width: 640px) {
  #hud { left: 8px; right: 8px; padding-right: 0; top: calc(max(10px, env(safe-area-inset-top)) + 56px); gap: 6px; }
  #hud > .card { padding: 4px 10px; min-height: 46px; gap: 6px; }
  .corner { right: 8px; top: max(10px, env(safe-area-inset-top)); }
  .stat { font-size: 21px; gap: 5px; } .stat svg { width: 24px; height: 24px; }
  .clock-row { font-size: 18px; gap: 5px; } .clock-row svg { width: 20px; height: 20px; } .clock-row b { min-width: 40px; }
  .bar { width: 64px; }
  .bays i { display: none; }
  .bays span { margin: 0; }
  h1 { font-size: 38px; }
  .panel { padding: 20px 18px 18px; }
  .tag-line { font-size: 16px; margin-bottom: 12px; }
  .how { gap: 8px; margin-bottom: 14px; }
  .ic { width: 32px; height: 32px; }
  .row-btns .big-btn { padding-left: 16px; padding-right: 16px; font-size: 19px; }
  .strip { font-size: 15px; padding: 5px 12px 5px 6px; gap: 8px; max-width: calc(100vw - 16px); bottom: max(8px, env(safe-area-inset-bottom)); }
  .mom-face { width: 30px; height: 30px; background-size: 26px; }
  /* the end card at the bottom; the homecoming at the top stays in view */
  .overlay.side { justify-items: stretch; align-items: end; padding: 12px 10px max(10px, env(safe-area-inset-bottom)); background: linear-gradient(0deg, rgba(20, 50, 80, 0.32), rgba(20, 50, 80, 0.02) 55%); }
  .overlay.side .panel { width: 100%; max-height: 64dvh; padding: 14px 14px 12px; }
  .over-card h2 { font-size: 24px; margin-bottom: 6px; }
  .over-card .stats { grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 6px; }
  .over-card .stats div { padding: 4px 3px; }
  .over-card .stats dt { font-size: 15px; line-height: 1.1; }
  .over-card .stats dd { font-size: 21px; }
  .over-card .score b { font-size: 28px; }
  .over-card .best { margin-top: 4px; }
  .over-card .post { margin-top: 8px; padding: 8px 10px; }
  .over-card .row-btns { margin-top: 10px; flex-wrap: nowrap; }
  .over-card .row-btns .big-btn { flex: 1; padding-left: 10px; padding-right: 10px; }
  #over .more-games { display: none; }
}

/* an upright phone while playing: one row at the top (score, daylight, freezes, pause) so the whole bay and Mom fit
   under it; music and sound are on the pause card (and the title and end cards) */
@media (max-width: 640px) and (min-height: 421px) {
  body[data-mode="play"] #btn-music, body[data-mode="play"] #btn-sfx, body[data-mode="ending"] #btn-music, body[data-mode="ending"] #btn-sfx { display: none; }
  body[data-mode="play"] #hud, body[data-mode="ending"] #hud { top: max(8px, env(safe-area-inset-top)); left: 6px; right: 6px; padding-right: 54px; gap: 4px; }
  body[data-mode="play"] #hud > .card, body[data-mode="ending"] #hud > .card { padding: 3px 7px; gap: 4px; }
  body[data-mode="play"] .corner, body[data-mode="ending"] .corner { top: max(8px, env(safe-area-inset-top)); right: 6px; }
  body[data-mode="play"] .stat, body[data-mode="ending"] .stat { font-size: 19px; gap: 4px; }
  body[data-mode="play"] .stat svg, body[data-mode="ending"] .stat svg { width: 20px; height: 20px; }
  body[data-mode="play"] .clock-row, body[data-mode="ending"] .clock-row { font-size: 17px; gap: 4px; }
  body[data-mode="play"] .clock-row svg, body[data-mode="ending"] .clock-row svg { width: 18px; height: 18px; }
  body[data-mode="play"] .bar, body[data-mode="ending"] .bar { width: 40px; }
}
/* a wide low window: the title card fits between the corner buttons on the right, so it may use the full height */
@media (max-height: 420px) and (min-width: 700px) {
  #title.overlay { padding-top: max(6px, env(safe-area-inset-top)); }
  #title .panel { max-height: calc(100dvh - 12px); }
}
/* a short upright phone (375 × 667): the end card tighter, so it fits without scrolling and the family stays in view */
@media (max-width: 640px) and (max-height: 740px) {
  .overlay.side .panel { max-height: 66dvh; padding: 10px 12px 10px; }
  .over-card h2 { font-size: 22px; margin-bottom: 2px; }
  .over-card .newbest { margin: 0 0 4px; }
  .over-card .stats { margin-bottom: 4px; }
  .over-card .stats div { padding: 2px 3px; }
  .over-card .stats dd { font-size: 19px; }
  .over-card #o-extra { display: none; }
  .over-card .score { margin-top: 0; }
  .over-card .score b { font-size: 24px; }
  .over-card .post { margin-top: 6px; padding: 6px 8px; }
  .over-card .post-rank { margin-bottom: 6px; }
  .over-card .post-who { gap: 6px; margin-bottom: 6px; }
  .over-card .post-who .or { display: none; }
  .over-card .row-btns { margin-top: 8px; }
}

/* ---------- a low window (a phone held sideways) ---------- */
@media (max-height: 420px) {
  #hud { top: max(6px, env(safe-area-inset-top)); left: 10px; right: 10px; padding-right: 172px; gap: 8px; }
  #hud > .card { min-height: 44px; padding: 3px 10px; gap: 7px; }
  .hud-mid { flex-direction: row !important; align-items: center; gap: 10px !important; padding-top: 3px !important; padding-bottom: 3px !important; }
  .stat { font-size: 20px; } .stat svg { width: 22px; height: 22px; }
  .clock-row { font-size: 17px; } .clock-row b { min-width: 38px; } .clock-row svg { width: 19px; height: 19px; }
  .bar { width: 56px; }
  .bays i { display: none; }
  .corner { top: max(6px, env(safe-area-inset-top)); right: 10px; }
  .icon-btn { width: 46px; height: 46px; }
  .strip { left: max(10px, env(safe-area-inset-left)); bottom: 4px; transform: none; max-width: calc(100vw - 20px); font-size: 15px; padding: 3px 12px 3px 4px; gap: 7px; white-space: nowrap; overflow: hidden; }
  .strip #strip-text { overflow: hidden; text-overflow: ellipsis; }
  .mom-face { width: 26px; height: 26px; background-size: 22px; }
  @keyframes stripIn { from { opacity: 0; transform: translateY(8px); } }
  .overlay:not(.top) { padding-top: calc(max(6px, env(safe-area-inset-top)) + 54px); padding-bottom: 6px; }
  .overlay:not(.top) .panel { max-height: calc(100dvh - max(6px, env(safe-area-inset-top)) - 60px); }
  .panel { padding: 12px 18px 10px; }
  h1 { font-size: 30px; } h1::after { margin-top: 4px; }
  .tag-line { margin: 4px 0 6px; font-size: 15px; line-height: 1.25; }
  .how { gap: 3px; margin-bottom: 4px; font-size: 15px; line-height: 1.2; }
  .ic { width: 26px; height: 26px; }
  #title .row-btns { margin-top: 8px; }
  #title .best { margin-top: 4px; }
  .big-btn { min-height: 46px; font-size: 18px; }
  .row-btns > .more-games { flex: 0 1 auto; margin: 0; align-self: center; padding: 0 8px; }
  .row-btns > .more-games .mg-at { display: none; }
  .row-btns > .more-games > span { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--frost); }
  /* the end card in two halves side by side, on the left; Mom and the chicks on the right stay in view */
  .overlay.side { padding-left: max(10px, env(safe-area-inset-left)); }
  .overlay.side .panel.over-card { width: min(500px, 68vw); display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: center; padding: 8px 12px; }
  .over-card h2 { font-size: 21px; margin-bottom: 2px; }
  .over-card .newbest { margin: 0 0 4px; font-size: 16px; }
  .over-card .stats { gap: 4px; margin-bottom: 4px; }
  .over-card .stats div { padding: 2px 6px; } .over-card .stats dd { font-size: 19px; } .over-card .stats dt { font-size: 15px; line-height: 1.1; }
  .over-card .ends { margin-bottom: 0; line-height: 1.2; }
  .over-card .score { font-size: 16px; margin-top: 2px; } .over-card .score b { font-size: 24px; }
  .over-card .best { margin-top: 2px; }
  .over-card .post { margin: 0; padding: 6px 8px; }
  .over-card .post-rank { margin-bottom: 4px; font-size: 15px; line-height: 1.2; }
  .over-card .post-who { gap: 4px; margin-bottom: 4px; }
  .over-card .row-btns { margin-top: 8px; flex-wrap: nowrap; gap: 6px; }
  .over-card .row-btns .big-btn { padding-left: 8px; padding-right: 8px; font-size: 17px; flex: 1; }
  #over .more-games { display: none; }
  .board-list { max-height: 40dvh; }
}
/* a short laptop window: the end card with the posting box already fills it, so the link is left to the title and pause cards */
@media (max-height: 720px) { #over .more-games { display: none; } }

/* a tap never scrolls, zooms or goes back a page; the cards' panels and the leaderboard list still scroll */
html, body { touch-action: none; overscroll-behavior: none; }
.panel, .board-list { touch-action: pan-y; }
button, a, input { touch-action: manipulation; }
