/* Deal or No Deal — game-show styling, responsive, offline, no external assets. */

:root {
  --bg-0: #060b18;
  --bg-1: #0e1c38;
  --bg-2: #16305c;
  --gold: #f6c650;
  --gold-deep: #b8860b;
  --gold-soft: #ffe9a8;
  --red: #e23b3b;
  --red-deep: #8f1d1d;
  --blue: #3aa0ff;
  --green: #29c39a;
  --ink: #eaf0ff;
  --ink-dim: #93a3c4;
  --case-1: #ffd873;
  --case-2: #d99a25;
  --case-edge: #7a5210;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

/* Interactive controls: kill the 300ms tap delay / double-tap zoom. */
button, .btn, .icon-btn, select, input { touch-action: manipulation; }

/* The hidden attribute must always win over author display rules. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% -10%, var(--bg-2), transparent 60%),
    radial-gradient(900px 600px at 50% 120%, #1a2f57, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* Rotating stage spotlights behind everything */
.stage-lights {
  position: fixed;
  inset: -20% -20% auto -20%;
  height: 80vh;
  pointer-events: none;
  background:
    conic-gradient(from 200deg at 50% 0%,
      transparent 0deg,
      rgba(246, 198, 80, 0.05) 20deg,
      transparent 40deg,
      rgba(58, 160, 255, 0.05) 70deg,
      transparent 95deg,
      rgba(246, 198, 80, 0.05) 130deg,
      transparent 160deg);
  z-index: 0;
}

/* ---------- top bar ---------- */
.topbar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(14px + env(safe-area-inset-top, 0px)) clamp(12px, 3vw, 32px) 14px;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-weight: 900;
  letter-spacing: 1px;
  font-size: clamp(22px, 4.5vw, 40px);
}
.logo-deal {
  color: var(--gold);
  text-shadow: 0 0 18px rgba(246, 198, 80, 0.5), 0 2px 0 #5a3d05;
}
.logo-or {
  color: var(--ink-dim);
  font-size: 0.65em;
  letter-spacing: 2px;
  transform: translateY(-0.1em);
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ctl { display: flex; align-items: center; gap: 6px; }
.ctl-label { font-size: 12px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; }

select#langSelect {
  appearance: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 14px;
  cursor: pointer;
}
select#langSelect:focus { outline: 2px solid var(--gold); }
select#langSelect option { color: #111; background: #fff; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.14); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.muted { opacity: 0.5; }

/* ---------- tagline + status ---------- */
.tagline {
  position: relative;
  z-index: 2;
  text-align: center;
  margin: 2px 0 6px;
  color: var(--gold-soft);
  font-size: clamp(13px, 2.4vw, 17px);
  letter-spacing: 0.3px;
}

.status-bar {
  position: relative;
  z-index: 2;
  text-align: center;
  min-height: 44px;
  padding: 4px 12px;
}
.status-main {
  font-size: clamp(15px, 3vw, 20px);
  font-weight: 700;
}
.status-held {
  font-size: 13px;
  color: var(--gold);
  margin-top: 2px;
  min-height: 16px;
}

/* ---------- table layout ---------- */
.table {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(0, 3fr) minmax(120px, 1fr);
  gap: clamp(8px, 2vw, 22px);
  align-items: start;
  padding: 8px clamp(10px, 3vw, 32px) 40px;
  max-width: 1200px;
  margin: 0 auto;
}

