:root {
  --bg: #061115;
  --panel: rgba(10, 27, 34, 0.88);
  --panel-strong: #0f252e;
  --text: #eef9fb;
  --muted: #9bb2b8;
  --line: rgba(255, 255, 255, 0.1);
  --accent: #55f2c2;
  --accent-2: #ffcf5a;
  --danger: #ff6b6b;
  --shadow: 0 24px 80px rgba(0,0,0,.45);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 10%, rgba(85,242,194,.15), transparent 30%),
    radial-gradient(circle at 85% 5%, rgba(255,207,90,.12), transparent 28%),
    linear-gradient(135deg, #03080a 0%, var(--bg) 48%, #020405 100%);
  overscroll-behavior: none;
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
code {
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,.08);
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 max(36px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: rgba(5, 16, 21, .72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand-block { min-width: 0; }
.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  margin-bottom: 8px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(28px, 4vw, 48px); line-height: 1; }
h2 { font-size: 20px; margin-bottom: 14px; }
.subtitle { margin: 0; color: var(--muted); line-height: 1.45; }

.wallet-card {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 280px;
}

.wallet-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 13px;
}
.muted { color: var(--muted); }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  margin-top: 20px;
}

.game-panel, .card {
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.game-panel { padding: 16px; }
.side-panel { display: grid; gap: 18px; align-content: start; }
.card { padding: 18px; }

.game-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr)) auto;
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.score-box {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.05);
}
.score-box span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 5px; }
.score-box strong { font-size: 24px; }

.toolbar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

.btn {
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  padding: 11px 15px;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, background .16s ease, opacity .16s ease;
  white-space: nowrap;
  min-height: 44px;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: rgba(255,255,255,.28); }
.btn:disabled { cursor: not-allowed; opacity: .5; }
.btn-primary { background: linear-gradient(135deg, #39dba7, #14a97f); color: #03100d; border-color: transparent; font-weight: 800; }
.btn-accent { background: linear-gradient(135deg, #ffe08a, #ffb72c); color: #1a1000; border-color: transparent; font-weight: 800; }
.btn-ghost { background: transparent; }

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #071014;
  min-height: 420px;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 960 / 640;
  cursor: crosshair;
  background:
    radial-gradient(circle at center, rgba(85,242,194,.08), transparent 30%),
    linear-gradient(160deg, #09202a, #030607 70%);
  touch-action: none;
  user-select: none;
}

.mobile-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(0,0,0,.35);
  border: 1px solid var(--line);
  font-size: 12px;
  pointer-events: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, .38);
}
.overlay-card {
  width: min(620px, 100%);
  padding: 26px;
  border-radius: 26px;
  border: 1px solid var(--line);
  background: rgba(8, 23, 28, .94);
  text-align: center;
  box-shadow: var(--shadow);
}
.overlay-card h2 { font-size: 34px; margin-bottom: 8px; }
.overlay-card p { color: var(--muted); line-height: 1.55; }
.overlay-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.rules { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rules span {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--muted);
  font-size: 13px;
}

.touch-controls {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.notice {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin: 12px 4px 0;
}

.leaderboard {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.leaderboard li {
  display: grid;
  grid-template-columns: 46px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.06);
}
.rank { color: var(--accent-2); font-weight: 800; }
.wallet { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.empty-state { color: var(--muted); padding: 14px; border-radius: 16px; background: rgba(255,255,255,.05); }
.small { color: var(--muted); font-size: 13px; line-height: 1.5; }
.reward-list { display: grid; gap: 8px; }
.reward {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.06);
}
.reward strong, .reward span { display: block; }
.reward span { color: var(--muted); font-size: 12px; margin-top: 3px; }
.reward b { color: var(--accent); }
.status-card p { color: var(--muted); line-height: 1.5; min-height: 48px; }

@media (max-width: 1180px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .wallet-card { align-items: flex-start; width: 100%; min-width: 0; }
  .wallet-meta { justify-content: flex-start; }
  .layout { grid-template-columns: 1fr; }
  .game-toolbar { grid-template-columns: repeat(4, 1fr); }
  .toolbar-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 760px) {
  .app-shell { width: min(100% - 18px, 1480px); padding-top: 10px; }
  .topbar, .game-panel, .card { border-radius: 20px; }
  .topbar { padding: 16px; }
  .game-panel, .card { padding: 12px; }
  .game-toolbar { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .score-box { padding: 10px 11px; border-radius: 15px; }
  .score-box strong { font-size: 20px; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr; width: 100%; }
  .btn { width: 100%; padding-inline: 12px; }
  .canvas-wrap { min-height: auto; border-radius: 18px; }
  .overlay { padding: 10px; }
  .overlay-card { padding: 16px; border-radius: 18px; }
  .overlay-card h2 { font-size: 26px; }
  .rules { display: none; }
  .touch-controls { display: grid; }
  .notice { font-size: 12px; }
}

@media (max-width: 420px) {
  .game-toolbar { grid-template-columns: 1fr 1fr; }
  .score-box span { font-size: 11px; }
  .score-box strong { font-size: 18px; }
  .leaderboard li { grid-template-columns: 40px 1fr auto; padding-inline: 9px; }
}
