/* Serpent & Rung — UI overlay. Dark atmospheric chrome over the 3D canvas.
   Mobile-first: compact HUD, ≥44px touch targets, no horizontal overflow. */

:root {
  --ink: #e8e4d8;
  --ink-dim: #9a967f;
  --gold: #ffd75e;
  --danger: #ff5a5a;
  --good: #9fd66b;
  --panel: rgba(10, 12, 16, 0.86);
  --edge: rgba(255, 215, 94, 0.25);
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #07090c;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}

#app { position: fixed; inset: 0; }
#app canvas { display: block; }

#ui { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#ui > * { pointer-events: none; }

.hidden { display: none !important; }

.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
  pointer-events: none;
}

.fade-layer {
  position: absolute; inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
}

/* ---------- buttons ---------- */
.btn {
  pointer-events: auto;
  display: inline-block;
  min-height: 44px;
  padding: 10px 22px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(40,44,52,0.95), rgba(18,20,26,0.95));
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.btn:hover { border-color: var(--gold); box-shadow: 0 0 14px rgba(255,215,94,0.2); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-primary { border-color: var(--gold); color: var(--gold); }
.btn-danger { border-color: rgba(255,90,90,0.5); color: var(--danger); }
.btn-ghost { opacity: 0.75; }
.btn-big { font-size: 19px; padding: 14px 34px; }
.btn-small { min-height: 44px; padding: 8px 16px; font-size: 13px; }
.btn-icon {
  min-width: 44px; min-height: 44px; padding: 6px;
  font-size: 18px; line-height: 1;
}
.btn.disabled { opacity: 0.35; pointer-events: none; }

/* ---------- title screen ---------- */
.title-screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 30%, rgba(20,26,22,0.35), rgba(4,5,8,0.88));
  pointer-events: auto;
}
.title-kicker { letter-spacing: 0.45em; font-size: 12px; color: var(--ink-dim); text-transform: uppercase; }
.game-title {
  font-size: clamp(42px, 9vw, 84px);
  letter-spacing: 0.08em;
  color: var(--gold);
  text-shadow: 0 0 32px rgba(255,215,94,0.35), 0 2px 0 #4d3a00;
  line-height: 1.05;
}
.title-sub { color: var(--ink-dim); font-style: italic; font-size: clamp(14px, 2.4vw, 17px); }
.seed-row { display: flex; gap: 10px; align-items: center; color: var(--ink-dim); }
.seed-input {
  pointer-events: auto;
  width: 150px; min-height: 44px;
  padding: 8px 12px;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 6px;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  text-align: center;
  letter-spacing: 0.1em;
}
.howto { color: var(--ink-dim); font-size: 13px; line-height: 1.7; }
.howto b { color: var(--ink); }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; }
.hud-left { position: absolute; top: 12px; left: 14px; display: flex; flex-direction: column; gap: 5px; }
.hud-right { position: absolute; top: 12px; right: 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.hearts { font-size: 21px; letter-spacing: 3px; text-shadow: 0 0 10px rgba(255,60,60,0.5); }
.heart { color: #ff5a6a; }
.heart.lost { color: rgba(120,60,70,0.45); text-shadow: none; }
.hud-level { font-size: 13px; color: var(--ink-dim); letter-spacing: 0.08em; }
.hud-score { font-size: 19px; color: var(--gold); }
.hud-score::before { content: '◆ '; opacity: 0.7; }
.hud-relics { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; max-width: 46vw; }
.relic-chip {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 14px;
  padding: 3px 9px;
  font-size: 14px;
}
.relic-chip i { font-style: normal; color: var(--gold); font-size: 11px; margin-left: 3px; }
.hud-seed { font-size: 11px; color: var(--ink-dim); letter-spacing: 0.12em; }
.hud-btns { display: flex; gap: 8px; }
.cursed-badge {
  position: absolute; top: 64px; left: 50%; transform: translateX(-50%);
  background: rgba(80,20,110,0.85);
  border: 1px solid #b04dff;
  color: #e8c8ff;
  padding: 5px 14px;
  border-radius: 14px;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.roll-button {
  pointer-events: auto;
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  min-width: 148px; min-height: 54px;
  border-radius: 28px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, rgba(70,58,20,0.92), rgba(30,24,8,0.92));
  color: var(--gold);
  font-family: inherit;
  font-size: 19px;
  letter-spacing: 0.28em;
  cursor: pointer;
  box-shadow: 0 0 22px rgba(255,215,94,0.18), inset 0 1px 0 rgba(255,255,255,0.12);
  transition: transform 100ms ease, box-shadow 100ms ease, opacity 200ms;
}
.roll-button:hover { box-shadow: 0 0 30px rgba(255,215,94,0.4); transform: translateX(-50%) translateY(-2px); }
.roll-button.disabled { opacity: 0.3; pointer-events: none; }

/* ---------- intro card ---------- */
.intro-card {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  text-align: center;
  background: rgba(2,3,5,0.55);
  animation: introPulse 2.1s ease forwards;
}
@keyframes introPulse {
  0% { opacity: 0; } 12% { opacity: 1; } 82% { opacity: 1; } 100% { opacity: 0; }
}
.intro-kicker { letter-spacing: 0.4em; font-size: 12px; color: var(--ink-dim); }
.intro-name { font-size: clamp(30px, 6vw, 54px); color: var(--gold); text-shadow: 0 0 26px rgba(255,215,94,0.3); }
.intro-tagline { font-style: italic; color: var(--ink-dim); font-size: clamp(13px, 2.4vw, 16px); }

/* ---------- toasts ---------- */
.toast-layer {
  position: absolute;
  top: 17%;
  left: 50%;
  transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: max-content; max-width: 92vw;
}
.toast {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.16);
  border-left: 3px solid var(--ink-dim);
  padding: 8px 18px;
  border-radius: 6px;
  font-size: 15px;
  animation: toastIn 240ms ease;
  transition: opacity 400ms ease, transform 400ms ease;
  max-width: 92vw;
  text-align: center;
}
.toast.good { border-left-color: var(--good); color: #d8ffc2; }
.toast.bad { border-left-color: var(--danger); color: #ffc9c9; }
.toast.gone { opacity: 0; transform: translateY(-12px); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; } }

/* ---------- reroll panel ---------- */
.reroll-panel {
  position: absolute;
  bottom: 92px;
  left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 10px 16px;
  pointer-events: auto;
}
.reroll-text { font-size: 14px; color: var(--ink); white-space: nowrap; }

/* ---------- modals ---------- */
.modal {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(2,3,5,0.72);
  padding: 18px;
  overflow-y: auto;
}
.modal-box {
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 12px;
  padding: 26px 30px;
  display: flex; flex-direction: column; gap: 14px;
  align-items: center;
  text-align: center;
  max-width: 640px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  pointer-events: auto;
  box-shadow: 0 0 60px rgba(0,0,0,0.7);
}
.modal-box h2 { color: var(--gold); font-size: clamp(22px, 4.6vw, 32px); letter-spacing: 0.06em; }
.modal-sub { color: var(--ink-dim); font-style: italic; font-size: 14px; }

/* ---------- draft ---------- */
.draft-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.draft-card {
  pointer-events: auto;
  width: 168px;
  background: linear-gradient(180deg, rgba(28,32,40,0.97), rgba(14,16,22,0.97));
  border: 1px solid;
  border-radius: 10px;
  padding: 16px 12px;
  display: flex; flex-direction: column; gap: 7px;
  align-items: center;
  cursor: pointer;
  color: var(--ink);
  font-family: inherit;
  transition: transform 130ms ease, box-shadow 130ms ease;
  min-height: 44px;
}
.draft-card:hover { transform: translateY(-4px) scale(1.03); box-shadow: 0 8px 26px rgba(0,0,0,0.6); }
.draft-icon { font-size: 38px; }
.draft-name { font-size: 16px; color: var(--gold); }
.draft-rarity { font-size: 10px; letter-spacing: 0.28em; text-transform: uppercase; }
.draft-desc { font-size: 12.5px; color: var(--ink-dim); line-height: 1.5; }
.rarity-common { border-color: #9fb4a8; } .rarity-common .draft-rarity { color: #9fb4a8; }
.rarity-uncommon { border-color: #6fd66f; } .rarity-uncommon .draft-rarity { color: #6fd66f; }
.rarity-rare { border-color: #5eb8ff; } .rarity-rare .draft-rarity { color: #5eb8ff; }
.rarity-legendary { border-color: #ffb347; box-shadow: 0 0 18px rgba(255,179,71,0.25); } .rarity-legendary .draft-rarity { color: #ffb347; }

/* ---------- end screens ---------- */
.end-win .end-title { color: var(--gold); text-shadow: 0 0 30px rgba(255,215,94,0.4); }
.end-lose .end-title { color: var(--danger); text-shadow: 0 0 30px rgba(255,90,90,0.3); }
.stats-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 5px 22px;
  font-size: 14px;
  margin: 4px 0;
}
.stat-k { color: var(--ink-dim); text-align: right; }
.stat-v { color: var(--ink); text-align: left; font-weight: bold; }

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  .hud-left { top: 8px; left: 8px; gap: 3px; }
  .hud-right { top: 8px; right: 8px; gap: 4px; }
  .hearts { font-size: 17px; letter-spacing: 2px; }
  .hud-level { font-size: 12px; }
  .hud-score { font-size: 15px; }
  .relic-chip { font-size: 12px; padding: 2px 7px; }
  .hud-relics { max-width: 52vw; }
  .roll-button { min-width: 128px; min-height: 50px; font-size: 16px; bottom: max(14px, env(safe-area-inset-bottom)); }
  .reroll-panel { bottom: 78px; flex-wrap: wrap; justify-content: center; max-width: 92vw; }
  .modal-box { padding: 18px 14px; }
  .draft-card { width: calc(50% - 8px); }
  .stats-grid { font-size: 12.5px; gap: 4px 14px; }
  .hud-seed { font-size: 12px; }
  .toast { font-size: 13px; padding: 7px 12px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
}

@media (max-height: 480px) and (orientation: landscape) {
  .roll-button { bottom: 8px; min-height: 44px; }
  .game-title { font-size: clamp(30px, 7vh, 48px); }
  .title-screen { gap: 10px; }
}
