/* ==========================================================================
   App shell — device frame, nav rail, top bar, and reusable UI atoms.
   Table-first, tactile: warm felt surfaces, capiz translucency, soft corners,
   generous touch targets (lolas-first, PRD §12–13).
   ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-ui);
  color: var(--bone);
  background: var(--panel-warm);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button { font-family: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
img { max-width: 100%; }

#app {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(0px, 2vmin, 28px);
}

/* ---- The device / stage ---- */
.device {
  position: relative;
  width: min(100%, 1180px);
  height: min(100%, 620px);
  aspect-ratio: 1180 / 620;
  display: flex;
  border-radius: clamp(20px, 3vmin, 40px);
  overflow: hidden;
  background: var(--felt-app);
  box-shadow: var(--shadow-pop), 0 0 0 1px rgba(255,255,255,0.05);
  isolation: isolate;
}
.device::before { /* banig weave warmth */
  content: ''; position: absolute; inset: 0; z-index: 0;
  background-image: var(--banig); pointer-events: none;
}
.device::after { /* soft vignette for depth */
  content: ''; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  box-shadow: inset 0 0 130px rgba(0,0,0,0.42);
}

/* ---- Nav rail ---- */
.rail {
  position: relative; z-index: 25;
  width: var(--rail-w); flex: 0 0 var(--rail-w);
  display: flex; flex-direction: column; align-items: center;
  padding: 14px 0 16px;
  background: linear-gradient(180deg, rgba(6,32,24,0.62), rgba(6,32,24,0.9));
  border-right: 1px solid var(--line-gold);
}
.rail__brand { margin-bottom: 8px; }
.rail__nav { flex: 1; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.rail__item {
  width: 62px; padding: 9px 0; border-radius: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  color: var(--bone-dim); border: 1px solid transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.rail__item:hover { color: var(--bone); background: rgba(255,255,255,0.04); }
.rail__item.is-active { color: var(--gold-hi); background: rgba(224,164,44,0.16); border-color: var(--line-gold-2); }
.rail__ico { width: 20px; height: 20px; display: grid; place-items: center; }
.rail__label { font-size: 9.5px; font-weight: 700; letter-spacing: .2px; }

/* ---- Stage / screens ---- */
.stage { position: relative; z-index: 10; flex: 1; min-width: 0; display: flex; overflow: hidden; }
.screen { position: relative; flex: 1; min-width: 0; display: flex; flex-direction: column; }
.screen--pad { padding: 16px 22px 20px; overflow: auto; }

/* Top status bar (faux device chrome + contextual header) */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 20px 4px; color: var(--bone-dim);
  font-size: 12px; font-variant-numeric: tabular-nums; flex: 0 0 auto;
}
.topbar .clock { font-weight: 700; color: var(--bone); }
.topbar .spacer { flex: 1; }
.topbar .sysico { display: inline-flex; gap: 5px; align-items: center; opacity: .7; }

/* ---- Currency counters (cosmetics/progression only — never a stake) ---- */
.wallet { display: flex; gap: 10px; align-items: center; }
.counter {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 8px 6px 10px; border-radius: var(--r-pill);
  background: rgba(8,26,20,0.62); border: 1px solid var(--line-gold);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}
.counter b { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .2px; color: var(--bone-bright); font-size: 14px; }
.counter .coin {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #3a2a06;
  background: radial-gradient(circle at 38% 30%, #F7CF69, #E0A42C 70%);
  box-shadow: inset 0 0 0 1.5px rgba(120,80,10,.35);
}
.counter .gem {
  width: 20px; height: 20px; display: grid; place-items: center;
  background: linear-gradient(135deg, #D2503E, #BE3A2B); clip-path: polygon(50% 0, 100% 38%, 50% 100%, 0 38%);
}
.counter .plus {
  width: 20px; height: 20px; border-radius: 50%; font-size: 15px; line-height: 1;
  display: grid; place-items: center; color: var(--gold-hi);
  background: rgba(224,164,44,0.14); border: 1px solid var(--line-gold-2);
}
.counter .plus:hover { background: rgba(224,164,44,0.26); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: 15px;
  letter-spacing: .2px; transition: transform .1s ease, filter .15s ease, box-shadow .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px) scale(.995); }
.btn--gold { background: var(--grad-gold); color: #3a2a06; box-shadow: 0 10px 24px rgba(224,164,44,.28), inset 0 1px 0 rgba(255,255,255,.4); }
.btn--gold:hover { filter: brightness(1.05); }
.btn--green { background: var(--grad-bamboo); color: #06281c; box-shadow: 0 10px 22px rgba(47,138,99,.3), inset 0 1px 0 rgba(255,255,255,.3); }
.btn--lacquer { background: var(--grad-lacquer); color: #fff6ef; box-shadow: 0 10px 26px rgba(190,58,43,.4), inset 0 1px 0 rgba(255,255,255,.25); }
.btn--ghost { background: rgba(255,255,255,0.05); color: var(--bone); border: 1px solid var(--line-gold); }
.btn--ghost:hover { background: rgba(255,255,255,0.09); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn__sub { font-size: 11px; font-weight: 600; opacity: .8; }
.btn .play-tri { width: 0; height: 0; border-left: 12px solid currentColor; border-top: 8px solid transparent; border-bottom: 8px solid transparent; }

/* ---- Cards ---- */
.card {
  position: relative; border-radius: var(--r-lg);
  background: var(--felt-card); border: 1px solid var(--line-gold);
  box-shadow: var(--shadow-card); overflow: hidden;
}
.card::before { content:''; position:absolute; inset:0; background-image: var(--banig); pointer-events:none; }
.card > * { position: relative; }

/* ---- Headings ---- */
.h-display { font-family: var(--font-display); font-weight: 800; color: var(--bone-bright); letter-spacing: -.4px; line-height: 1; }
.eyebrow { font-size: 10.5px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--bone-faint); font-weight: 700; }
.muted { color: var(--bone-dim); }
.nums { font-variant-numeric: tabular-nums; }

/* ---- Progress bar (Antas) ---- */
.progress { height: 8px; border-radius: 999px; background: rgba(0,0,0,0.35); overflow: hidden; box-shadow: inset 0 0 0 1px rgba(255,255,255,.05); }
.progress > i { display: block; height: 100%; border-radius: 999px; background: var(--grad-gold-sheen); box-shadow: 0 0 12px rgba(224,164,44,.5); }

/* ---- Segmented control / tabs ---- */
.seg { display: inline-flex; gap: 4px; }
.seg button { padding: 6px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; color: var(--bone-dim); }
.seg button.is-active { color: var(--gold-hi); background: rgba(224,164,44,0.14); box-shadow: inset 0 -2px 0 var(--marigold); border-radius: 10px 10px 4px 4px; }
.seg button:hover:not(.is-active) { color: var(--bone); }

/* ---- Toast ---- */
.toast-host { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 10px 16px; border-radius: 12px; font-size: 13px; font-weight: 600;
  background: rgba(12,40,30,0.95); color: var(--bone-bright); border: 1px solid var(--line-gold-2);
  box-shadow: 0 12px 30px rgba(0,0,0,.5); animation: toastIn .25s ease;
}
.toast--gold { border-color: var(--marigold); box-shadow: 0 0 24px rgba(224,164,44,.4); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---- Portrait rotate gate (landscape-first seated table) ---- */
#rotate-gate { display: none; }
.rotate-gate__parol { position: relative; filter: drop-shadow(0 0 34px rgba(224,164,44,0.45)); }
.rotate-gate__msg { position: relative; font-family: var(--font-display); font-weight: 800; font-size: 24px; color: var(--bone-bright); line-height: 1.25; }
.rotate-gate__msg span { display: block; font-family: var(--font-ui); font-weight: 600; font-size: 14px; color: var(--bone-dim); margin-top: 10px; }

@media (orientation: portrait) and (max-width: 900px) {
  #device { display: none; }
  #rotate-gate {
    display: flex; position: fixed; inset: 0; z-index: 500;
    flex-direction: column; align-items: center; justify-content: center;
    gap: 26px; text-align: center; padding: 32px; background: var(--felt-app);
  }
  #rotate-gate::before { content: ''; position: absolute; inset: 0; background-image: var(--banig); pointer-events: none; }
}

/* Landscape phones: fill the screen edge-to-edge rather than letterboxing */
@media (orientation: landscape) and (max-height: 520px) {
  #app { padding: 0; }
  .device { width: 100%; height: 100dvh; max-width: none; border-radius: 0; aspect-ratio: auto; }
}
@media (max-width: 640px) {
  #app { padding: 0; }
  .device { border-radius: 0; }
}

.fade-in { animation: fadeIn .28s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
