:root {
  --bg: #f4ead4;
  --surface: #fff8e9;
  --surface-2: #ead9b8;
  --line: rgba(89, 69, 38, 0.22);
  --text: #2c2012;
  --muted: #705f42;
  --bronze: #8e4f22;
  --red: #9f3326;
  --gold: #c88723;
  --sun: #f4bf58;
  --stone: #8d8574;
  --danger: #b84a42;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    repeating-linear-gradient(135deg, rgba(142, 79, 34, 0.06) 0 10px, transparent 10px 22px),
    linear-gradient(135deg, #f9efdb 0%, #e5d2ad 52%, #c9b07d 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 8%, rgba(244, 191, 88, 0.35), transparent 30%),
    linear-gradient(180deg, rgba(159, 51, 38, 0.08), transparent 44%);
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 248, 233, 0.9);
  backdrop-filter: blur(18px);
  box-shadow: 0 8px 30px rgba(76, 53, 22, 0.08);
}

.brand,
.desktop-nav,
.desktop-nav a,
.bottom-nav a,
.balance-pill {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: #fff8e9;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red), var(--bronze));
  box-shadow: inset 0 -3px 0 rgba(67, 28, 12, 0.28);
}

.desktop-nav {
  gap: 8px;
}

.desktop-nav a {
  gap: 8px;
  padding: 10px 14px;
  color: var(--muted);
  border-radius: 8px;
}

.desktop-nav a.active,
.desktop-nav a:hover,
.bottom-nav a.active {
  color: var(--text);
  background: rgba(200, 135, 35, 0.16);
}

.balance-pill {
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.78);
}

.logout-link {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.58);
}

.logout-link:hover {
  color: var(--text);
  background: rgba(200, 135, 35, 0.16);
}

.balance-pill span,
.muted {
  color: var(--muted);
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 104px;
}

.grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 20px;
  align-items: start;
}

.run-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.7fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, rgba(89, 69, 38, 0.035) 0 8px, transparent 8px 18px),
    linear-gradient(180deg, rgba(255, 248, 233, 0.96), rgba(241, 226, 197, 0.96));
  box-shadow: 0 22px 70px rgba(80, 58, 28, 0.16);
}

.panel {
  padding: clamp(18px, 3vw, 28px);
}

.hero-panel {
  position: relative;
  overflow: hidden;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(circle at 86% 24%, rgba(244, 191, 88, 0.32), transparent 22%),
    repeating-linear-gradient(90deg, rgba(200, 135, 35, 0.08) 0 12px, transparent 12px 28px),
    linear-gradient(90deg, rgba(255, 248, 233, 0.98) 0%, rgba(255, 248, 233, 0.92) 58%, rgba(233, 205, 145, 0.66) 100%),
    #fff8e9;
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 650px;
}

.game-title {
  font-size: clamp(44px, 8vw, 84px);
  line-height: 0.9;
  color: #2a1b0d;
  text-shadow: 0 3px 0 rgba(244, 191, 88, 0.42);
}

h2.game-title {
  font-size: clamp(34px, 5vw, 58px);
}

.game-title.muted {
  color: var(--muted);
}

.artifact-strip {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 20px 0;
}

.artifact {
  width: 82px;
  height: 82px;
  position: relative;
  display: grid;
  place-items: center;
  border: 3px solid rgba(255, 248, 233, 0.85);
  border-radius: 8px;
  box-shadow: 0 12px 24px rgba(80, 58, 28, 0.18);
}

.artifact::before,
.artifact::after {
  content: "";
  position: absolute;
}

