:root {
  --bg: #0a1424;
  --panel: #111f33;
  --panel-2: #17283f;
  --border: #2f4463;
  --text: #e5edf9;
  --muted: #9db0cd;
  --ok: #54cd81;
  --warn: #f5ad51;
  --danger: #f47171;
  --card-w: 81px;
  --card-h: 113px;
  --road-player: #2563eb;
  --road-banker: #dc2626;
  --road-tie: #22c55e;
  --phase-idle: #334155;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: radial-gradient(circle at 0% 0%, #132944 0%, var(--bg) 45%, #060d17 100%);
}

.shell { max-width: 1250px; margin: 0 auto; padding: 16px; display: grid; gap: 12px; }
.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.hero { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.hero h1 { margin: 0; font-size: 1.3rem; }
.hero p { margin: 6px 0 0; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; color: #9ec2f8; font-size: .72rem; }
.hero-right { text-align: right; }
.hero-actions { display: flex; justify-content: flex-end; gap: 8px; }
.hero-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  background: #28578f;
  border: 1px solid #4e76a8;
  color: #fff;
  font-size: .78rem;
  letter-spacing: .03em;
  text-transform: uppercase;
}
.hero-action--logout { background: rgba(244,113,113,.14); border-color: rgba(244,113,113,.45); color: #ffc4c4; }
.hero-action--logout:hover { background: rgba(244,113,113,.25); }

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: #1c2f4b;
  font-size: .82rem;
}
.pill.ok { background: rgba(84,205,129,.16); border-color: rgba(84,205,129,.45); color: #9df0b8; }
.pill.warn { background: rgba(245,173,81,.15); border-color: rgba(245,173,81,.45); color: #ffd8a2; }
.pill.muted { opacity: .8; }

.muted { color: var(--muted); font-size: .86rem; }

.hidden { display: none !important; }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-shell { width: min(100%, 430px); }
.auth-card { padding: 28px; box-shadow: 0 24px 60px rgba(0,0,0,.32); }
.auth-card h1 { margin: 8px 0 6px; font-size: 1.55rem; }
.auth-card > p { margin: 0 0 20px; }
.auth-form { display: grid; gap: 14px; }
.auth-form label { display: grid; gap: 6px; color: var(--muted); font-size: .88rem; }
.auth-form button { margin-top: 4px; background: #28578f; border-color: #4e76a8; color: #fff; }
.auth-message { min-height: 1.3em; margin: 16px 0 0 !important; }
.auth-message--error { color: #ffc4c4; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.form-grid label { display: grid; gap: 6px; font-size: .84rem; color: var(--muted); }
input, select, button {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #12223a;
  color: var(--text);
  padding: 8px 10px;
}
button { cursor: pointer; font-weight: 600; }
button:hover { background: #1a3557; }
button.ghost { background: #1a2a42; }
button.danger { background: rgba(244,113,113,.14); border-color: rgba(244,113,113,.45); color: #ffc4c4; }
.small-btn { padding: 5px 8px; font-size: .78rem; }

.btn-row { display: flex; align-items: end; gap: 8px; }
.inline-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.inline-row.between { justify-content: space-between; }
.inline-row label { display: flex; gap: 8px; align-items: center; font-size: .84rem; color: var(--muted); }
.inline-row label input { min-width: 190px; }
.confidence-high { color: #9df0b8; font-weight: 700; }
.confidence-mid { color: #ffd8a2; font-weight: 700; }
.confidence-low { color: #c7d4e9; font-weight: 700; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td {
  border-bottom: 1px solid rgba(157,176,205,.18);
  text-align: left;
  padding: 8px 7px;
  font-size: .82rem;
  vertical-align: middle;
}
.data-table th { color: var(--muted); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 12px; }

.result-inline {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  background: rgba(3, 10, 24, 0.28);
}

.result-top {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
}
.result-top__side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1 1 0;
}
.result-top__center { display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.result-score { font-size: 1.12rem; font-weight: 700; color: rgba(255,255,255,.84); }
.result-score strong { font-size: 1.5rem; }
.result-score--player strong { color: #63adff; }
.result-score--banker strong { color: #ff8686; }

.result-bottom {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}
.result-bottom__pair { display: flex; gap: 8px; flex: 1 1 0; justify-content: center; }
.result-bottom__gap { width: 120px; flex-shrink: 0; }

.result-card {
  width: var(--card-w);
  height: var(--card-h);
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #1d3048;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.result-card--landscape {
  width: var(--card-h);
  height: var(--card-w);
  position: relative;
  overflow: hidden;
}
.result-card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.result-card--landscape .result-card-img {
  position: absolute;
  width: var(--card-w);
  height: var(--card-h);
  top: 50%;
  left: 50%;
  margin-top: calc(-1 * var(--card-h) / 2);
  margin-left: calc(-1 * var(--card-w) / 2);
  transform: rotate(90deg);
}

.result-winner-bubble {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .96rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--phase-idle);
}
.result-winner-bubble--player { background: var(--road-player); }
.result-winner-bubble--banker { background: var(--road-banker); }
.result-winner-bubble--tie { background: var(--road-tie); color: #043316; }

@media (max-width: 980px) {
  .grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}

.hidden { display: none !important; }

.grid-view-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: radial-gradient(circle at 0% 0%, #0f223a 0%, #08111d 55%, #050b13 100%);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grid-view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border-radius: 12px;
  padding: 10px 12px;
}
.grid-view-header h2 {
  margin: 4px 0 0;
  font-size: 1.1rem;
}

.grid-view-container {
  --grid-cols: 3;
  --grid-rows: 3;
  flex: 1;
  min-height: 0;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(var(--grid-cols), minmax(0, 1fr));
  grid-template-rows: repeat(var(--grid-rows), minmax(0, 1fr));
}

.grid-table-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, #132741, #111f33);
  padding: 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  cursor: zoom-in;
}
.grid-table-card--placeholder {
  cursor: default;
  opacity: .72;
  border-style: dashed;
}
.grid-table-card.is-expanded {
  position: fixed;
  inset: 12px;
  z-index: 10000;
  cursor: zoom-out;
  background: linear-gradient(180deg, #163053, #132741);
}
.grid-table-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.grid-table-card__name {
  font-weight: 700;
  font-size: .95rem;
}
.grid-table-card__meta {
  color: var(--muted);
  font-size: .74rem;
}
.grid-table-card__placeholder-note {
  margin-top: 8px;
  color: #b7c8e4;
  font-size: .82rem;
}

.grid-result {
  border: 1px solid rgba(157,176,205,.22);
  border-radius: 10px;
  padding: 8px;
  background: rgba(2, 10, 22, 0.38);
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
}
.grid-scoreline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  font-size: .76rem;
}
.grid-scoreline strong {
  font-size: .9rem;
}
.grid-cards-layout {
  --slot-w: 52px;
  --slot-h: calc(var(--slot-w) * 1.39);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-height: 0;
  flex: 1;
  align-items: center;
}
.grid-table-card.is-expanded .grid-cards-layout {
  --slot-w: 96px;
}
.grid-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  min-height: 0;
}
.grid-side__top {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  flex: 0 0 auto;
}
.grid-side__bottom {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  min-height: 0;
  flex: 0 0 auto;
}
.grid-card-slot {
  border: 1px solid rgba(157,176,205,.22);
  border-radius: 5px;
  background: #1d3048;
  width: var(--slot-w);
  height: var(--slot-h);
  min-width: 52px;
  min-height: 72px;
  position: relative;
  overflow: hidden;
}
.grid-card-slot--top {
  width: var(--slot-h);
  height: var(--slot-w);
  min-width: 72px;
  min-height: 52px;
}
.grid-card-slot img {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  transform: translate(-50%, -50%);
  object-fit: contain;
  display: block;
}
.grid-card-slot--top img {
  transform: translate(-50%, -50%) rotate(-90deg);
  transform-origin: center;
}

.grid-raw {
  margin-top: 8px;
  border: 1px solid rgba(157,176,205,.22);
  border-radius: 8px;
  background: rgba(3, 8, 16, 0.7);
  padding: 6px;
  min-height: 0;
  flex: 0 0 auto;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: .72rem;
  line-height: 1.3;
  max-height: calc(1.3em * 3 + 18px);
}
.grid-table-card.is-expanded .grid-raw {
  flex: 0 0 25%;
  max-height: 25%;
}
.grid-table-card.is-expanded .grid-result {
  flex: 1 1 75%;
}
.grid-raw__line {
  color: #d9e7ff;
  white-space: nowrap;
}
.grid-raw__empty {
  color: #9db0cd;
  font-size: .74rem;
}
