/* ==========================================================================
   GAMES PAGE (/games/). Built on site.css: same colors, type and buttons.
   ========================================================================== */
.gm { --good: #2E7D5B; --good-bg: #E3F2EA; --bad: #B4544C; --bad-bg: #F8E6E3; --gold: #B98A2E; --gold-bg: #F6ECD6;
  padding-bottom: clamp(3rem, 6vw, 5rem); min-height: 40vh; }
.gm [hidden] { display: none !important; }
.gm-zh { font-family: var(--cjk); color: var(--terra-text); font-weight: 600; font-size: .8em; letter-spacing: .04em; }
.gm-fine { font-size: .82rem; color: var(--ink); margin: 0; }
.gm-note { font-size: .85rem; color: var(--ink); margin: 0; }
.gm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- the hub ---------- */
.gm-streak { display: flex; align-items: center; gap: .7rem; width: fit-content; max-width: 100%; margin: 0 auto 1.75rem; padding: .7rem 1.2rem; border-radius: 999px; background: var(--card); border: 1px solid var(--rule); box-shadow: var(--shadow-sm); color: var(--ink); font-size: .95rem; }
.gm-streak strong { color: var(--navy); font-weight: 600; }
.gm-flame { color: var(--terra); display: grid; place-items: center; }
.gm-tiles { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1.25rem; }
.gm-tile { display: grid; grid-template-rows: auto 1fr; background: var(--card); border: 1px solid var(--rule); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-sm); min-width: 0; }
.gm-tile-body { display: grid; grid-template-rows: auto 1fr auto auto; gap: .6rem; padding: 1.1rem 1.25rem 1.3rem; }
.gm-tile h2 { font-size: 1.35rem; }
.gm-tile p { margin: 0; font-size: .93rem; }
.gm-tile .btn { width: 100%; }   /* like the Courses page: one full-width button at the foot of every tile */
.gm-tile-daily { border-color: #E3CF9F; }
@media (min-width: 980px) { .gm-tile-daily { grid-column: span 2; grid-template-rows: none; grid-template-columns: 1fr 1fr; } .gm-tile-daily .gm-art { height: 100%; min-height: 190px; } }
.gm-off { opacity: .55; pointer-events: none; }
.gm-art { position: relative; height: 150px; display: grid; place-items: center; overflow: hidden; }
.gm-art img { width: 100%; height: 100%; object-fit: cover; }
.gm-art-zh { font-family: var(--cjk); font-weight: 600; font-size: 4.2rem; line-height: 1; color: #FBFAF7; text-shadow: 0 2px 0 rgba(10,56,96,.12); }
.gm-art-sub { position: absolute; right: 14px; bottom: 10px; font-size: .9rem; font-weight: 600; color: rgba(251,250,247,.92); letter-spacing: .04em; }
.gm-art::before { content: ""; position: absolute; inset: auto -20% -55% -20%; height: 80%; border-radius: 50%; background: rgba(255,255,255,.13); }
.gm-terra { background: linear-gradient(135deg, #D58A80, #B4544C); }
.gm-sage { background: linear-gradient(135deg, #9DB59A, #6F8F6C); }
.gm-teal { background: linear-gradient(135deg, #7FAEB0, #4F8587); }
.gm-gold { background: linear-gradient(135deg, #D9B36A, #B98A2E); }
.gm-navy { background: linear-gradient(135deg, #5F7E9C, #0A3860); }

/* ---------- a game screen ---------- */
.gm-back { display: inline-block; margin-bottom: .9rem; color: var(--terra-text); font-weight: 500; text-decoration: none; }
.gm-back:hover { text-decoration: underline; text-underline-offset: 3px; }
.gm-game { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.gm-game.gm-solo { grid-template-columns: minmax(0, 720px); justify-content: center; }
@media (max-width: 860px) { .gm-game { grid-template-columns: minmax(0, 1fr); } }
.gm-panel { background: var(--card); border: 1px solid var(--rule); border-radius: 14px; padding: clamp(1rem, 3vw, 1.6rem); box-shadow: var(--shadow-sm); min-width: 0; }
.gm-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: .3rem .8rem; margin-bottom: .9rem; }
.gm-title h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2rem); }
.gm-opts { display: flex; flex-wrap: wrap; gap: .8rem 1rem; align-items: end; margin-bottom: .5rem; }
.gm-opts .gm-note { flex-basis: 100%; }
.gm-field { display: grid; gap: .25rem; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); }
.gm-field select { font: 500 .95rem var(--sans); text-transform: none; letter-spacing: 0; color: var(--navy); background: #fff; border: 1px solid var(--mist-line); border-radius: 8px; padding: .55rem .7rem; min-height: 42px; max-width: 100%; }
.gm-seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--mist-line); border-radius: 999px; padding: 3px; background: #fff; }
.gm-seg button { border: 0; background: none; font: 500 .85rem var(--sans); color: var(--ink); padding: .45rem .9rem; border-radius: 999px; cursor: pointer; min-height: 34px; }
.gm-seg button[aria-pressed="true"] { background: var(--navy); color: #F5F3ED; }
.gm-intro { display: grid; gap: 1rem; justify-items: center; text-align: center; padding: 1.2rem 0 .6rem; }
.gm-intro p { margin: 0; max-width: 52ch; }
.gm-how { font-size: .9rem; color: var(--ink); margin: 0; }
.gm-actions { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; width: 100%; }
.gm-actions .btn, .gm-form .btn { flex: 0 1 200px; min-width: 180px; }
@media (max-width: 480px) { .gm-actions .btn, .gm-form .btn { flex-basis: 100%; } }
.gm button:focus-visible, .gm a:focus-visible, .gm select:focus-visible, .gm input:focus-visible { outline: 3px solid var(--terra); outline-offset: 2px; }

/* the start screen: a preview of a round and the rules as icons */
.gm-peek { position: relative; margin: .9rem 0 0; padding: 1.5rem 1rem 1rem; border-radius: 12px; background: var(--paper); border: 1px dashed var(--mist-line); pointer-events: none; user-select: none; }
.gm-peek-tag { position: absolute; top: -.65rem; left: 1rem; padding: .1rem .6rem; border-radius: 999px; background: var(--navy); color: #F5F3ED; font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.gm-peek-in { font-size: .9em; }
.gm-peek .gm-prompt { min-height: 0; padding: .3rem 0 .2rem; }
.gm-peek .gm-big { font-size: clamp(1.8rem, 1.3rem + 2.4vw, 2.5rem); }
.gm-peek .gm-big.gm-en { font-size: clamp(1.3rem, 1.1rem + 1.2vw, 1.7rem); }
.gm-peek .gm-bar { margin: .5rem 0 .7rem; }
.gm-peek .gm-opt { display: grid; place-items: center; text-align: center; padding: .6rem .8rem; min-height: 46px; font-size: .92rem; }
.gm-peek .gm-zhopt { font-size: 1.15rem; }
.gm-peek .gm-tilebtn { display: grid; place-items: center; text-align: center; min-height: 58px; font-size: .8rem; position: relative; }
.gm-peek .gm-tilebtn.gm-zhopt { font-size: 1.05rem; }
.gm-peek .gm-grid { margin-top: .5rem; }
.gm-peek .gm-opt, .gm-peek .gm-tilebtn { position: relative; }
.gm-p-sel { border-color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); background: var(--mist); animation: gm-sel 3.2s infinite; }
.gm-p-right, .gm-p-mate { animation: gm-right 3.2s infinite; }
.gm-pop { position: absolute; right: .5rem; top: -.2rem; padding: .05rem .45rem; border-radius: 999px; background: var(--good); color: #fff; font: 600 .78rem var(--sans); opacity: 0; animation: gm-pop 3.2s infinite; }
@keyframes gm-right { 0%, 35% { background: #fff; border-color: var(--mist-line); color: var(--navy); } 45%, 92% { background: var(--good-bg); border-color: var(--good); color: var(--good); } 100% { background: #fff; border-color: var(--mist-line); color: var(--navy); } }
@keyframes gm-sel { 0%, 40% { border-color: var(--navy); background: var(--mist); color: var(--navy); } 45%, 92% { border-color: var(--good); background: var(--good-bg); color: var(--good); box-shadow: none; } }
@keyframes gm-pop { 0%, 40% { opacity: 0; transform: translateY(4px); } 48%, 85% { opacity: 1; transform: translateY(-6px); } 100% { opacity: 0; transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) {
  .gm-p-right, .gm-p-mate, .gm-p-sel { animation: none; background: var(--good-bg); border-color: var(--good); color: var(--good); box-shadow: none; }
  .gm-pop { animation: none; opacity: 1; }
}
.gm-rules { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; width: 100%; }
.gm-rule { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: .55rem; align-items: center; text-align: left; padding: .5rem .85rem .5rem .6rem; border-radius: 12px; background: #fff; border: 1px solid var(--rule); min-width: 0; }
.gm-rule .gm-ico { grid-row: span 2; }
.gm-rule b { font: 600 1rem var(--sans); color: var(--navy); line-height: 1.15; white-space: nowrap; }
.gm-rule span:not(.gm-ico) { font-size: .76rem; color: var(--ink); line-height: 1.2; }
.gm-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--mist); color: var(--navy); }
.gm-ico-check { background: var(--good-bg); color: var(--good); }
.gm-ico-bolt { background: var(--gold-bg); color: var(--gold); }
.gm-ico-heart { background: var(--bad-bg); color: var(--bad); }
.gm-ico-flame { background: #FBE7DD; color: #D9663B; }
@media (max-width: 480px) { .gm-rules { display: grid; grid-template-columns: 1fr 1fr; } .gm-rule { padding-right: .5rem; } .gm-rule b { white-space: normal; } }

/* the round */
.gm-hud { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .4rem 1rem; color: var(--navy); font-weight: 500; font-variant-numeric: tabular-nums; }
.gm-hearts { color: var(--terra); letter-spacing: .12em; }
.gm-lost { color: var(--mist-line); }
.gm-combo { color: var(--terra-text); }
.gm-bar { height: 8px; margin: .7rem 0 1rem; border-radius: 99px; background: var(--mist); overflow: hidden; }
.gm-bar i { display: block; height: 100%; width: 100%; background: var(--terra); transition: width .1s linear; }
.gm-bar.low i { background: var(--bad); }
.gm-card { display: grid; gap: 1rem; }
.gm-prompt { display: grid; gap: .3rem; justify-items: center; text-align: center; padding: .8rem 0 .4rem; min-height: 120px; align-content: center; }
.gm-big { font-family: var(--cjk); font-weight: 600; font-size: clamp(2.2rem, 1.4rem + 4vw, 3.4rem); color: var(--navy); line-height: 1.2; }
.gm-big.gm-en { font-family: var(--serif); font-size: clamp(1.5rem, 1.1rem + 2vw, 2.2rem); }
.gm-py { font-family: var(--py); color: var(--ink); }
.gm-hint { color: var(--ink); font-style: italic; font-family: var(--serif); }
.gm-reveal { min-height: 1.5em; font-family: var(--py); color: var(--navy); }
.gm-listen { font: 500 .9rem var(--sans); color: var(--navy); background: var(--mist); border: 0; border-radius: 999px; padding: .6rem 1.1rem; cursor: pointer; }
.gm-opts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
@media (max-width: 480px) { .gm-opts-grid { grid-template-columns: 1fr; } }
.gm-opt { position: relative; font: 500 1rem var(--sans); color: var(--navy); background: #fff; border: 1.5px solid var(--mist-line); border-radius: 10px; padding: .9rem 1rem .9rem 2.2rem; min-height: 58px; cursor: pointer; text-align: left; line-height: 1.3; }
.gm-opt kbd { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); font: 500 .72rem var(--sans); color: var(--ink); opacity: .7; }
@media (hover: none) { .gm-opt kbd { display: none; } .gm-opt { padding-left: 1rem; text-align: center; } }
.gm-opt:hover:not(:disabled) { border-color: var(--navy); }
.gm-opt:disabled { cursor: default; }
.gm-zhopt { font-family: var(--cjk); font-size: 1.3rem; font-weight: 600; }
.gm-tone { display: grid; place-items: center; padding-block: .6rem; }
.gm-tones { display: inline-flex; gap: .9rem; }
.gm-tonebox { display: grid; justify-items: center; gap: .1rem; }
.gm-tonenum { font-size: .8rem; color: var(--ink); line-height: 1; }
.gm-opt.right .gm-tonenum, .gm-opt.wrong .gm-tonenum { color: inherit; }
.gm-opt.right, .gm-tilebtn.done { background: var(--good-bg); border-color: var(--good); color: var(--good); }
.gm-opt.wrong { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.gm-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .6rem; margin-top: 1rem; }
@media (max-width: 560px) { .gm-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.gm-tilebtn { min-height: 86px; padding: .5rem; border-radius: 10px; border: 1.5px solid var(--mist-line); background: #fff; color: var(--navy); font: 500 .88rem var(--sans); line-height: 1.25; cursor: pointer; overflow-wrap: anywhere; }
.gm-tilebtn.gm-zhopt { font-size: 1.25rem; }
.gm-tilebtn.sel { border-color: var(--navy); box-shadow: inset 0 0 0 2px var(--navy); background: var(--mist); }
.gm-tilebtn.done { cursor: default; }
.gm-tilebtn.miss { animation: gm-shake .32s; border-color: var(--bad); }
@keyframes gm-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (prefers-reduced-motion: reduce) { .gm-tilebtn.miss { animation: none; } .gm-bar i { transition: none; } }

/* the result */
.gm-result { display: grid; gap: .7rem; justify-items: center; text-align: center; padding: .6rem 0; }
.gm-result p { margin: 0; }
.gm-score { font-family: var(--serif); font-weight: 600; font-size: clamp(2.4rem, 1.8rem + 3vw, 3.4rem); color: var(--navy); line-height: 1; font-variant-numeric: tabular-nums; }
.gm-place { font-family: var(--script); font-size: 1.6rem; color: var(--terra-text); min-height: 1.2em; }
.gm-save { display: grid; gap: .4rem; justify-items: center; }
.gm-form { display: flex; flex-wrap: wrap; gap: .7rem; justify-content: center; width: 100%; }
.gm-form input { font: 1rem var(--sans); color: var(--navy); border: 1px solid var(--mist-line); border-radius: 8px; padding: .55rem .8rem; min-height: 52px; flex: 0 1 200px; min-width: 180px; }
@media (max-width: 480px) { .gm-form input { flex-basis: 100%; } }
.gm-setmsg { text-align: center; margin: .8rem 0 0; font-weight: 600; color: var(--good); }
.gm-setmsg.gm-bad { color: var(--bad); }
.gm-err { color: var(--bad); font-size: .88rem; min-height: 1.2em; }
.gm-saved { color: var(--good); font-weight: 500; }
.gm-missed { width: 100%; text-align: left; border-top: 1px solid var(--rule); padding-top: .8rem; margin-top: .4rem; }
.gm-missed h3 { font-size: 1.05rem; margin-bottom: .4rem; }
.gm-missed ul { margin: 0; padding-left: 1.1rem; display: grid; gap: .2rem; font-size: .92rem; }
.gm-missed b { font-family: var(--cjk); color: var(--navy); font-weight: 600; }

/* the leaderboard */
.gm-board-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .3rem .8rem; }
.gm-board-head h3 { font-size: 1.25rem; }
.gm-board-head span { font-size: .85rem; color: var(--ink); }
.gm-board .gm-seg { margin: .8rem 0 .4rem; }
.gm-rows { list-style: none; margin: .4rem 0 0; padding: 0; font-variant-numeric: tabular-nums; }
.gm-rows li { display: grid; grid-template-columns: 1.8rem minmax(0, 1fr) auto; gap: .6rem; align-items: center; padding: .55rem .4rem; border-bottom: 1px solid var(--rule); font-size: .92rem; }
.gm-rows li.gm-empty { display: block; color: var(--ink); border: 0; padding: .8rem .2rem; }
.gm-n { text-align: center; color: var(--ink); font-weight: 500; }
.gm-rows li:first-child .gm-n { color: var(--gold); }
.gm-who { color: var(--navy); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gm-who small { color: var(--ink); font-size: .78rem; }
.gm-s { color: var(--navy); font-weight: 600; }
.gm-rows li.gm-me { background: var(--bad-bg); border-radius: 8px; }
.gm-rows li.gm-new { box-shadow: inset 3px 0 0 var(--terra); }
.gm-board-note { font-size: .8rem; color: var(--ink); margin: .8rem 0 0; }
@media (max-width: 640px) { .gm-opts .gm-field { flex: 1 1 100%; } }