.artifact.coin {
  border-radius: 50%;
  background:
    radial-gradient(circle at 36% 32%, #fff3b3 0 12%, transparent 13%),
    radial-gradient(circle, #f4bf58 0 54%, #c88723 55% 70%, #7d421c 71%);
}

.artifact.coin::before {
  inset: 18px;
  border: 5px solid rgba(125, 66, 28, 0.5);
  border-radius: 50%;
}

.artifact.chest {
  background:
    linear-gradient(#f4bf58 0 14%, transparent 14%),
    linear-gradient(90deg, transparent 44%, rgba(255, 248, 233, 0.75) 44% 56%, transparent 56%),
    linear-gradient(180deg, #8e4f22 0 46%, #6f3918 47%);
}

.artifact.chest::before {
  inset: 12px;
  border: 4px solid rgba(255, 248, 233, 0.45);
  border-radius: 4px;
}

.artifact.gem {
  background:
    linear-gradient(135deg, #f4bf58 0 22%, #9f3326 23% 54%, #8e4f22 55%);
  clip-path: polygon(50% 0, 92% 30%, 78% 100%, 22% 100%, 8% 30%);
}

.relic-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 320px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(244, 191, 88, 0.34), transparent 38%),
    repeating-linear-gradient(0deg, rgba(89, 69, 38, 0.055) 0 12px, transparent 12px 24px),
    linear-gradient(180deg, rgba(255, 248, 233, 0.94), rgba(230, 211, 170, 0.92));
}

.relic-image {
  min-height: 170px;
  margin: -28px -28px 22px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(circle at center, rgba(244, 191, 88, 0.4) 0 18%, transparent 19%),
    linear-gradient(135deg, transparent 0 46%, rgba(159, 51, 38, 0.14) 47% 53%, transparent 54%),
    repeating-linear-gradient(90deg, rgba(142, 79, 34, 0.1) 0 10px, transparent 10px 28px),
    linear-gradient(180deg, rgba(255, 248, 233, 0.7), rgba(200, 135, 35, 0.18));
}

.relic-icon {
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  margin-bottom: 20px;
  color: #fff8e9;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red), var(--bronze));
  box-shadow: inset 0 -4px 0 rgba(67, 28, 12, 0.22);
  font-size: 42px;
}

.panel h1,
.panel h2 {
  margin: 0 0 10px;
  letter-spacing: 0;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 20px 0;
}

.hero-panel .stat-row {
  grid-template-columns: minmax(180px, 260px);
}

.stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.72);
  box-shadow: inset 0 -3px 0 rgba(200, 135, 35, 0.12);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 18px;
}

.form-row {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.bet-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.bet-card {
  min-height: 92px;
  display: grid;
  align-content: center;
  gap: 6px;
  padding: 12px;
  color: var(--text);
  border: 2px solid rgba(89, 69, 38, 0.18);
  background:
    radial-gradient(circle at 50% 0%, rgba(244, 191, 88, 0.22), transparent 46%),
    linear-gradient(180deg, #fff8e9, #ead9b8);
  box-shadow: inset 0 -4px 0 rgba(200, 135, 35, 0.18), 0 10px 20px rgba(80, 58, 28, 0.1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.bet-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.bet-card strong {
  font-size: 20px;
}

.bet-card.selected {
  color: #fff8e9;
  border-color: rgba(159, 51, 38, 0.55);
  background: linear-gradient(135deg, var(--red), var(--bronze));
}

.bet-card.selected span {
  color: rgba(255, 248, 233, 0.78);
}

input,
textarea,
button,
.button-link {
  min-height: 48px;
  border-radius: 8px;
}

input,
textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  color: var(--text);
  background: #fffaf0;
  font: inherit;
}

textarea {
  resize: vertical;
}

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  color: #fff8e9;
  font-weight: 800;
  background: linear-gradient(135deg, var(--red), var(--bronze));
  box-shadow: inset 0 -4px 0 rgba(67, 28, 12, 0.25), 0 10px 20px rgba(142, 79, 34, 0.18);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.ghost {
  color: var(--text);
  border: 1px solid var(--line);
  background: rgba(255, 248, 233, 0.55);
}

.payment-box {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.64);
}

.payment-box[hidden] {
  display: none;
}

.qr-holder {
  display: grid;
  place-items: center;
}

.qr-holder img {
  width: min(260px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.status {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
  white-space: pre-line;
}

.status.error {
  color: var(--danger);
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  width: min(100%, 480px);
  margin: 0 auto;
  padding: 24px;
}

.auth-card {
  width: 100%;
  background:
    radial-gradient(circle at 85% 12%, rgba(244, 191, 88, 0.24), transparent 26%),
    repeating-linear-gradient(45deg, rgba(89, 69, 38, 0.04) 0 8px, transparent 8px 18px),
    linear-gradient(rgba(255, 248, 233, 0.96), rgba(255, 248, 233, 0.96));
}

.auth-brand {
  margin-bottom: 24px;
}

.auth-link {
  margin-top: 18px;
}

.auth-link a {
  color: var(--red);
  font-weight: 800;
}

.game-frame {
  display: none;
  width: 100%;
  height: 720px;
  border: 0;
  background: #000;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(41, 30, 15, 0.54);
  pointer-events: none;
  touch-action: none;
}

.modal-backdrop.open {
  display: flex;
  pointer-events: auto;
}

.modal {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    repeating-linear-gradient(45deg, rgba(89, 69, 38, 0.04) 0 8px, transparent 8px 18px),
    linear-gradient(rgba(255, 248, 233, 0.97), rgba(255, 248, 233, 0.97));
}

.game-modal-backdrop {
  z-index: 70;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  align-items: flex-start;
  overflow: auto;
}

.game-modal {
  width: min(1180px, 100%);
  height: min(820px, calc(100dvh - max(28px, env(safe-area-inset-top)) - max(28px, env(safe-area-inset-bottom))));
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #2a1d0f;
  box-shadow: 0 24px 90px rgba(75, 51, 21, 0.44);
}

.game-modal-bar {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--line);
  color: #fff8e9;
  background:
    repeating-linear-gradient(90deg, rgba(255, 248, 233, 0.08) 0 8px, transparent 8px 18px),
    linear-gradient(90deg, rgba(159, 51, 38, 0.96), rgba(142, 79, 34, 0.96));
}

.game-modal-bar .ghost {
  color: #fff8e9;
  border-color: rgba(255, 248, 233, 0.42);
  background: rgba(255, 248, 233, 0.12);
}

.icon-button {
  width: 42px;
  min-height: 42px;
  padding: 0;
}

.game-modal .game-frame {
  display: block;
  width: 100%;
  height: calc(100% - 56px);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.bottom-nav {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 30;
  display: none;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 233, 0.96);
  backdrop-filter: blur(18px);
}

.bottom-nav a {
  flex-direction: column;
  gap: 2px;
  padding: 8px 4px;
  color: var(--muted);
  border-radius: 8px;
  font-size: 12px;
}

.bottom-nav a.active,
.bottom-nav a:hover {
  color: var(--text);
}

@media (max-width: 820px) {
  .desktop-nav {
    display: none;
  }

  .bottom-nav {
    display: grid;
  }

  .topbar {
    gap: 12px;
  }

  .brand span:last-child {
    display: none;
  }

  .grid,
  .run-layout,
  .stat-row {
    grid-template-columns: 1fr;
  }

  .bet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-frame {
    height: calc(100% - 52px);
  }

  .game-modal {
    width: 100%;
    height: calc(100dvh - max(18px, env(safe-area-inset-top)) - max(18px, env(safe-area-inset-bottom)));
    margin-top: max(8px, env(safe-area-inset-top));
  }

  .game-modal-bar {
    height: 52px;
    padding: 0 10px 0 14px;
  }

  .game-modal .game-frame {
    height: calc(100% - 52px);
  }
}
