/* bitXbit test platform — single stylesheet, dark theme, no frameworks. */

:root {
  --bg: #0e1116;
  --surface: #161b23;
  --surface-2: #1d232d;
  --border: #2a323e;
  --text: #e6eaf0;
  --muted: #8b95a5;
  --accent: #4ade80;
  --accent-dim: #22c55e;
  --danger: #f87171;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: inherit; text-decoration: none; }
code { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

.container { max-width: 1180px; margin: 0 auto; padding: 28px 20px 60px; }
.container-narrow { max-width: 420px; padding-top: 12vh; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--accent); }
.neg { color: var(--danger); }

/* --- top bar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 20px; font-weight: 700; letter-spacing: -0.5px; }
.brand span, .login-title span { color: var(--accent); }
.topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.balance-box {
  display: flex; align-items: baseline; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
}
.balance-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
.balance-box strong { font-size: 17px; font-variant-numeric: tabular-nums; }

/* --- buttons --- */
.btn {
  display: inline-block;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #252c38; border-color: #3a4453; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--accent-dim); border-color: var(--accent-dim); color: #05210f; font-weight: 600; }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }

/* --- login --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
}
.login-title { margin: 0; font-size: 30px; letter-spacing: -1px; }
.form { display: flex; flex-direction: column; gap: 6px; margin: 22px 0 16px; }
.form label { font-size: 13px; color: var(--muted); }
.form input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 10px 12px;
  font-size: 15px;
  margin-bottom: 8px;
}
.form input:focus { outline: 2px solid var(--accent-dim); outline-offset: -1px; }
.alert {
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 14px;
}
.alert-page { margin: 20px; }

/* --- lobby --- */
.hero {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px 24px;
}
.hero p { margin: 0 0 4px; }
.player-name { margin: 0; font-size: 26px; }
.hero-balance { text-align: right; }
.balance-big { margin: 0; font-size: 40px; font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; }
.toolbar { display: flex; align-items: center; gap: 14px; margin: 22px 0 16px; }
.page-title { margin: 0 0 4px; font-size: 24px; }
.section-title { font-size: 15px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; margin: 26px 0 10px; }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
}
.game-card {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  transition: transform 0.12s, border-color 0.12s;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--accent-dim); }

/* The thumbnail is a lettered tile; the <img> covers it when the CDN answers,
   and is removed when every icon URL fails, revealing the tile underneath. */
.game-thumb {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  background: linear-gradient(135deg, #232b37, #171d26);
  overflow: hidden;
}
.game-thumb::after {
  content: attr(data-letter);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 44px;
  font-weight: 700;
  color: #3d4757;
}
.game-thumb img {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  /* contain, not cover: the provider's icons vary in aspect ratio and cover
     crops the game title straight off the artwork. */
  object-fit: contain;
  display: block;
}
.game-name { font-weight: 600; margin-top: 6px; }
.game-meta { color: var(--muted); font-size: 12px; }

/* --- game page: the iframe fills whatever is left under the bar ---
   Flex layout instead of a hardcoded header height, which was wrong as soon as
   the top bar wrapped to a second line. */
.body-game { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.body-game .topbar { flex: 0 0 auto; position: static; }
.game-main { flex: 1 1 auto; min-height: 0; padding: 0; }
.game-stage { position: relative; width: 100%; height: 100%; }
.game-frame { width: 100%; height: 100%; border: 0; display: block; }

/* Placeholder shown until the frame reports a load. */
.game-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg);
  text-align: center;
  padding: 20px;
  z-index: 2;
}
.game-loading[hidden] { display: none; }
.game-loading code { color: var(--muted); word-break: break-all; }
.game-loading a { color: var(--accent); text-decoration: underline; }
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- transactions --- */
.table-wrap { overflow-x: auto; margin-top: 18px; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { background: var(--surface); color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface); }

/* IDs are 32-char hex; truncate so every column fits, full value in the tooltip. */
.table td.id {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); background: var(--surface-2); }
.tag-withdraw { color: #fbbf24; border-color: #7c5b12; }
.tag-deposit { color: var(--accent); border-color: #1d6b3c; }
.tag-betwin { color: #60a5fa; border-color: #1e4a7a; }
.tag-rollback { color: #c084fc; border-color: #5b2f7a; }
.tag-rolled { color: var(--danger); border-color: #7a2b2b; }

/* --- mock game (the provider stand-in, rendered inside the iframe) --- */
.mock-main { padding: 22px 20px 40px; }
.mock-shell { max-width: 760px; margin: 0 auto; }
.mock-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.mock-title { margin: 2px 0 0; font-size: 22px; }
.mock-balance { text-align: right; }
.mock-balance strong { display: block; font-size: 26px; color: var(--accent); font-variant-numeric: tabular-nums; }
.mock-note { margin-top: 4px; }

.reels {
  display: flex; gap: 12px; justify-content: center;
  background: linear-gradient(180deg, #1c2430, #12171f);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px 18px;
  margin: 20px 0 10px;
}
.reel {
  width: 92px; height: 92px;
  display: flex; align-items: center; justify-content: center;
  font-size: 46px; line-height: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.reels.spinning .reel { animation: reel-blur 0.35s linear infinite; }
@keyframes reel-blur {
  50% { transform: translateY(-6px); opacity: 0.55; }
}
.reel-result { text-align: center; font-size: 17px; font-weight: 600; margin: 0 0 4px; min-height: 24px; }
.reel-result.ok { color: var(--accent); }      /* the round paid out */
.reel-result.idle { color: var(--muted); }     /* accepted, but no win */
.reel-result.bad { color: var(--danger); }     /* a non-zero result code */

.mock-buttons { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0 10px; justify-content: center; }
.log { display: flex; flex-direction: column; gap: 8px; }
.log-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 8px;
  padding: 10px 12px;
}
.log-entry.code-0 { border-left-color: var(--accent); }
.log-entry.code-6, .log-entry.code-11, .log-entry.code-9, .log-entry.code-8 { border-left-color: #fbbf24; }
.log-entry.code-1, .log-entry.code-2, .log-entry.code-3, .log-entry.code-4, .log-entry.code-5 { border-left-color: var(--danger); }
.log-head { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.log pre {
  margin: 0; white-space: pre-wrap; word-break: break-all;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px; color: var(--muted);
}

/* --- balance flash on refresh --- */
@keyframes flash { from { color: var(--accent); } to { color: inherit; } }
.flash { animation: flash 0.8s ease-out; }
