:root {
  --bg: #090909;
  --panel: #151412;
  --panel-2: #201d17;
  --text: #f4f0e6;
  --muted: #b9ad92;
  --accent: #d6b354;
  --accent-2: #e9d28d;
  --danger: #e18478;
  --ok: #d6b354;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: radial-gradient(1000px 520px at 50% -20%, #292316 0%, var(--bg) 65%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  background: rgba(9, 9, 9, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand { font-size: 26px; letter-spacing: 2px; font-weight: 800; color: var(--accent); }
.brand span { font-size: 15px; letter-spacing: 1px; font-weight: 600; margin-left: 6px; vertical-align: 2px; }
.currency-label { color: var(--accent-2); font-size: 12px; font-weight: 700; letter-spacing: 0.08em; }

.account { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.balance { color: var(--accent-2); font-weight: 700; font-variant-numeric: tabular-nums; }
.currency { color: var(--muted); }

.link {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  padding: 6px 8px;
  cursor: pointer;
}

main { max-width: 500px; margin: 0 auto; padding: clamp(36px, 10vh, 100px) 16px 48px; }

.panel { animation: rise 0.25s ease-out; padding: 28px; background: rgba(21, 20, 18, 0.96); border: 1px solid rgba(214, 179, 84, 0.28); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.48); }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 22px; margin: 6px 0 4px; }
.sub { color: var(--muted); margin: 0 0 18px; font-size: 14px; }

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  padding: 5px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.tab {
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  padding: 10px;
  font-size: 15px;
  cursor: pointer;
}
.tab.active { background: var(--panel-2); color: var(--text); font-weight: 600; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }

input {
  width: 100%;
  padding: 13px 14px;
  font-size: 16px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 11px;
  outline: none;
}
input:focus { border-color: var(--accent); }

button.primary {
  margin-top: 4px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  color: #17130a;
  background: linear-gradient(180deg, #e4ca79, #b28b36);
  border: 0;
  border-radius: 11px;
  cursor: pointer;
  min-height: 48px;
}
button.primary:disabled { opacity: 0.6; }

.message { margin-top: 14px; font-size: 14px; }
.message.error { color: var(--danger); }
.message.ok { color: var(--ok); }

.games {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.game-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 104px;
  padding: 16px;
  text-align: left;
  color: var(--text);
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  cursor: pointer;
}
.game-card:active { transform: scale(0.98); }
.game-card .name { font-size: 17px; font-weight: 700; }
.game-card .name-en { font-size: 12px; color: var(--muted); margin-top: 2px; }
.game-card .code {
  margin-top: 14px;
  align-self: flex-start;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent-2);
  background: rgba(245, 166, 35, 0.12);
  border-radius: 999px;
  padding: 3px 9px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: rgba(6, 15, 26, 0.9);
  z-index: 30;
}
.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

[hidden] { display: none !important; }

@media (min-width: 560px) {
  .games { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 520px) {
  .app-header { padding: 9px 13px; }
  main { padding: 9vh 12px 28px; }
  .panel { padding: 20px 16px; border-radius: 11px; }
  h1 { font-size: 20px; }
  .sub { font-size: 13px; margin-bottom: 15px; }
  .stack { gap: 10px; }
}

@media (min-width: 900px) {
  main { padding-top: 12vh; }
  .panel { padding: 32px; }
}
