/* Higher or Lower: styles. System fonts only, no remote assets. */
:root {
  --hue: 230;
  --bg: #12102a;
  --bg2: #1d1940;
  --ink: #f6f4ff;
  --muted: #b9b4d9;
  --card: rgba(255, 255, 255, 0.07);
  --card-line: rgba(255, 255, 255, 0.14);
  --accent: hsl(var(--hue) 85% 66%);
  --accent-soft: hsl(var(--hue) 70% 50% / 0.22);
  --up: #3ee08f;
  --down: #ff5c7a;
  --focus: #ffd84d;
  --radius: 22px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 15% -10%, hsl(var(--hue) 70% 45% / 0.35), transparent 60%),
    radial-gradient(900px 500px at 110% 110%, hsl(calc(var(--hue) + 60) 70% 45% / 0.25), transparent 60%),
    linear-gradient(160deg, var(--bg), var(--bg2));
  background-attachment: fixed;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .6s;
}
[hidden] { display: none !important; }
.sr-only, .offscreen { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; left: -9999px; }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--focus); color: #111; padding: 8px 12px; border-radius: 8px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
main { flex: 1; display: flex; flex-direction: column; outline: none; }
.muted { color: var(--muted); }
kbd { font-family: inherit; font-size: .85em; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px clamp(14px, 3vw, 32px); }
.logo { margin: 0; font-size: clamp(1.1rem, 2.4vw, 1.5rem); font-weight: 800; letter-spacing: -0.02em; display: flex; align-items: center; gap: .35em; white-space: nowrap; }
.logo-or { color: var(--muted); font-weight: 600; font-style: italic; }
.logo-up { color: var(--up); font-size: .8em; }
.logo-down { color: var(--down); font-size: .8em; }
.scores { display: flex; gap: 10px; }
.score { background: var(--card); border: 1px solid var(--card-line); border-radius: 14px; padding: 6px 14px; text-align: center; min-width: 74px; }
.score-label { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.score-num { display: block; font-size: 1.35rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- buttons ---------- */
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 999px; cursor: pointer; padding: 12px 22px; color: var(--ink); background: rgba(255,255,255,.1); transition: transform .12s, background-color .2s, box-shadow .2s; touch-action: manipulation; }
.btn:hover { background: rgba(255,255,255,.18); }
.btn:active { transform: scale(.97); }
.btn:disabled { cursor: default; opacity: .6; }
.btn-primary { background: var(--accent); color: #0e0c22; box-shadow: 0 8px 24px hsl(var(--hue) 80% 50% / .35); }
.btn-primary:hover { background: hsl(var(--hue) 90% 72%); }
.btn-big { font-size: 1.2rem; padding: 16px 40px; }
.btn-ghost { background: transparent; border: 2px solid var(--card-line); }
.linkish { font: inherit; background: none; border: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 6px; }
.linkish:hover { color: var(--ink); }

/* ---------- start ---------- */
.screen-start, .screen-over { flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px; }
.start-card, .over-card { max-width: 560px; width: 100%; text-align: center; background: var(--card); border: 1px solid var(--card-line); border-radius: 28px; padding: clamp(24px, 5vw, 44px); backdrop-filter: blur(8px); }
.start-card h2 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.15; margin: 10px 0 14px; letter-spacing: -0.02em; }
.start-card p { margin: 0 0 14px; }
.start-card .btn-big { margin: 10px 0 18px; }
.keys { font-size: .9rem; }
.start-best { font-weight: 700; color: var(--accent); margin-top: 6px; }
.start-art { font-size: 2.2rem; display: flex; justify-content: center; gap: 10px; }
.start-art span { display: inline-block; animation: bob 3s ease-in-out infinite; }
.start-art span:nth-child(2) { animation-delay: .3s; }
.start-art span:nth-child(3) { animation-delay: .6s; }
.start-art span:nth-child(4) { animation-delay: .9s; }
.start-art span:nth-child(5) { animation-delay: 1.2s; }
@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

/* ---------- game ---------- */
.screen-game { flex: 1; display: flex; padding: 0 clamp(12px, 3vw, 32px) 12px; }
.arena { flex: 1; display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: clamp(10px, 2vw, 24px); max-width: 1200px; margin: 0 auto; width: 100%; }
.card { position: relative; border-radius: var(--radius); background: var(--card); border: 1px solid var(--card-line); display: flex; overflow: hidden; min-height: 420px; transition: border-color .3s, box-shadow .3s, background-color .3s; }
.card::before { content: ""; position: absolute; inset: 0; background: radial-gradient(500px 300px at 50% 0%, var(--accent-soft), transparent 70%); pointer-events: none; }
.card-inner { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: clamp(18px, 3vw, 36px); gap: 4px; }
.chip { font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 4px 12px; margin-bottom: 8px; }
.emoji { font-size: clamp(2.6rem, 6vw, 4rem); line-height: 1.1; margin-bottom: 6px; }
.item-name { margin: 0; font-size: clamp(1.35rem, 3vw, 2.1rem); line-height: 1.15; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.item-detail { margin: 2px 0 0; color: var(--muted); font-size: .95rem; }
.stem { margin: 12px 0 0; color: var(--muted); font-size: 1rem; }
.stem-after { margin-top: 6px; }
.stem:empty { display: none; }
.value { margin: 4px 0 0; font-size: clamp(2rem, 5.2vw, 3.4rem); font-weight: 800; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.05; color: var(--ink); overflow-wrap: anywhere; }
.unit { margin: 2px 0 0; color: var(--muted); font-weight: 600; }
.source { margin: 14px 0 0; font-size: .78rem; color: var(--muted); opacity: .85; max-width: 36ch; }
.source:empty { display: none; }
.choices { display: flex; flex-direction: column; gap: 10px; margin: 14px 0 4px; width: min(100%, 280px); }
.btn-choice { font-size: 1.15rem; padding: 15px 20px; min-height: 54px; border: 2px solid transparent; }
.btn-hi { background: rgba(62, 224, 143, .16); border-color: rgba(62, 224, 143, .55); }
.btn-hi:hover { background: rgba(62, 224, 143, .3); }
.btn-lo { background: rgba(255, 92, 122, .16); border-color: rgba(255, 92, 122, .55); }
.btn-lo:hover { background: rgba(255, 92, 122, .3); }
.btn-next { margin-top: 18px; min-width: 160px; font-size: 1.1rem; }
.card-right.is-right { border-color: var(--up); box-shadow: 0 0 0 2px rgba(62,224,143,.35), 0 20px 50px rgba(62,224,143,.15); }
.card-right.is-wrong { border-color: var(--down); box-shadow: 0 0 0 2px rgba(255,92,122,.35), 0 20px 50px rgba(255,92,122,.15); }
.card-right.is-right .value { color: var(--up); }
.card-right.is-wrong .value { color: var(--down); }

.vs { align-self: center; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: #14122b; font-weight: 900; font-size: 1.15rem; box-shadow: 0 10px 30px rgba(0,0,0,.35); position: relative; z-index: 1; transition: background-color .3s, transform .3s; }
.vs > span { grid-area: 1 / 1; transition: opacity .2s, transform .3s; }
.vs-tick, .vs-cross { opacity: 0; transform: scale(.4); font-size: 1.6rem; color: #fff; }
.vs.is-right { background: var(--up); transform: scale(1.08); }
.vs.is-wrong { background: var(--down); transform: scale(1.08); }
.vs.is-right .vs-text, .vs.is-wrong .vs-text { opacity: 0; }
.vs.is-right .vs-tick, .vs.is-wrong .vs-cross { opacity: 1; transform: scale(1); }

.screen-game.enter .card-left { animation: slideIn .45s ease-out both; }
.screen-game.enter .card-right { animation: slideIn .45s .08s ease-out both; }
.card-right.is-wrong { animation: shake .4s ease-in-out; }
.card-right.is-right .value { animation: pop .35s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.08); } 100% { transform: scale(1); } }

/* ---------- game over ---------- */
.over-emoji { font-size: 3.4rem; animation: pop .5s ease-out; }
.over-card h2 { font-size: clamp(1.8rem, 5vw, 2.4rem); margin: 6px 0 8px; outline: none; }
.over-answer { color: var(--muted); margin: 0 0 18px; }
.over-scores { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; }
.over-scores > div { background: rgba(255,255,255,.06); border: 1px solid var(--card-line); border-radius: 18px; padding: 12px 22px; min-width: 130px; }
.big-num { display: block; font-size: 2.8rem; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1.1; }
.new-best { font-weight: 800; color: var(--up); margin: 8px 0; }
.over-quip { margin: 8px 0 20px; }
.over-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; align-items: center; }
.share-status { min-height: 1.4em; margin: 14px 0 0; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }

/* ---------- footer & about ---------- */
.foot { text-align: center; color: var(--muted); font-size: .85rem; padding: 10px 16px 18px; }
.dot { margin: 0 6px; }
.about { max-width: 640px; width: calc(100% - 24px); max-height: calc(100vh - 40px); border: 1px solid var(--card-line); border-radius: 22px; padding: 0; background: #1b1838; color: var(--ink); }
.about::backdrop { background: rgba(5, 4, 15, .7); }
.about-inner { padding: 22px 24px 26px; }
.about-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.about h2 { margin: 0; }
.about h3 { margin: 20px 0 8px; font-size: 1rem; }
.btn-close { padding: 6px 12px; }
.source-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.source-list li { background: rgba(255,255,255,.05); border-radius: 12px; padding: 10px 12px; font-size: .92rem; }
.source-list .src { display: block; color: var(--muted); font-size: .85rem; margin-top: 2px; }

/* ---------- mobile ---------- */
@media (max-width: 760px) {
  .topbar { padding: 10px 14px; }
  .score { min-width: 62px; padding: 4px 10px; }
  .score-num { font-size: 1.15rem; }
  .arena { grid-template-columns: 1fr; grid-template-rows: auto auto auto; gap: 0; }
  .card { min-height: 0; }
  .card-inner { padding: 16px 16px 18px; }
  .card-left .card-inner { padding-bottom: 26px; }
  .card-right .card-inner { padding-top: 26px; }
  .vs { width: 50px; height: 50px; margin: -25px auto; font-size: 1rem; }
  .emoji { font-size: 2.2rem; margin-bottom: 2px; }
  .chip { margin-bottom: 4px; }
  .stem { margin-top: 6px; }
  .value { font-size: clamp(1.8rem, 9vw, 2.4rem); }
  .source { margin-top: 8px; }
  .choices { flex-direction: row; width: 100%; margin-top: 10px; }
  .choices .btn { flex: 1; }
  .btn-next { margin-top: 12px; }
  .over-scores > div { min-width: 0; flex: 1; padding: 10px; }
}
@media (max-width: 380px) {
  .logo { font-size: 1rem; }
}

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
