:root {
  --bg: #071208;
  --panel: #102014dd;
  --panel-2: #16321c;
  --line: #2d4a32;
  --text: #e8f0ea;
  --muted: #8aa094;
  --emerald: #3dff9a;
  --emerald-dim: #1a7a4a;
  --gold: #e7c56a;
  --danger: #ff5d6c;
  --accent: #7cf0c2;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; height: 100dvh; }
body {
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    linear-gradient(180deg, rgba(4,10,6,0.42) 0%, rgba(4,10,6,0.28) 40%, rgba(4,8,6,0.55) 100%),
    url("lobby-bg.jpg") center / cover no-repeat fixed;
  color: var(--text);
  overflow: auto;
  touch-action: manipulation;
  -ms-touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.side, input, select, textarea, .btn { touch-action: manipulation; -webkit-user-select: text; user-select: text; }
input, select, textarea {
  pointer-events: auto !important;
  touch-action: manipulation !important;
  -webkit-user-select: text !important;
  user-select: text !important;
  font-size: 16px;
  min-height: 44px;
  width: 100%;
}
input[type=checkbox] {
  width: 22px;
  height: 22px;
  min-height: 22px;
  width: 22px;
}
label.row, label.tiny { pointer-events: auto; z-index: 7; position: relative; }

.app {
  display: grid;
  grid-template-columns: 300px 1fr minmax(380px, 440px);
  height: 100%;
  height: 100dvh;
}
.mobile-bar { display: none; }
.touch-ui { display: none; }

.side {
  background:
    linear-gradient(180deg, rgba(8, 18, 10, 0.62) 0%, rgba(6, 12, 8, 0.68) 100%);
  backdrop-filter: blur(8px);
  border-right: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
}
.side.right { border-right: 0; border-left: 1px solid var(--line); }

.brand {
  display: flex; align-items: center; gap: 10px; margin-bottom: 18px;
}
.brand.compact { margin-bottom: 0; }
.brand.compact strong { letter-spacing: 0.06em; font-size: 14px; }
.logo {
  width: 42px; height: 42px; border-radius: 12px;
  background: conic-gradient(from 120deg, #3dff9a, #0b3, #e7c56a, #3dff9a);
  display: grid; place-items: center; font-weight: 800; color: #04120a;
}
.logo-img {
  width: 48px; height: 48px; border-radius: 12px;
  object-fit: cover; background: #0b120c;
  border: 1px solid #e7c56a;
  flex-shrink: 0;
}
.brand h1 { font-size: 20px; letter-spacing: 0.08em; }
.brand p { color: var(--muted); font-size: 12px; }

.card {
  background: rgba(10, 22, 14, 0.72);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 12px;
}
.card h2 { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }

.btn, select, input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
}
.btn { cursor: pointer; font-weight: 700; }
.btn.primary { background: var(--emerald); color: #05210f; border-color: #8fffc4; }
.btn.gold { background: var(--gold); color: #2a2108; border-color: #ffe09a; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

.tiers { display: grid; gap: 8px; }
.tier {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.tier.active { border-color: var(--emerald); box-shadow: 0 0 0 1px var(--emerald) inset; }
.tier b { color: var(--emerald); }

.skins { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.skin-preview {
  width: 100%;
  height: 140px;
  margin: 10px 0 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #07140c;
  display: block;
}
.skin {
  height: 38px; border-radius: 999px; border: 2px solid transparent; cursor: pointer;
}
.skin.sel { border-color: #fff; }

.arena-wrap {
  position: relative;
  background:
    linear-gradient(180deg, rgba(4,10,6,0.2), rgba(4,10,6,0.35)),
    url("lobby-bg.jpg") center / cover no-repeat;
}
#arena { width: 100%; height: 100%; display: block; background: #000; pointer-events: none; }
.app.playing #arena { pointer-events: auto; }
.hud {
  display: none;
  position: absolute; inset: 12px auto auto 12px;
  background: rgba(8,12,10,0.72); border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 12px; min-width: 220px;
}
.app.playing .hud { display: block; }
.hud .stat { display: flex; justify-content: space-between; gap: 16px; font-size: 13px; color: var(--muted); }
.hud .stat b { color: var(--text); }

.toast {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%);
  background: #0f1c16; border: 1px solid var(--emerald-dim); color: var(--accent);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; display: none;
}
.app:not(.playing) .queue-banner { display: none !important; }
.queue-banner {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  z-index: 12;
  background: rgba(8,16,12,0.86);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px;
  white-space: nowrap;
}
.killcam-tag {
  position: absolute; left: 50%; top: 56px; transform: translateX(-50%);
  z-index: 13;
  background: #ff5d6c;
  color: #140406;
  font-weight: 800;
  letter-spacing: 0.12em;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.hidden, .killcam-tag.hidden, #watch-ui.hidden { display: none !important; }

.overlay {
  position: fixed; inset: 0; z-index: 35; display: grid; place-items: center;
  background: rgba(4,8,6,0.72); backdrop-filter: blur(4px);
}
.overlay.hidden { display: none; }
#coil-page { position: fixed; inset: 0; z-index: 30; }
.coil-modal { max-width: 420px; width: min(92vw, 420px); }
.coil-stage {
  position: relative;
  height: 240px;
  margin: 14px 0;
  background: #07140c;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.coil-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.charmer { position: absolute; left: 18px; bottom: 16px; font-size: 42px; transition: transform 0.3s; }
.charmer.play { animation: charm 0.6s ease-in-out infinite; }
@keyframes charm { 50% { transform: rotate(-12deg) translateY(-4px); } }
.coil-pot-art { position: absolute; right: 36px; bottom: 12px; font-size: 56px; }
.coil-snake {
  position: absolute; left: 0; right: 0; bottom: 10px; text-align: center;
  font-size: 20px; color: var(--gold); font-weight: 700;
  text-shadow: 0 2px 8px #000;
}
@keyframes rise { from { transform: translateY(70px); opacity: 0; } to { transform: translateY(-28px); opacity: 1; } }

.app.waiting-intro { visibility: hidden; }
.intro {
  position: fixed; inset: 0; z-index: 40;
  background: #030806;
  display: grid; place-items: center;
}
.intro.gone {
  display: none !important;
  opacity: 0; pointer-events: none;
}
.intro video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  background: #030806;
}
.intro-copy {
  position: absolute; left: 50%; bottom: 7%;
  transform: translateX(-50%);
  text-align: center; letter-spacing: 0.18em;
  pointer-events: none;
  text-shadow: 0 2px 16px #000, 0 0 24px #0a2010;
}
.intro-copy strong { display: block; font-size: 36px; color: #e7c56a; }
.intro-copy span { color: #d7efe4; font-size: 13px; letter-spacing: 0.2em; text-transform: uppercase; }
.intro-skip {
  position: absolute; top: 16px; right: 16px; z-index: 50;
  background: transparent; color: #c9dcc8; border: 1px solid #355;
  border-radius: 999px; padding: 8px 14px; cursor: pointer; font: inherit;
}
.sheet-x {
  float: right;
  width: 44px; height: 44px; border-radius: 10px;
  background: #1a281c; color: #e8f0ea; border: 1px solid var(--line);
  font-size: 20px;
}
.modal {
  width: min(440px, 92%); background: #101810; border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; text-align: center;
}
.modal h3 { margin-bottom: 8px; }
.modal p { color: var(--muted); margin-bottom: 14px; font-size: 14px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 0; border-bottom: 1px solid #1c2620; }
th { color: var(--muted); font-weight: 600; }

.tiny { font-size: 11px; color: var(--muted); margin-top: 8px; line-height: 1.4; }
.addr { font-family: ui-monospace, monospace; font-size: 11px; word-break: break-all; color: var(--gold); }

.boost-btn {
  width: 92px; height: 92px; border-radius: 50%;
  border: 3px solid #ffe09a;
  background: rgba(231, 197, 106, 0.92);
  color: #2a2108; font-weight: 800; letter-spacing: 0.06em;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.boost-btn.held { transform: scale(0.94); background: #fff1b3; }

@media (max-width: 980px) {
  body { overflow: auto; touch-action: pan-x pan-y pinch-zoom; }
  .mobile-bar { display: none !important; }
  .app {
    grid-template-columns: 280px 1fr 340px;
    grid-template-rows: 1fr;
    width: 1100px;
    height: 720px;
    transform-origin: top left;
  }
  .side {
    max-height: 720px;
    padding: 12px;
    -webkit-overflow-scrolling: touch;
    order: unset;
    z-index: 6;
  }
  .arena-wrap { order: unset; }
  .side.right { order: unset; }
  .app.playing {
    width: 100vw;
    height: 100dvh;
    transform: none !important;
    grid-template-columns: 1fr;
  }
  .app.playing .mobile-bar,
  .app.playing .side { display: none; }
  .app.playing .arena-wrap { height: 100dvh; }
  .hud {
    inset: calc(8px + env(safe-area-inset-top)) auto auto 8px;
    min-width: 160px; padding: 8px 10px; font-size: 12px;
  }
  .hud .btn { padding: 12px; }
  .touch-ui {
    display: none;
    position: absolute;
    inset: 0;
    width: auto;
    height: auto;
    z-index: 8;
    pointer-events: none;
  }
  .app.playing .touch-ui { display: block; }
  .stick {
    pointer-events: auto;
    position: absolute;
    left: calc(18px + env(safe-area-inset-left));
    bottom: calc(20px + env(safe-area-inset-bottom));
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(8, 18, 12, 0.55);
    border: 2px solid #e7c56a88;
  }
  .stick-knob {
    position: absolute;
    left: 50%; top: 50%;
    width: 48px; height: 48px;
    margin: -24px 0 0 -24px;
    border-radius: 50%;
    background: #e7c56a;
  }
  .boost-btn {
    pointer-events: auto;
    position: absolute;
    right: calc(16px + env(safe-area-inset-right));
    bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .toast { top: calc(12px + env(safe-area-inset-top)); max-width: 90%; text-align: center; }
  .queue-banner { display: none !important; }
  .intro-skip { min-height: 48px; font-size: 16px; }
}

@media (pointer: coarse) {
  .btn, select, .tier { min-height: 44px; }
  .skin { height: 44px; }
}

.wallet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}
.wallet-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
}
.wallet-btn small { color: var(--muted); font-size: 11px; }
.wallet-btn.on { border-color: var(--gold); box-shadow: 0 0 0 1px #e7c56a55; }
.wallet-btn:hover { border-color: var(--emerald-dim); }

.rank-card { font-size: 13px; line-height: 1.45; }
.rank-card b { color: var(--gold); display: block; font-size: 15px; margin-bottom: 4px; }
.rank-bar { height: 7px; background: #0c1810; border-radius: 99px; overflow: hidden; margin: 6px 0; }
.rank-bar i { display: block; height: 100%; background: linear-gradient(90deg, #1a7a4a, #e7c56a); width: 0; }
.chat-log {
  height: min(48vh, 460px);
  min-height: 280px;
  overflow: auto;
  background: rgba(6,12,8,0.55);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  font-size: 16px;
  line-height: 1.55;
}
.chat-line { margin-bottom: 10px; word-wrap: break-word; }
.chat-line .who { color: var(--gold); }
.chat-line.sys { color: var(--muted); font-style: italic; }
.chat-line.tip { color: #e7c56a; }
.chat-line.tip .who { color: #3dff9a; }
.emoji-bar { display: flex; flex-wrap: wrap; gap: 4px; }
.emoji-bar button {
  background: #0c1810; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 6px; cursor: pointer; font-size: 16px; line-height: 1; color: var(--text);
}
.emoji-bar button:hover { border-color: var(--gold); }
.emoji-bar img, .chat-xrp { width: 16px; height: 16px; vertical-align: -3px; }
.chat-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.chat-form input { width: 100%; min-height: 56px; font-size: 16px; padding: 14px 14px; }
.chat-form .btn { min-height: 44px; width: 100%; }
.board-wrap { overflow-x: auto; margin-top: 8px; }
.board-wrap table { min-width: 420px; font-size: 12px; }
.board-wrap th, .board-wrap td { padding: 6px 6px; white-space: nowrap; }
.live-px { color: var(--gold); font-variant-numeric: tabular-nums; }

.news-list { max-height: 280px; overflow: auto; }
.news-item { display: block; padding: 8px 0; border-bottom: 1px solid #1c2620; text-decoration: none; color: var(--text); }
.news-item:hover { color: var(--gold); }
.news-item strong { display: block; font-size: 13px; line-height: 1.3; }
.news-item span { color: var(--muted); font-size: 11px; }

.slots-reels { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 10px 0; }
.reel {
  height: 56px; display: grid; place-items: center;
  background: #0a120c; border: 1px solid var(--line); border-radius: 10px;
  font-size: 26px;
}
.reel.win { border-color: var(--gold); box-shadow: 0 0 0 1px #e7c56a66; }

.rank-modal {
  text-align: left;
  width: min(96vw, 440px);
  max-height: 92dvh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.rank-ladder { margin-top: 8px; }
.rank-row {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #1c2620;
  font-size: 13px;
}
.rank-row.have { color: #8aa094; }
.rank-row.now { color: var(--gold); font-weight: 700; }
.rank-row.wait { color: var(--text); }

.chal-banner {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translateX(-50%);
  z-index: 40;
  width: min(520px, 92%);
  background: #101c14;
  border: 2px solid var(--gold);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 12px 40px #0008;
}
.chal-banner.hidden { display: none; }
.chal-banner p { margin: 0; font-size: 15px; line-height: 1.35; }
.chal-actions { display: flex; gap: 8px; flex-shrink: 0; }
.chal-yes, .chal-no {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  font-size: 22px; cursor: pointer; color: #041006; font-weight: 800;
}
.chal-yes { background: #3dff9a; }
.chal-no { background: #ff5d6c; color: #fff; }
