:root {
  --bg: #0f0f0f;
  --bg2: #1a1a1a;
  --bg3: #242424;
  --border: #2e2e2e;
  --text: #f0ede6;
  --muted: #888;
  --accent: #f5a623;
  --accent2: #e8c37a;
  --tile-text-dark: #776e65;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Nav ── */
.nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(15,15,15,0.95);
  backdrop-filter: blur(8px);
  z-index: 100;
}
.nav-logo {
  font-size: 18px;
  font-weight: 900;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.5px;
  margin-right: 8px;
}
.nav-logo span { color: var(--accent); }
.nav-links { display: flex; gap: 4px; flex: 1; }
.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--bg3); }
#wallet-btn {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
  white-space: nowrap;
}
#wallet-btn:hover { opacity: .85; }
#wallet-btn.connected { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 20px; cursor: pointer; padding: 4px 8px; }

/* ── Game Layout ── */
.game-layout {
  display: flex;
  gap: 24px;
  max-width: 820px;
  margin: 0 auto;
  padding: 28px 16px;
  align-items: flex-start;
}

/* ── Side Panel ── */
.side-panel { width: 180px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }
.score-cards { display: flex; gap: 8px; }
.score-card {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 8px;
  text-align: center;
}
.score-label { font-size: 10px; color: var(--muted); letter-spacing: 1px; font-weight: 600; }
.score-val { font-size: 20px; font-weight: 800; color: var(--accent); margin-top: 2px; }

