/* Pawn Crossing: a chess take on lane-dodging arcade games. */
:root {
  /* Ocean orange brand colours (see brand/README.md). --green is the main brand blue. */
  --ink: #023e58;
  --ink-soft: #4f6f7c;
  --paper: #ffffff;
  --line: #d7eef4;
  --green: #0096c7;
  --gold: #ffc233;
  --gold-soft: #fff4c7;
  --coral: #ff8c42;
  --coral-dark: #d9691f;
  --deep: #006a92;
  --serif: "Baloo 2", ui-rounded, "SF Pro Rounded", "Nunito", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--deep); color: var(--ink); font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
canvas { display: block; touch-action: none; user-select: none; -webkit-user-select: none; }

.hud { position: fixed; inset: 0 0 auto 0; display: flex; align-items: flex-start; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 16px 0; pointer-events: none; }
.hud > * { pointer-events: auto; }
.score { text-align: center; color: #fff; font-family: var(--serif); font-weight: 800; text-shadow: 0 2px 0 rgb(0 0 0 / 25%), 0 6px 20px rgb(0 0 0 / 30%); position: absolute; left: 50%; transform: translateX(-50%); top: max(10px, env(safe-area-inset-top)); }
.score b { display: block; font-size: 52px; line-height: 1; letter-spacing: -1px; }
.score small { font-size: 12px; letter-spacing: .18em; text-transform: uppercase; opacity: .8; }
.score.bump b { animation: bump .25s ease-out; }
@keyframes bump { 40% { transform: scale(1.18); } }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 999px; border: 0; background: rgb(2 62 88 / 45%); color: #fff; font: 600 14px var(--sans); text-decoration: none; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); cursor: pointer; }
.pill b { color: var(--gold-soft); }
.left { display: flex; gap: 8px; }
.right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.toast { position: fixed; left: 50%; top: 22%; transform: translate(-50%, 0) scale(.8); padding: 10px 18px; border-radius: 999px; background: var(--gold); color: var(--ink); font: 800 18px var(--serif); box-shadow: 0 10px 30px rgb(0 0 0 / 30%); opacity: 0; pointer-events: none; white-space: nowrap; }
.toast.show { animation: toast 1.6s ease-out forwards; }
@keyframes toast { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 25% { transform: translate(-50%, 0) scale(1); } 75% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -14px) scale(1); } }

.overlay { position: fixed; inset: 0; display: grid; justify-items: center; align-items: safe center; overflow-y: auto; padding: 64px 16px 16px; background: radial-gradient(ellipse at center, rgb(2 62 88 / 30%), rgb(1 30 44 / 62%)); transition: opacity .25s ease; }
.overlay.hidden { opacity: 0; pointer-events: none; }
.card { width: min(380px, 100%); background: var(--paper); border-radius: 22px; padding: 26px 24px 22px; text-align: center; box-shadow: 0 2px 0 rgb(255 255 255 / 60%) inset, 0 24px 60px rgb(0 0 0 / 40%); transform: translateY(0); transition: transform .3s cubic-bezier(.2,.9,.3,1.3); }
.overlay.hidden .card { transform: translateY(16px) scale(.97); }
.badge { width: 72px; height: 72px; margin: -62px auto 10px; border-radius: 50%; background: var(--green); display: grid; place-items: center; box-shadow: 0 8px 20px rgb(0 0 0 / 30%), 0 0 0 5px var(--paper); }
h1, h2 { font-family: var(--serif); margin: 0 0 6px; letter-spacing: -.5px; }
h1 { font-size: 32px; }
h2 { font-size: 26px; }
.card p { margin: 0 0 16px; color: var(--ink-soft); }
.keys { display: flex; justify-content: center; gap: 14px; margin: 0 0 18px; font-size: 13px; color: var(--ink-soft); flex-wrap: wrap; }
.keys span { display: inline-flex; align-items: center; gap: 6px; }
kbd { display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 7px; background: #fff; border: 1px solid var(--line); border-bottom-width: 3px; font: 600 13px var(--sans); color: var(--ink); }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 20px; text-align: left; }
.legend div { display: flex; gap: 10px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; font-size: 13px; line-height: 1.3; color: var(--ink-soft); }
.legend strong { color: var(--ink); display: block; font-size: 14px; }
.legend canvas { flex: none; }
.btn { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 52px; border: 0; border-radius: 14px; background: var(--coral); color: #fff; font: 800 18px var(--serif); cursor: pointer; box-shadow: 0 4px 0 var(--coral-dark); transition: transform .08s, box-shadow .08s; }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--coral-dark); }
.btn:focus-visible, .pill:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.card p.tip { margin: -6px 0 16px; font-size: 13px; }
.hint { margin-top: 10px; font-size: 12px; color: var(--ink-soft); }
.stats { display: flex; justify-content: center; gap: 12px; margin: 6px 0 18px; }
.stats div { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px 6px; }
.stats b { display: block; font: 800 34px/1.1 var(--serif); }
.stats small { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.newbest { display: inline-block; margin-bottom: 8px; padding: 3px 10px; border-radius: 999px; background: var(--gold-soft); color: #8a6512; font: 800 13px var(--serif); letter-spacing: .04em; }
.newbest[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .card, .overlay { transition: none; } .toast.show { animation-duration: 2s; } }

.stats div { min-width: 0; }
.link { display: block; margin: 12px auto 0; border: 0; background: none; color: var(--green); font: 700 15px var(--serif); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.entry { margin: 0 0 14px; text-align: left; }
.entry label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.entry-row { display: flex; gap: 8px; }
.entry input { flex: 1; min-width: 0; height: 44px; padding: 0 12px; border: 2px solid var(--line); border-radius: 12px; font: 600 16px var(--sans); background: #fff; color: var(--ink); }
.entry input:focus { outline: none; border-color: var(--gold); }
.btn.small { width: auto; height: 44px; padding: 0 18px; font-size: 16px; box-shadow: 0 3px 0 var(--coral-dark); }
.board { list-style: none; margin: 0 0 16px; padding: 0; text-align: left; counter-reset: rank; }
.board:empty { display: none; }
.board li { counter-increment: rank; display: grid; grid-template-columns: 26px 1fr auto auto; gap: 8px; align-items: center; padding: 5px 10px; border-radius: 10px; font-size: 14px; }
.board li:nth-child(odd) { background: #fff; }
.board li::before { content: counter(rank); font: 800 14px var(--serif); color: var(--ink-soft); }
.board li:nth-child(1)::before { color: var(--gold); }
.board li.me { background: var(--gold-soft); outline: 2px solid var(--gold); }
.board .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .sc { font: 800 16px var(--serif); }
.board .ea { font-size: 12px; color: var(--ink-soft); min-width: 52px; text-align: right; }
.board .empty { display: block; text-align: center; color: var(--ink-soft); }
.board .empty::before { content: none; }