/* ---------- money ladders ---------- */
.ladder {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  backdrop-filter: blur(2px);
}
.rung {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 4px;
  border-radius: 8px;
  font-weight: 700;
  font-size: clamp(11px, 1.6vw, 15px);
  letter-spacing: 0.3px;
  background: linear-gradient(180deg, rgba(58, 160, 255, 0.22), rgba(58, 160, 255, 0.08));
  color: #dbe9ff;
  border: 1px solid rgba(58, 160, 255, 0.25);
  transition: opacity 0.35s ease, filter 0.35s ease, transform 0.25s ease;
}
.ladder.right .rung {
  background: linear-gradient(180deg, rgba(246, 198, 80, 0.24), rgba(246, 198, 80, 0.08));
  color: var(--gold-soft);
  border-color: rgba(246, 198, 80, 0.3);
}
.rung.out {
  opacity: 0.22;
  filter: grayscale(0.8);
  text-decoration: line-through;
  transform: scale(0.97);
}
.rung.flash { animation: rungFlash 0.6s ease; }
@keyframes rungFlash {
  0% { transform: scale(1); box-shadow: 0 0 0 rgba(255, 255, 255, 0); }
  40% { transform: scale(1.12); box-shadow: 0 0 22px rgba(255, 255, 255, 0.6); }
  100% { transform: scale(0.97); }
}

/* ---------- case board ---------- */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: clamp(6px, 1.4vw, 12px);
  justify-content: center;
}