.side-info {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.side-info h3 { font-size: 11px; color: var(--muted); letter-spacing: 1px; margin-bottom: 8px; }
.side-info p { font-size: 13px; color: var(--muted); line-height: 1.6; }
.side-info strong { color: var(--accent); }

.badge-free {
  background: rgba(245,166,35,0.15);
  border: 1px solid rgba(245,166,35,0.3);
  color: var(--accent);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
}
#fee-info { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
#fee-info strong { color: var(--text); }
.hint { font-size: 11px; color: var(--muted); margin-top: 6px; line-height: 1.4; }

/* ── Game Section ── */
.game-section { flex: 1; min-width: 0; }
.game-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.game-header h1 { font-size: 36px; font-weight: 900; color: var(--accent); letter-spacing: -1px; }
.game-controls { display: flex; gap: 8px; }

/* ── Game Board ── */
.game-container {
  position: relative;
  background: #bbada0;
  border-radius: 10px;
  padding: 10px;
  width: 100%;
  aspect-ratio: 1;
  max-width: 480px;
}
.grid-bg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  position: absolute;
  inset: 10px;
}
.grid-cell {
  background: rgba(238,228,218,0.35);
  border-radius: 4px;
}
.tile-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.tile {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-weight: 800;
  font-size: clamp(20px, 5vw, 34px);
  line-height: 1;
  will-change: transform;
  transition: transform 0.12s ease-in-out;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.tile.tile-d4 { font-size: clamp(16px, 4vw, 27px); }   /* 4-digit: 1024, 2048, 4096, 8192 */
.tile.tile-d5 { font-size: clamp(12px, 3vw, 21px); }   /* 5–6 digit: 16384+ */

.tile-appear { animation: appear 0.16s ease; }
.tile-pop    { animation: pop 0.18s ease; }
.tile-vanish { animation: vanish 0.16s ease forwards; }
@keyframes appear { 0% { opacity:0; transform: scale(0); } 100% { opacity:1; } }
@keyframes pop {
  0% { }
  50% { transform: scale(1.18); }
  100% { }
}
@keyframes vanish { to { opacity:0; transform: scale(0.2); } }

/* Tile colors — classic warm ramp up to the golden 2048 hero, Base-blue/violet jewels beyond */
.tile-2     { background:#eee4da; color:var(--tile-text-dark); }
.tile-4     { background:#ede0c8; color:var(--tile-text-dark); }
.tile-8     { background:#f2b179; color:#fff; }
.tile-16    { background:#f59563; color:#fff; }
.tile-32    { background:#f67c5f; color:#fff; }
.tile-64    { background:#f65e3b; color:#fff; }
.tile-128   { background:#edcf72; color:#fff; }
.tile-256   { background:#edcc61; color:#fff; }
.tile-512   { background:#edc850; color:#fff; }
.tile-1024  { background:#edc53f; color:#fff; }
.tile-2048  {
  background: linear-gradient(135deg, #f5a623, #f7b943);
  color:#fff;
  box-shadow: 0 0 28px rgba(245,166,35,0.65), 0 1px 2px rgba(0,0,0,0.2);
}
/* Beyond 2048 — premium Base-blue → violet → magenta jewel tones */
.tile-4096   { background: linear-gradient(135deg, #0052ff, #2f6bff); color:#fff; box-shadow:0 0 24px rgba(0,82,255,0.5); }
.tile-8192   { background: linear-gradient(135deg, #0043cc, #1a5bef); color:#fff; box-shadow:0 0 24px rgba(0,82,255,0.5); }
.tile-16384  { background: linear-gradient(135deg, #5b21d6, #7c3aed); color:#fff; box-shadow:0 0 24px rgba(124,58,237,0.5); }
.tile-32768  { background: linear-gradient(135deg, #7e22ce, #9333ea); color:#fff; box-shadow:0 0 24px rgba(147,51,234,0.5); }
.tile-65536  { background: linear-gradient(135deg, #a21caf, #c026d3); color:#fff; box-shadow:0 0 26px rgba(192,38,211,0.55); }
.tile-super  { background: linear-gradient(135deg, #1a1a2e, #16213e); color:#f5a623; box-shadow:0 0 30px rgba(245,166,35,0.4); }

/* ── Game Over / Won overlay ── */
.game-message {
  position: absolute;
  inset: 0;
  background: rgba(238,228,218,0.85);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 10;
}
.game-message h2 { font-size: 28px; color: var(--tile-text-dark); margin-bottom: 8px; }
.game-message p { color: var(--tile-text-dark); font-size: 15px; margin-bottom: 16px; }
.game-message strong { color: #f65e3b; }
.game-message .life-hint { font-size: 12px; color: #93857a; margin: 6px 0 0; }
.game-message .end-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: center; }
#continue-btn { width: auto; padding: 12px 22px; }
.won-msg { background: rgba(245,166,35,0.88); }
.won-msg h2, .won-msg p, .won-msg strong { color: #fff; }

/* ── Buttons ── */
.btn {
  background: var(--bg3);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  transition: opacity .15s, background .15s;
}
.btn:hover { opacity: .8; }
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); width: 100%; justify-content: center; }
.btn-outline { background: transparent; color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 15px; width: auto; }

/* ── NFT CTA Section ── */
.nft-cta {
  background: var(--bg2);
  border-top: 1px solid var(--border);
  padding: 48px 16px;
  text-align: center;
}
.cta-inner { max-width: 600px; margin: 0 auto; }
.cta-inner h2 { font-size: 26px; font-weight: 800; margin-bottom: 12px; }
.cta-inner p { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.cta-stats { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-bottom: 28px; }
.stat { background: var(--bg3); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; min-width: 100px; }
.stat span { display: block; font-size: 20px; font-weight: 800; color: var(--accent); }
.stat small { font-size: 11px; color: var(--muted); display: block; margin-top: 2px; }

/* ── Section generic ── */
.section { padding: 40px 16px; max-width: 900px; margin: 0 auto; }
.section-title { font-size: 11px; letter-spacing: 2px; color: var(--muted); text-transform: uppercase; margin-bottom: 16px; }

/* ── Card ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

/* ── Table ── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; font-size: 13px; }
th { background: var(--bg3); color: var(--muted); font-size: 11px; letter-spacing: 1px; text-transform: uppercase; }
td { border-top: 1px solid var(--border); color: var(--text); }
tr:hover td { background: var(--bg3); }
.rank-1 td { color: var(--accent); }

/* ── Footer ── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 24px 16px;
  text-align: center;
  margin-top: 40px;
}
.footer-links { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; margin-bottom: 12px; }
.footer-links a { color: var(--muted); text-decoration: none; font-size: 13px; }
.footer-links a:hover { color: var(--text); }
.footer-copy { font-size: 12px; color: var(--muted); }

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 13px;
  opacity: 0;
  transition: transform .25s, opacity .25s;
  z-index: 999;
  white-space: nowrap;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Responsive ── */
@media (max-width: 600px) {
  .nav { padding: 0 16px; }
  .game-layout { flex-direction: column; gap: 16px; padding: 16px 12px; }
  .side-panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .side-panel .score-cards { flex: 1; min-width: 120px; }
  .side-panel .side-info { flex: 1; min-width: 160px; }
  #entry-info { width: 100%; }
  #wallet-btn { margin-left: auto; }
  .nav-links { display: none; flex-direction: column; position: absolute; top: 56px; left: 0; right: 0; background: var(--bg); border-bottom: 1px solid var(--border); padding: 8px 6px; gap: 2px; }
  .nav-links.open { display: flex; }
  .hamburger { display: block; padding: 4px 0 4px 8px; }
  .game-container { max-width: 100%; }
}
