:root {
  --bg0: #0a1016;
  --panel: #111f29;
  --panel2: #0d1a23;
  --tile-top: #294453;
  --tile-bot: #1a3140;
  --tile-edge: #39596c;
  --edge: #1d3240;
  --teal: #16e0c6;
  --teal2: #0cae9a;
  --gold: #ffce5a;
  --gold2: #f0a93a;
  --green: #22d781;
  --red: #ff4d61;
  --text: #eaf4f3;
  --muted: #7795a1;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text); min-height: 100vh;
  font-family: "Inter", ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  background:
    radial-gradient(1000px 560px at 85% -12%, #142a34 0%, transparent 55%),
    var(--bg0);
  -webkit-font-smoothing: antialiased;
}
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 60; }

.wrap { max-width: 920px; margin: 0 auto; padding: 22px 18px 56px; }

/* ---------- header ---------- */
header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 24px; width: 46px; height: 46px; display: grid; place-items: center;
  background: linear-gradient(180deg, #16323f, #0e2029);
  border: 1px solid var(--edge); border-radius: 12px;
}
h1 { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: 2px; }
h1 span { color: var(--teal); }

.hdr-actions { display: flex; align-items: center; gap: 10px; }
.fairbtn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  background: var(--panel); border: 1px solid var(--edge); color: var(--muted);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; font-size: 13px;
  transition: color .15s, border-color .15s;
}
.fairbtn:hover { color: var(--teal); border-color: var(--teal); }
.iconbtn {
  display: grid; place-items: center; cursor: pointer; width: 38px; height: 38px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 10px;
  font-size: 15px; line-height: 1; transition: border-color .15s;
}
.iconbtn:hover { border-color: var(--teal); }
.iconbtn.muted { opacity: .55; }

/* ---------- layout ---------- */
.game { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
@media (max-width: 700px) { .game { grid-template-columns: 1fr; } }

.panel, .boardcard {
  background: var(--panel); border: 1px solid var(--edge); border-radius: var(--radius);
}
.panel { padding: 16px; display: flex; flex-direction: column; gap: 13px; }

.field label, .box label, .multi label {
  display: block; font-size: 10.5px; letter-spacing: .6px; color: var(--muted);
  font-weight: 600; margin-bottom: 7px; text-transform: uppercase;
}
.betfixed {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--edge); border-radius: 10px; padding: 11px 12px;
}
.betfixed .cur { color: var(--muted); font-weight: 700; }
.betfixed .amt { flex: 1; color: var(--text); font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.betfixed .lock { opacity: .6; font-size: 12px; }

.splitstat { display: flex; gap: 11px; }
.box { flex: 1; background: var(--panel2); border: 1px solid var(--edge); border-radius: 10px; padding: 9px 12px; }
.box b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; }

.multi {
  background: radial-gradient(120% 140% at 50% 0%, rgba(22,224,198,.1), transparent 62%), var(--panel2);
  border: 1px solid var(--edge); border-radius: 12px; padding: 16px 14px; text-align: center;
}
.multi .big {
  font-size: 38px; font-weight: 900; letter-spacing: .5px; color: var(--teal);
  font-variant-numeric: tabular-nums; line-height: 1.05; text-shadow: 0 0 22px rgba(22,224,198,.3);
}
.multi .next { margin-top: 7px; display: flex; justify-content: center; gap: 8px; align-items: baseline; color: var(--muted); font-size: 12px; }
.multi .next b { color: var(--text); font-variant-numeric: tabular-nums; }

.btn {
  border: none; border-radius: 11px; padding: 14px; font: inherit; font-weight: 800;
  letter-spacing: .3px; cursor: pointer; font-size: 14px; color: #06161a;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, filter .15s;
}
.btn em { font-style: normal; font-weight: 700; opacity: .8; font-variant-numeric: tabular-nums; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--teal), var(--teal2)); }
.btn.cash { background: linear-gradient(180deg, var(--gold), var(--gold2)); }
.btn:hover:not(:disabled) { filter: brightness(1.05); }
.btn:disabled { opacity: .38; cursor: default; }

.msg { text-align: center; min-height: 16px; margin: 0; font-weight: 700; font-size: 12.5px; }
.msg.win { color: var(--green); }
.msg.bust { color: var(--red); }

