:root {
  --bg: #161018;
  --panel: rgba(28, 18, 24, 0.82);
  --ink: #f3eadc;
  --muted: #b9a496;
  --accent: #e8b86d;
  --good: #d4a056;
  --warn: #e09a5a;
  --bad: #d97878;
  --line: #5a4638;
  --chip: rgba(42, 28, 32, 0.92);
  --shadow: 0 10px 28px rgba(20, 8, 12, .5);
  --radius: 8px;
  --mono: "Cascadia Code", "Fira Code", ui-monospace, monospace;
  --sans: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #120c12; }
body {
  font-family: var(--sans);
  color: var(--ink);
  min-height: 100vh;
  background: transparent;
  line-height: 1.4;
}
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-color: #120c12;
  background-image:
    radial-gradient(900px 520px at 8% -8%, rgba(92, 58, 140, .42) 0%, transparent 58%),
    radial-gradient(820px 480px at 108% 4%, rgba(176, 72, 64, .28) 0%, transparent 52%),
    radial-gradient(700px 420px at 50% 118%, rgba(212, 160, 86, .18) 0%, transparent 55%),
    linear-gradient(180deg, rgba(18, 12, 16, .2), rgba(12, 8, 12, .72));
}
body::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: .18;
  background-image:
    repeating-linear-gradient(90deg, rgba(243,234,220,.07) 0 1px, transparent 1px 3px),
    repeating-linear-gradient(0deg, rgba(243,234,220,.05) 0 1px, transparent 1px 4px);
}
.wrap {
  position: relative; z-index: 1;
  max-width: 720px; margin: 0 auto;
  padding: calc(36px + env(safe-area-inset-top, 28px)) 14px 40px;
}
header {
  display: flex; flex-wrap: wrap; gap: 12px 18px;
  justify-content: space-between; align-items: end; margin-bottom: 18px;
}
.brand h1, .menu-hero h1 {
  margin: 0; font-size: 1.55rem; letter-spacing: .12em;
  text-transform: uppercase; color: #f0d09a;
  text-shadow: 0 0 12px rgba(232,184,109,.28);
}
.brand p, .menu-hero p { margin: 4px 0 0; color: var(--muted); font-size: .95rem; }
.brand-tagline {
  margin: 8px 0 0;
  padding: 8px 12px;
  background: #22161c;
  border: 1px solid #6a5344;
  border-radius: 4px;
  color: #e6d6c4;
  font-size: .92rem;
  line-height: 1.35;
}
.wallet { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.wallet-pill {
  background: rgba(28, 16, 20, 0.86);
  border: 1px solid #6a5344;
  border-radius: 4px;
  padding: 8px 12px;
  box-shadow: inset 0 0 0 1px rgba(232,184,109,.1), var(--shadow);
  font-size: .88rem; color: var(--muted);
  font-family: var(--mono);
}
.wallet-pill b { color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.controls, .rules, .shop-card, .account-bar {
  background: rgba(28, 16, 22, 0.82);
  border: 1px solid #5a4638;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(232,184,109,.08), var(--shadow);
}
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  padding: 14px;
  margin-bottom: 14px;
  align-items: start;
}
.controls .btn-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: stretch;
  justify-content: space-between;
}
.controls .btn-row button, .controls .btn-row a.btn {
  flex: 1 1 148px;
}
label {
  display: grid; gap: 6px; font-size: .78rem; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
}
select, button, input[type="text"], a.btn {
  font: inherit; border-radius: 4px; border: 1px solid #6a5344;
  background: #22161c; color: var(--ink); padding: 10px 12px;
}
select:focus, button:focus, input:focus, a.btn:focus {
  outline: 2px solid #e8b86d;
  outline-offset: 1px;
}
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: stretch; }
button, a.btn {
  cursor: pointer; transition: .15s ease; white-space: nowrap;
  text-align: center; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px;
}
button:hover, a.btn:hover { transform: translateY(-1px); border-color: #e8b86d; text-decoration: none; }
button.primary, a.btn.primary {
  background: #4a2e18;
  border-color: #e8b86d;
  color: #ffe9c4;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
button.ghost, a.btn.ghost {
  background: rgba(28,16,22,.55);
  border-color: #6a5344;
  color: #e6d6c4;
}
button.tutorial {
  background: #5a1212;
  border-color: #ef4444;
  color: #ffe4e4;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
button.warn, a.btn.warn {
  background: #3a2210;
  border-color: #e09a5a;
  color: #ffe7b0;
  font-weight: 700;
}
button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.rules {
  padding: 12px 14px; margin-bottom: 14px; color: var(--muted); font-size: .9rem;
}
.rules strong { color: var(--ink); }
.shop-card {
  padding: 16px;
  margin-bottom: 12px;
}
.shop-card h2 {
  margin: 0 0 6px; font-size: 1.05rem; letter-spacing: .06em; text-transform: uppercase;
  color: #f0d09a;
}
.shop-card p { margin: 0 0 12px; color: var(--muted); font-size: .92rem; }
.shop-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid #3a2a28;
}
.shop-row:first-of-type { border-top: 0; }
.shop-row .meta { margin: 0; color: var(--muted); font-size: .85rem; }
.shop-row b { color: var(--ink); }
.account-bar {
  padding: 12px 14px;
  margin-bottom: 14px;
}
.account-status { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }
.account-status b { color: var(--ink); }
.username-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.username-row.hidden { display: none; }
.username-row input {
  flex: 1; min-width: 140px; background: #22161c; border: 1px solid #6a5344;
  color: var(--ink); border-radius: 8px; padding: 8px 10px; font: inherit;
}
.screen { display: none; }
.screen.active { display: block; }
.hidden { display: none !important; }
.menu-hero { margin-bottom: 16px; }
footer { color: var(--muted); font-size: .85rem; text-align: center; margin-top: 8px; }
.board-list { display: grid; gap: 0; }
.board-row {
  display: grid;
  grid-template-columns: 2.4em 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid #3a2a28;
  font-family: var(--mono);
  font-size: .88rem;
}
.board-row .rank { color: var(--muted); }
.board-note, .board-invite, .board-soon { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }
.board-login {
  display: inline;
  margin-left: 8px;
  color: var(--muted);
  font-size: .75rem;
  text-decoration: underline;
  opacity: .72;
}
.board-login:hover { opacity: 1; }
button.board-soon {
  display: inline-flex;
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px dashed #5a4638;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: 600 12px Segoe UI, sans-serif;
  opacity: .7;
  cursor: default;
}
.history {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.card {
  background: #22161c;
  border: 1px solid #5a4638;
  border-radius: 8px;
  overflow: hidden;
}
.card .body { padding: 10px 12px; display: grid; gap: 6px; }
.card h3 { margin: 0; font-size: .95rem; color: var(--ink); }
.card p { margin: 0; color: var(--muted); font-size: .8rem; }
.tag {
  display: inline-flex; width: fit-content;
  padding: 2px 8px; border-radius: 4px;
  background: #4a2e18; color: var(--accent);
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; font-family: var(--mono);
}
.game-top {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: rgba(28, 16, 22, 0.94);
  border-bottom: 1px solid #5a4638;
}
.game-top h1 { margin: 0; font-size: 1rem; letter-spacing: .08em; text-transform: uppercase; color: #f0d09a; }
.game-top a, .game-top button {
  color: var(--accent);
  background: none;
  border: 0;
  font: 600 13px var(--sans);
  cursor: pointer;
  padding: 0;
  min-height: 0;
}
.game-top button.warn { color: var(--warn); }
@media (max-width: 720px) {
  .wrap { padding: calc(32px + env(safe-area-inset-top, 24px)) 10px 36px; }
  .btn-row button, .btn-row a.btn { min-height: 48px; padding: 12px 14px; }
  .controls { grid-template-columns: 1fr; }
}
