:root {
  --bg: #0f1116; --panel: #171a22; --panel2: #1e2230; --line: #2a2f3d; --text: #e9ecf3; --muted: #8b93a7;
  --red: #d7263d; --red2: #ff4d5e; --amber: #ffcc00; --green: #7bf1a8;
  font-family: Rubik, "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; flex-direction: column; min-height: 100dvh; }
a { color: var(--amber); }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: .55em 1em; }
button.primary { background: var(--red); border-color: var(--red2); color: #fff; font-weight: 700; }
button.primary:hover { background: var(--red2); }
button.ghost { background: transparent; }
button.ghost:hover { background: var(--panel2); }
button.small { padding: .3em .7em; font-size: .85em; }
button.big { font-size: 1.35em; padding: .6em 1.6em; }
button.icon { font-size: 1.1em; }
button small { font-weight: 400; opacity: .8; }
kbd { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 0 .4em; font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .92em; }
.msg { color: var(--red2); min-height: 1.2em; margin: .3em 0 0; }
.badge { background: var(--amber); color: #111; font-weight: 700; border-radius: 6px; padding: .1em .5em; font-size: .75em; }
.row { display: flex; gap: .6em; flex-wrap: wrap; align-items: center; }
.row.center { justify-content: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

header.top { display: flex; align-items: center; gap: .8em; height: 44px; box-sizing: border-box; padding: 0 1em; border-bottom: 1px solid var(--line); background: var(--panel); }
header nav { margin-left: auto; display: flex; gap: .5em; align-items: center; }
.brand { text-decoration: none; color: var(--text); font-weight: 800; letter-spacing: .04em; display: flex; align-items: center; gap: .4em; }
.brand .sign { display: inline-grid; place-items: center; width: 3em; height: 3em; background: var(--red); color: #fff; font-size: .42em; letter-spacing: 0; font-weight: 900; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); }
.who small { color: var(--muted); }
.link-hub { text-decoration: none; color: var(--muted); }

main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen { flex: 1; min-height: 0; }
#screen-menu { max-width: 1100px; width: 100%; margin: 0 auto; padding: 1.2em 1em 2em; }
.hero { display: flex; gap: 1.6em; align-items: center; margin: .5em 0 1.4em; }
.hero h1 { margin: 0 0 .2em; font-size: 2.4em; letter-spacing: .02em; }
.hero .tag { margin: 0 0 1em; color: var(--muted); line-height: 1.45; }
.hero-sign { flex: none; width: 120px; height: 120px; background: var(--red); display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 1.7em; letter-spacing: .02em; clip-path: polygon(30% 0, 70% 0, 100% 30%, 100% 70%, 70% 100%, 30% 100%, 0 70%, 0 30%); box-shadow: 0 0 0 6px #fff inset; animation: bob 1.4s ease-in-out infinite; }
.hero-sign span { transform: rotate(-8deg); }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-14px) rotate(12deg); } }
.columns { display: grid; grid-template-columns: 1.3fr 1fr; gap: 1em; }
.columns .howto { grid-column: 2; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1em 1.1em; }
.card h2 { margin: 0 0 .6em; font-size: 1.1em; }
.card h2 small { font-weight: 400; font-size: .8em; }
.card label { display: block; margin-bottom: .6em; color: var(--muted); font-size: .9em; }
.card input { display: block; width: 100%; margin-top: .25em; padding: .5em .6em; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); font: inherit; }
.howto ul { margin: 0; padding-left: 1.1em; line-height: 1.6; color: var(--muted); }
.howto b { color: var(--text); }
.tablewrap { max-height: 420px; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .35em .5em; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: .85em; }
tr.me td { color: var(--amber); font-weight: 700; }
.foot { margin-top: 1.4em; color: var(--muted); font-size: .8em; text-align: center; }

/* The canvas is OUT of the layout flow: its bitmap size must never feed back
   into its own CSS box (an in-flow canvas with width/height:100% ratchets the
   page taller on wide windows / rotation). The renderer sizes it from this
   box and sets an explicit CSS size that maps 1:1 onto backing pixels. */
#screen-game { position: relative; display: block; overflow: hidden; background: #33363c; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; user-select: none; -webkit-user-select: none; background: #5ec8ff; }
.hud-btn { position: absolute; top: .6em; right: .6em; background: rgba(0,0,0,.35); border-color: rgba(255,255,255,.2); color: #fff; }
.death { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(10, 8, 12, .45); animation: fadein .25s ease-out; }
@keyframes fadein { from { opacity: 0; transform: scale(.98); } to { opacity: 1; transform: none; } }
.death-box { background: rgba(23, 26, 34, .96); border: 2px solid var(--red); border-radius: 18px; padding: 1.4em 2.2em; text-align: center; min-width: 300px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.death.best .death-box { border-color: var(--green); }
.death-title { font-weight: 900; letter-spacing: .12em; color: var(--red2); }
.death.best .death-title::after { content: ' — NEW BEST'; color: var(--green); }
.death-dist { font-size: 3em; font-weight: 900; margin: .1em 0; }
.death-cause { color: var(--muted); }
.death-attempt { margin-top: .5em; font-weight: 700; }
.death-best { color: var(--amber); margin: .3em 0 1em; min-height: 1.2em; }

@media (max-width: 760px) {
  .columns { grid-template-columns: 1fr; }
  .columns .howto { grid-column: auto; }
  .hero { flex-direction: column; text-align: center; }
  header .who small { display: none; }
}