/* ---------- board ---------- */
.boardcard { position: relative; padding: 16px; }
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 11px; }
.tile { aspect-ratio: 1 / 1; border: none; background: transparent; padding: 0; cursor: pointer; perspective: 600px; }
.tile .inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .35s cubic-bezier(.2,.8,.3,1.2); }
.tile.revealed .inner { transform: rotateY(180deg); }
.face { position: absolute; inset: 0; border-radius: 12px; display: grid; place-items: center; backface-visibility: hidden; font-size: clamp(24px, 6.6vw, 38px); }
.front {
  background: linear-gradient(180deg, var(--tile-top), var(--tile-bot));
  border: 1px solid var(--tile-edge);
  box-shadow: inset 0 2px 0 rgba(255,255,255,.07), 0 5px 12px rgba(0,0,0,.3);
  color: rgba(180,220,230,.18); font-size: 18px;
}
.tile:hover:not(.revealed) .front { filter: brightness(1.12); transform: translateY(-2px); transition: transform .1s, filter .1s; }
.back { transform: rotateY(180deg); }
.back.gem { background: radial-gradient(circle at 50% 38%, #1c6a58, #0e2a26); border: 1px solid var(--green); box-shadow: inset 0 0 20px rgba(34,215,129,.22); }
.back.mine { background: radial-gradient(circle at 50% 38%, #6a1c28, #2a0e14); border: 1px solid var(--red); box-shadow: inset 0 0 20px rgba(255,77,97,.28); }
.back.ghost { opacity: .35; filter: grayscale(.3); }
.tile.hit .back.mine { animation: shake .4s ease; box-shadow: inset 0 0 0 2px var(--red), 0 0 24px rgba(255,77,97,.55); }
@keyframes shake { 0%,100%{transform:rotateY(180deg) translateX(0)} 20%{transform:rotateY(180deg) translateX(-5px)} 60%{transform:rotateY(180deg) translateX(5px)} }
.back.gem.sparkle { animation: sparkle .5s ease; }
@keyframes sparkle { 0%{transform:rotateY(180deg) scale(.8)} 55%{transform:rotateY(180deg) scale(1.12)} 100%{transform:rotateY(180deg) scale(1)} }

.banner {
  position: absolute; inset: 12px; border-radius: 12px; display: grid; place-items: center;
  text-align: center; padding: 20px; background: rgba(8,15,20,.86); backdrop-filter: blur(4px);
  border: 1px solid var(--edge); animation: fade .3s ease;
}
.banner.hidden { display: none; }
.banner.winbanner { border-color: var(--gold); }
.banner h3 { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
.banner.winbanner h3 { color: var(--gold); text-shadow: 0 0 18px rgba(255,206,90,.45); }
.banner.bustbanner h3 { color: var(--red); }
.banner .sub { color: var(--muted); font-size: 13px; }
.banner .flag {
  margin-top: 12px; font-family: ui-monospace, Menlo, monospace; color: var(--gold);
  background: #06161a; border: 1px solid var(--gold); padding: 10px 14px; border-radius: 9px;
  word-break: break-all; font-size: 13.5px;
}
.banner .again {
  margin-top: 14px; border: 1px solid var(--edge); background: transparent; color: var(--muted);
  padding: 8px 16px; border-radius: 9px; font: inherit; font-weight: 700; font-size: 12.5px; cursor: pointer;
}
.banner .again:hover { color: var(--text); border-color: var(--teal); }
@keyframes fade { from{opacity:0; transform:scale(.98)} to{opacity:1; transform:scale(1)} }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px;
  background: rgba(5,10,14,.6); backdrop-filter: blur(5px); animation: fade .2s ease; }
.modal.hidden { display: none; }
.modal-card {
  position: relative; width: 100%; max-width: 560px; max-height: 84vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 16px; padding: 24px;
  box-shadow: 0 24px 70px rgba(0,0,0,.5);
}
.modal-card h2 { margin: 0 0 12px; font-size: 19px; }
.modal-close {
  position: absolute; top: 14px; right: 14px; width: 32px; height: 32px; border-radius: 9px;
  border: 1px solid var(--edge); background: var(--panel2); color: var(--muted); cursor: pointer; font-size: 14px;
}
.modal-close:hover { color: var(--text); border-color: var(--teal); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.65; margin: 0 0 14px; }
code { font-family: ui-monospace, Menlo, monospace; color: var(--gold); background: #06161a; padding: 3px 8px; border-radius: 6px; word-break: break-all; font-size: 12.5px; }
code.inline { padding: 1px 5px; font-size: 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; margin: 10px 0; align-items: baseline; }
.kv span { color: var(--muted); font-size: 13px; }
.commits-label { color: var(--muted); font-size: 12px; margin: 14px 0 6px; font-weight: 600; }
.commits {
  font-family: ui-monospace, Menlo, monospace; background: #06161a; border: 1px solid var(--edge); border-radius: 10px;
  padding: 12px; margin: 0; white-space: pre-wrap; word-break: break-all; font-size: 11.5px; color: var(--teal);
  line-height: 1.55; max-height: 300px; overflow: auto;
}