.case {
  position: relative;
  aspect-ratio: 5 / 4;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  color: #3a2600;
  font-weight: 900;
  background:
    linear-gradient(160deg, var(--case-1), var(--case-2) 60%, #b47c17);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.6),
    inset 0 -3px 6px rgba(0, 0, 0, 0.3),
    0 4px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.3s ease;
  overflow: hidden;
}
.case::after { /* briefcase handle hint */
  content: "";
  position: absolute;
  top: 6%;
  left: 50%;
  transform: translateX(-50%);
  width: 34%;
  height: 10%;
  border: 2px solid rgba(90, 60, 5, 0.55);
  border-bottom: none;
  border-radius: 8px 8px 0 0;
}
.case .num {
  position: relative;
  z-index: 1;
  font-size: clamp(18px, 3.4vw, 26px);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.case .amt { display: none; }

.case:not(.opened):not(.held):hover { transform: translateY(-3px) scale(1.03); }
.case:not(.opened):not(.held):active { transform: scale(0.96); }

/* Suspense wind-up: shake + swell + glow before the reveal. */
.case.arming {
  cursor: default;
  z-index: 5;
  box-shadow: 0 0 0 3px var(--gold), 0 0 34px rgba(246, 198, 80, 0.95);
  animation: arm 0.6s ease-in-out;
}
@keyframes arm {
  0%   { transform: scale(1) rotate(0deg); }
  12%  { transform: scale(1.07) rotate(-4deg); }
  26%  { transform: scale(1.05) rotate(4deg); }
  40%  { transform: scale(1.10) rotate(-4deg); }
  54%  { transform: scale(1.08) rotate(4deg); }
  70%  { transform: scale(1.14) rotate(-3deg); }
  85%  { transform: scale(1.12) rotate(3deg); }
  100% { transform: scale(1.18) rotate(0deg); }
}

.case.held {
  cursor: default;
  background: linear-gradient(160deg, #fff2c8, #f6c650 60%, #d99a25);
  box-shadow: 0 0 0 3px var(--gold), 0 0 26px rgba(246, 198, 80, 0.7);
  animation: heldPulse 2.2s ease-in-out infinite;
}
@keyframes heldPulse {
  0%, 100% { box-shadow: 0 0 0 3px var(--gold), 0 0 18px rgba(246, 198, 80, 0.5); }
  50% { box-shadow: 0 0 0 3px var(--gold), 0 0 30px rgba(246, 198, 80, 0.9); }
}
.case.held .tag {
  position: absolute;
  bottom: 4px;
  left: 0; right: 0;
  z-index: 1;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #6a4a00;
}

.case.opened {
  cursor: default;
  color: var(--ink);
  background: linear-gradient(160deg, #24304a, #161f31);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  filter: none;
  animation: openFlip 0.45s ease;
}
.case.opened::after { display: none; }
.case.opened .num { display: none; }
.case.opened .amt {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 2px;
  font-size: clamp(11px, 1.8vw, 15px);
  font-weight: 800;
  color: var(--ink-dim);
  text-align: center;
  line-height: 1.05;
}
@keyframes openFlip {
  0% { transform: rotateY(0deg) scale(1); }
  50% { transform: rotateY(90deg) scale(1.06); background: #fff; }
  100% { transform: rotateY(0deg) scale(1); }
}

/* ---------- overlay ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(3, 6, 14, 0.72);
  backdrop-filter: blur(4px);
  animation: fadeIn 0.25s ease;
}
.overlay[hidden] { display: none; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.banker-card {
  position: relative;
  width: min(440px, 94vw);
  text-align: center;
  padding: 26px 22px 22px;
  border-radius: 20px;
  background: linear-gradient(180deg, #1b2b4d, #101a30);
  border: 1px solid rgba(246, 198, 80, 0.3);
  box-shadow: var(--shadow), 0 0 60px rgba(246, 198, 80, 0.15);
  animation: cardIn 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes cardIn {
  from { transform: translateY(24px) scale(0.9); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.banker-icon {
  font-size: 40px;
  margin-bottom: 6px;
  filter: drop-shadow(0 0 12px rgba(226, 59, 59, 0.7));
  animation: ring 0.8s ease-in-out infinite;
}
@keyframes ring {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}
.banker-card.result .banker-icon { animation: none; }

.banker-title {
  font-size: clamp(16px, 3vw, 20px);
  color: var(--ink);
  margin-bottom: 6px;
}
.banker-caption {
  font-size: 12px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--ink-dim);
  min-height: 0;
}
.banker-caption:empty { display: none; }
.banker-offer {
  font-size: clamp(34px, 9vw, 58px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 26px rgba(246, 198, 80, 0.6);
  line-height: 1.1;
  margin: 4px 0;
  min-height: 1.1em;
}
.banker-sub {
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.5;
  margin: 4px 0;
}
/* "Next round: open N cases" heads-up on the Banker's offer. */
.banker-next {
  display: inline-block;
  margin: 8px auto 2px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(246, 198, 80, 0.12);
  border: 1px solid rgba(246, 198, 80, 0.3);
  color: var(--gold-soft);
  font-size: 13px;
  font-weight: 600;
}
.banker-next:empty { display: none; }
.banker-flavor {
  color: var(--ink-dim);
  font-style: italic;
  font-size: 13px;
  min-height: 18px;
  margin: 8px 0 14px;
}

.banker-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}
.btn {
  flex: 1 1 auto;
  min-width: 120px;
  padding: 14px 18px;
  border: none;
  border-radius: 12px;
  font-size: clamp(15px, 3.5vw, 19px);
  font-weight: 900;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.1s ease, filter 0.2s ease;
}
.btn:active { transform: scale(0.95); }
.btn-deal {
  color: #05230f;
  background: linear-gradient(180deg, #4fe6b0, #1a9d78);
  box-shadow: 0 6px 18px rgba(41, 195, 154, 0.4);
}
.btn-nodeal {
  color: #fff;
  background: linear-gradient(180deg, #ff5a5a, #b01f1f);
  box-shadow: 0 6px 18px rgba(226, 59, 59, 0.4);
}
.btn-neutral {
  color: #1a1204;
  background: linear-gradient(180deg, var(--gold-soft), var(--gold));
  box-shadow: 0 6px 18px rgba(246, 198, 80, 0.4);
}
.btn-haggle {
  color: #fff;
  background: linear-gradient(180deg, #8b6cff, #5a3fd6);
  box-shadow: 0 6px 18px rgba(124, 92, 255, 0.45);
}
.btn:hover { filter: brightness(1.08); }

/* ---------- responsive: stack ladders above board on narrow screens ---------- */
@media (max-width: 720px) {
  .table {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "left right"
      "board board";
  }
  #ladderLeft { grid-area: left; }
  #ladderRight { grid-area: right; }
  .board-wrap { grid-area: board; }
  /* Money board = two aligned vertical columns (low | high), classic show layout.
     Both sides have 13 equal-height rungs, so every tier lines up across the gap. */
  .ladder {
    gap: 4px;
    padding: 8px 6px;
  }
  .rung {
    padding: 4px 4px;
    font-size: 12px;
    white-space: nowrap;
  }
  .board {
    grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  }
}

@media (max-width: 400px) {
  .board { grid-template-columns: repeat(5, 1fr); }
}

/* ============ shell: views, header extras ============ */
.view[hidden] { display: none; }
.topbar-left { display: flex; align-items: center; gap: 10px; }

/* jackpot rate badge (lobby, top-right) */
.jackpot-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.05;
  padding: 5px 12px;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(246, 198, 80, 0.18), rgba(246, 198, 80, 0.06));
  border: 1px solid rgba(246, 198, 80, 0.4);
  box-shadow: 0 0 16px rgba(246, 198, 80, 0.15);
  cursor: default;
}
.jp-label {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--gold-soft);
  opacity: 0.85;
}
.jp-pct {
  font-size: 16px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 10px rgba(246, 198, 80, 0.4);
}

/* ============ game as a full-screen screen ============ */
#viewGame.screen {
  position: fixed;
  inset: 0;
  z-index: 15;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
  background:
    radial-gradient(1200px 700px at 50% -10%, var(--bg-2), transparent 60%),
    radial-gradient(900px 600px at 50% 120%, #1a2f57, transparent 55%),
    linear-gradient(180deg, var(--bg-1), var(--bg-0));
  animation: screenIn 0.36s cubic-bezier(0.2, 0.8, 0.25, 1);
}
@keyframes screenIn {
  from { transform: translateX(7%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.game-top {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(12px + env(safe-area-inset-top, 0px))
           max(clamp(12px, 3vw, 28px), env(safe-area-inset-right, 0px))
           12px
           max(clamp(12px, 3vw, 28px), env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(6, 11, 24, 0.92), rgba(6, 11, 24, 0));
}
.game-top-title {
  font-weight: 800;
  font-size: clamp(15px, 3vw, 19px);
  color: var(--gold-soft);
  letter-spacing: 0.5px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

/* ============ lobby ============ */
#viewLobby {
  position: relative;
  z-index: 2;
  max-width: 640px;
  margin: 0 auto;
  padding: 10px clamp(14px, 4vw, 26px) 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.profile-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "avatar meta"
    "stats stats";
  gap: 14px 16px;
  align-items: center;
  padding: 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(30, 47, 82, 0.85), rgba(16, 26, 48, 0.85));
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: var(--shadow);
}

.avatar {
  grid-area: avatar;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 3px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  line-height: 1;
  cursor: pointer;
  background-size: cover;
  background-position: center;
  box-shadow: 0 0 18px rgba(246, 198, 80, 0.4);
  transition: transform 0.12s ease;
  padding: 0;
}
.avatar:hover { transform: scale(1.05); }
.avatar:active { transform: scale(0.96); }
.avatar.avatar-img { color: transparent; }

.profile-meta { grid-area: meta; display: flex; flex-direction: column; gap: 4px; }
.pname {
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 800;
  color: var(--ink);
}
/* wallet-address line under the name (wallet-login accounts only) */
.pwallet {
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.4;
  color: var(--ink-dim);
  word-break: break-all;
  max-width: 100%;
}
.pwallet[hidden] { display: none; }
.pwallet .pw-label { color: var(--gold-soft); }
.link-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--gold);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover { color: var(--gold-soft); }

.profile-stats {
  grid-area: stats;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.stat {
  flex: 1 1 160px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.stat-label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 5px;
}
.stat.wallet .stat-value {
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 16px rgba(246, 198, 80, 0.4);
}
.stamina-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pips { display: flex; gap: 4px; }
.pip {
  width: 16px;
  height: 10px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.pip.on {
  background: linear-gradient(180deg, #4fe6b0, #1a9d78);
  border-color: transparent;
  box-shadow: 0 0 8px rgba(41, 195, 154, 0.6);
}
.stamina-next { font-size: 12px; color: var(--ink-dim); }

/* ---- mode card ---- */
.modes { display: flex; flex-direction: column; gap: 16px; }
.mode-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas:
    "art body"
    "foot foot";
  gap: 12px 18px;
  align-items: center;
  padding: 20px;
  border-radius: 18px;
  background:
    radial-gradient(500px 200px at 100% 0%, rgba(246, 198, 80, 0.12), transparent 70%),
    linear-gradient(180deg, rgba(30, 47, 82, 0.9), rgba(16, 26, 48, 0.9));
  border: 1px solid rgba(246, 198, 80, 0.25);
  box-shadow: var(--shadow);
  transition: border-color 0.2s ease, transform 0.12s ease;
}
.mode-card.locked { opacity: 0.85; border-color: rgba(255, 255, 255, 0.1); }
.mode-art {
  grid-area: art;
  width: 68px;
  height: 68px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  background: linear-gradient(160deg, #ffd873, #d99a25);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.5), 0 6px 16px rgba(0, 0, 0, 0.4);
}
.mode-body { grid-area: body; }
.mode-title { margin: 0 0 4px; font-size: clamp(18px, 4vw, 23px); color: var(--ink); }
.mode-desc { margin: 0 0 10px; font-size: 13px; color: var(--ink-dim); line-height: 1.4; }
.mode-cost { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
}
.chip-ticket b { color: var(--gold); }
.chip-energy { color: #7fe6c6; }

.mode-foot { grid-area: foot; display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.play-btn { width: 100%; padding: 15px; font-size: 18px; }
.play-reason { min-height: 16px; text-align: center; font-size: 12px; color: var(--red); }

/* Grand Prix mode card */
.mode-grand {
  border-color: rgba(246, 198, 80, 0.5);
  background:
    radial-gradient(500px 200px at 100% 0%, rgba(246, 198, 80, 0.22), transparent 70%),
    linear-gradient(180deg, rgba(44, 36, 64, 0.92), rgba(22, 17, 36, 0.94));
}
.mode-grand .mode-art { background: linear-gradient(160deg, #ffe9a8, #e0a52a); box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), 0 6px 18px rgba(224, 165, 42, 0.4); }
.mode-grand .mode-title { color: var(--gold-soft); }
.gp-status { margin-top: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; color: var(--ink-dim); }
.gp-status.open { color: #4fe6b0; }

/* ---- wallet leaderboard ---- */
.leaderboard {
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(30, 47, 82, 0.8), rgba(16, 26, 48, 0.8));
  border: 1px solid rgba(246, 198, 80, 0.22);
  box-shadow: var(--shadow);
}
/* Transparent on mobile (no box); becomes the scroll frame on PC (see min-width:900). */
.lb-inner { display: contents; }
.lb-title { margin: 0 0 12px; font-size: clamp(16px, 4vw, 20px); color: var(--gold-soft); }
.lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.lb-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.24);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.lb-rank {
  min-width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 800;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}
.lb-row.top1 .lb-rank { background: linear-gradient(180deg, #ffe9a8, #f6c650); color: #1a1204; box-shadow: 0 0 12px rgba(246, 198, 80, 0.5); }
.lb-row.top2 .lb-rank { background: linear-gradient(180deg, #e8eef7, #b9c4d6); color: #1a1204; }
.lb-row.top3 .lb-rank { background: linear-gradient(180deg, #f0b483, #cd7f45); color: #1a1204; }
.lb-row.me { border-color: rgba(246, 198, 80, 0.55); background: rgba(246, 198, 80, 0.1); }
.lb-name { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-amt { font-weight: 800; color: var(--gold); white-space: nowrap; }
.lb-empty { color: var(--ink-dim); font-size: 13px; padding: 8px 2px; }

/* ============ modals ============ */
.modal-card {
  width: min(440px, 94vw);
  padding: 24px 22px;
  border-radius: 20px;
  background: linear-gradient(180deg, #1b2b4d, #101a30);
  border: 1px solid rgba(246, 198, 80, 0.3);
  box-shadow: var(--shadow), 0 0 60px rgba(246, 198, 80, 0.12);
  animation: cardIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.modal-title { margin: 0 0 16px; text-align: center; color: var(--ink); }
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-bottom: 8px;
}
.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-size: 16px;
}
.text-input:focus { outline: 2px solid var(--gold); }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.avatar-opt {
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
  font-size: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background-size: cover;
  background-position: center;
  transition: transform 0.1s ease;
  padding: 0;
}
.avatar-opt:hover { transform: scale(1.08); }
.avatar-opt.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(246, 198, 80, 0.4), 0 0 14px rgba(246, 198, 80, 0.6);
}
.avatar-opt.avatar-img { color: transparent; }

.upload-btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: var(--ink);
  font-size: 13px;
  cursor: pointer;
}
.upload-btn:hover { background: rgba(255, 255, 255, 0.14); }

.modal-actions { display: flex; gap: 12px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* ---- haggle picker ---- */
.haggle-ref { color: var(--ink-dim); font-size: 14px; margin: 2px 0 14px; }
.haggle-ref b { color: var(--gold); }
.haggle-presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 14px; }
.preset {
  flex: 1 1 90px;
  min-width: 84px;
  padding: 10px 8px;
  border-radius: 12px;
  border: 1px solid rgba(139, 108, 255, 0.5);
  background: rgba(139, 108, 255, 0.12);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: transform 0.1s ease, background 0.2s ease;
}
.preset:hover { background: rgba(139, 108, 255, 0.22); }
.preset:active { transform: scale(0.95); }
.preset.active {
  border-color: #8b6cff;
  background: rgba(139, 108, 255, 0.30);
  box-shadow: 0 0 0 2px rgba(139, 108, 255, 0.4);
}
.preset .mult { font-size: 15px; font-weight: 800; color: #b9a6ff; }
.preset .amt { font-size: 12px; color: var(--ink-dim); }

.haggle-custom { text-align: left; margin-bottom: 4px; }
.haggle-custom .field-label { text-align: left; }
.haggle-input-row { display: flex; align-items: center; gap: 6px; margin-top: 6px; }
.haggle-input-row .cur { color: var(--gold); font-weight: 800; font-size: 18px; }
.haggle-input-row .text-input { flex: 1; }
.haggle-hint { min-height: 16px; margin-top: 6px; font-size: 12px; color: var(--red); text-align: left; }

/* confirm dialog (ticket / leave): looser vertical rhythm */
#confirmModal .banker-icon { margin-bottom: 12px; }
#confirmModal .banker-title { margin-bottom: 10px; font-size: clamp(18px, 3.4vw, 22px); }
#confirmModal .banker-sub { margin: 0 auto; max-width: 30ch; }
#confirmModal .banker-actions { margin-top: 22px; }

/* ============ auth (login / register) ============ */
.auth-view {
  position: relative;
  z-index: 2;
  min-height: 72vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  width: min(400px, 94vw);
  padding: 28px 26px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(30, 47, 82, 0.9), rgba(16, 26, 48, 0.92));
  border: 1px solid rgba(246, 198, 80, 0.28);
  box-shadow: var(--shadow), 0 0 60px rgba(246, 198, 80, 0.12);
  text-align: center;
}
.auth-logo { justify-content: center; margin-bottom: 10px; }
.auth-welcome { color: var(--ink-dim); font-size: 14px; margin: 0 0 20px; line-height: 1.5; }
.auth-card .field { text-align: left; margin-bottom: 14px; }
.auth-error { min-height: 18px; color: var(--red); font-size: 13px; margin: 2px 0 12px; }
.auth-card .btn { width: 100%; }
.auth-card .link-btn { display: inline-block; margin-top: 14px; }

/* ============ game rules ============ */
.rules-card { width: min(470px, 94vw); max-height: 82vh; overflow-y: auto; }
.rules-list { list-style: none; margin: 4px 0 8px; padding: 0; text-align: left; }
.rules-list li {
  font-size: 14px;
  line-height: 1.55;
  color: var(--ink);
  padding: 9px 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.rules-list li:last-child { border-bottom: none; }

/* ============ wallet sign-in ============ */
.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 16px 0 12px;
}
.auth-or::before, .auth-or::after { content: ""; flex: 1; height: 1px; background: rgba(255, 255, 255, 0.12); }
.wallet-btn {
  width: 100%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(246, 198, 80, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.wallet-btn:hover { background: rgba(255, 255, 255, 0.12); filter: none; }
.wallet-btn .w-ico { font-size: 18px; }

.wallet-list { display: flex; flex-direction: column; gap: 8px; margin: 6px 0 4px; }
.wallet-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}
.wallet-opt:hover { background: rgba(255, 255, 255, 0.12); }
.wallet-opt:active { transform: scale(0.98); }
.wallet-opt img { width: 28px; height: 28px; border-radius: 6px; }
.wallet-opt .w-ico { font-size: 22px; }

/* ============ banker offer history ============ */
.offer-history {
  position: relative;
  z-index: 2;
  max-width: 900px;
  margin: 0 auto 10px;
  padding: 0 clamp(10px, 3vw, 32px);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.oh-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-dim); }
.oh-list { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.oh-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 13px;
  color: var(--ink-dim);
}
.oh-chip .oh-round {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink);
}
.oh-chip .oh-amt { font-weight: 700; }
.oh-chip.latest { border-color: var(--gold); background: rgba(246, 198, 80, 0.15); }
.oh-chip.latest .oh-amt { color: var(--gold); }
.oh-chip.latest .oh-round { background: var(--gold); color: #1a1204; }

/* ============ peek (hide offer to view the board) ============ */
.peek-hide {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}
.peek-hide[hidden] { display: none; }
.peek-hide:hover { background: rgba(255, 255, 255, 0.16); }
.peek-hide:active { transform: scale(0.9); }

.peek-bar {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 22px;
  border-radius: 999px;
  background: linear-gradient(180deg, #1b2b4d, #101a30);
  border: 1px solid rgba(246, 198, 80, 0.5);
  box-shadow: var(--shadow), 0 0 30px rgba(246, 198, 80, 0.2);
  color: var(--ink);
  font-size: 15px;
  cursor: pointer;
  animation: peekBarIn 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
.peek-bar[hidden] { display: none; }
.peek-bar:hover { border-color: var(--gold); }
.peek-bar-icon { font-size: 18px; }
.peek-bar-text b { color: var(--gold); font-weight: 800; }
@keyframes peekBarIn {
  from { transform: translateX(-50%) translateY(16px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

/* ============ toast ============ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%) translateY(12px);
  z-index: 40;
  max-width: 90vw;
  padding: 12px 20px;
  border-radius: 12px;
  background: rgba(20, 30, 54, 0.96);
  border: 1px solid rgba(246, 198, 80, 0.4);
  color: var(--ink);
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast[hidden] { display: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 480px) {
  .profile-card { grid-template-columns: auto 1fr; }
  .mode-card { grid-template-columns: 1fr; grid-template-areas: "art" "body" "foot"; justify-items: center; text-align: center; }
  .mode-cost { justify-content: center; }
}

/* ============================================================
   Mobile adaptation — touch, notches, small & landscape screens
   ============================================================ */

/* On touch devices, cancel :hover states that would otherwise
   "stick" after a tap (most visibly the briefcase lift). */
@media (hover: none) {
  .case:not(.opened):not(.held):hover { transform: none; }
  .avatar:hover,
  .avatar-opt:hover,
  .preset:hover { transform: none; }
  .btn:hover { filter: none; }
  .icon-btn:hover,
  .upload-btn:hover,
  .wallet-opt:hover,
  .peek-hide:hover { background: rgba(255, 255, 255, 0.06); }
  .link-btn:hover { color: var(--gold); }
  .peek-bar:hover { border-color: rgba(246, 198, 80, 0.5); }
}

/* Phones — compact the header so logo + controls sit on one tidy row. */
@media (max-width: 560px) {
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .topbar-controls { gap: 8px; }
  .ctl-label { display: none; }            /* the "LANGUAGE" caption eats width */
  select#langSelect { font-size: 16px; padding: 8px 9px; } /* 16px stops iOS zoom-on-focus */
  .jackpot-badge { padding: 4px 9px; }
  .jp-pct { font-size: 15px; }
  .game-top-title { font-size: 15px; }
}

/* Small phones — five briefcases per row. */
@media (max-width: 480px) {
  .board { grid-template-columns: repeat(5, 1fr); gap: 7px; }
}

/* Very small phones. */
@media (max-width: 360px) {
  .logo { font-size: 20px; gap: 6px; }
  .board { gap: 6px; }
  .rung { font-size: 11px; }
  .banker-offer { font-size: clamp(30px, 12vw, 44px); }
}

/* Landscape phones — reclaim vertical space inside the game screen. */
@media (max-height: 480px) and (orientation: landscape) {
  .tagline { display: none; }
  .status-bar { min-height: 0; padding: 2px 12px; }
  .status-held { min-height: 0; }
  .game-top { padding-top: calc(8px + env(safe-area-inset-top, 0px)); padding-bottom: 8px; }
  #viewGame.screen { padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
  .offer-history { margin-bottom: 6px; }
  .table { padding-top: 4px; padding-bottom: 24px; }
  .banker-card { padding-top: 18px; }
  .banker-icon { font-size: 30px; margin-bottom: 2px; }
  .banker-offer { font-size: clamp(28px, 7vw, 46px); }
}

/* ============================================================
   PC lobby — dashboard grid (>= 900px). Phones/tablets keep the
   stacked column above; only wide screens get this layout.
   Player status becomes a top HUD bar, the two game modes are the
   side-by-side centerpiece, and the leaderboard is a right-hand rail.
   ============================================================ */
@media (min-width: 900px) {
  #viewLobby {
    max-width: 1200px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    grid-template-areas:
      "profile     leaderboard"
      "modes       leaderboard";
    gap: 20px;
    align-items: start;
    padding: 18px clamp(20px, 4vw, 40px) 56px;
  }

  /* Player status compressed into a horizontal HUD bar. */
  .profile-card {
    grid-area: profile;
    grid-template-columns: auto 1fr auto;
    grid-template-areas: "avatar meta stats";
    gap: 8px 22px;
    align-items: center;
  }
  .profile-stats { grid-area: stats; flex-wrap: nowrap; gap: 12px; }
  .profile-stats .stat { flex: 0 0 auto; min-width: 150px; }

  /* The two game modes are the centerpiece — side by side, equal height,
     each with its PLAY button pinned to the bottom. */
  .modes {
    grid-area: modes;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 18px;
  }
  .mode-card { grid-template-rows: 1fr auto; }

  /* Leaderboard rail: its height tracks the HUD + game cards (the left column).
     The inner frame is absolutely positioned so the ranking list no longer
     inflates the grid rows — a growing roster scrolls inside the rail instead.
     .leaderboard stretches to fill the two spanned rows; .lb-inner fills it. */
  .leaderboard {
    grid-area: leaderboard;
    align-self: stretch;
    position: relative;
    overflow: hidden;
    padding: 0;
  }
  .leaderboard .lb-inner {
    display: flex;
    flex-direction: column;
    position: absolute;
    inset: 0;
    padding: 18px 20px;
  }
  .leaderboard .lb-title { flex: 0 0 auto; }
  .lb-list {
    gap: 7px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-width: thin;
    scrollbar-color: rgba(246, 198, 80, 0.4) rgba(0, 0, 0, 0.25);
  }
  .lb-list::-webkit-scrollbar { width: 8px; }
  .lb-list::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.22); border-radius: 8px; }
  .lb-list::-webkit-scrollbar-thumb { background: rgba(246, 198, 80, 0.35); border-radius: 8px; }
  .lb-list::-webkit-scrollbar-thumb:hover { background: rgba(246, 198, 80, 0.55); }
}
