:root {
  --bg: #0a1a14;
  --panel: #0f241c;
  --line: #1e3d30;
  --green: #3ecf7a;
  --fairway: #1a8f4c;
  --gold: #d4b017;
  --text: #e8f6ee;
  --muted: #8aafa0;
  --danger: #ff5b45;
  --ok: #15d817;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; min-height: 100%;
  font-family: Outfit, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 60% at 20% 0%, rgba(30, 120, 70, .35), transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 100%, rgba(20, 60, 40, .4), transparent 50%),
    linear-gradient(160deg, #06140f 0%, #0c1f17 45%, #081610 100%);
}
button { font: inherit; cursor: pointer; border: 0; }
#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(6, 18, 12, .88);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { display: none; }
.brand-title {
  font-family: Rajdhani, sans-serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .06em;
  color: var(--green);
}
.top-right { display: flex; align-items: center; gap: 12px; }
.clock, .balance { font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px; }
.balance { color: var(--green); }
.exit-btn { background: #1a3228; color: #fff; padding: 8px 12px; border-radius: 6px; }

.help-btn {
  width: 34px; height: 34px; padding: 0; border: 0; background: transparent;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; cursor: pointer;
}
.help-btn img {
  width: 26px; height: 26px; display: block;
  filter: brightness(0) saturate(100%) invert(72%) sepia(42%) saturate(600%) hue-rotate(88deg) brightness(104%) contrast(95%);
}
.help-btn:hover { opacity: .85; }

.lang-switch { position: relative; z-index: 40; }
.lang-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 0; border-radius: 6px;
  background: #152820; color: #fff; cursor: pointer;
}
.lang-btn img { width: 22px; height: 16px; object-fit: cover; border-radius: 2px; }
.lang-btn #lang-code { font-size: 12px; font-weight: 700; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  max-height: 280px; overflow: auto; min-width: 180px;
  background: #12241c; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0,0,0,.45);
}
.lang-menu.hide { display: none; }
.lang-item {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; text-align: left; border: 0;
  background: transparent; color: #fff; cursor: pointer; font-size: 12px;
}
.lang-item:hover, .lang-item.on { background: #1c3a2c; }
.lang-item img { width: 22px; height: 16px; object-fit: cover; }

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  min-height: 0;
}
.main-col { display: flex; flex-direction: column; min-width: 0; }

.stage {
  position: relative;
  width: calc(100% - 20px);
  margin-left: 10px;
  margin-right: 10px;
  aspect-ratio: 16 / 9;
  height: auto;
  max-height: min(62vh, 560px);
  background: #06140f;
  overflow: hidden;
  border-radius: 4px;
}
.stage .poster,
#match-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  object-position: center center;
}
.stage .poster {
  z-index: 1;
  opacity: .78;
  object-fit: cover;
  object-position: center center;
  transition: opacity .45s ease;
}
#match-video {
  z-index: 1;
  background: #000;
  object-fit: contain;
  object-position: center center;
}
#match-video.hide,
.stage .poster.hide,
.golf-live.hide { display: none; }

/* FGOL-style live golf island (replaces wrong stock MP4s) */
.golf-live {
  position: absolute; inset: 0; z-index: 1;
  overflow: hidden;
  background: #0a2a3a;
}
.gl-sky {
  position: absolute; inset: 0 0 42% 0;
  background:
    radial-gradient(ellipse 80% 60% at 70% 20%, rgba(255,255,255,.18), transparent 55%),
    linear-gradient(180deg, #5eb7e8 0%, #8ed0f0 45%, #c8e8f5 100%);
  animation: glCloud 18s ease-in-out infinite alternate;
}
@keyframes glCloud {
  from { transform: scale(1.02) translateX(0); }
  to { transform: scale(1.08) translateX(-2%); }
}
.gl-water {
  position: absolute; left: 0; right: 0; bottom: 0; height: 48%;
  background:
    linear-gradient(180deg, #1a6fa8 0%, #0d4a78 55%, #083554 100%);
  animation: glWave 4s ease-in-out infinite alternate;
}
@keyframes glWave {
  from { transform: translateY(0); }
  to { transform: translateY(6px); }
}
.gl-island {
  position: absolute;
  left: 50%; top: 46%;
  width: min(92%, 720px); height: 58%;
  transform: translate(-50%, -42%) perspective(900px) rotateX(48deg) rotateZ(-8deg);
  transform-origin: center center;
  animation: glIsland 12s ease-in-out infinite alternate;
}
@keyframes glIsland {
  from { transform: translate(-50%, -42%) perspective(900px) rotateX(48deg) rotateZ(-8deg) scale(1); }
  to { transform: translate(-50%, -44%) perspective(900px) rotateX(50deg) rotateZ(-4deg) scale(1.04); }
}
.gl-fairway {
  position: absolute; inset: 8% 12% 10% 10%;
  border-radius: 42% 38% 44% 40% / 36% 42% 34% 40%;
  background:
    radial-gradient(ellipse at 62% 72%, #6bcf4a 0%, #3fa82e 35%, #2d8a22 70%, #1f6b18 100%);
  box-shadow:
    inset 0 0 40px rgba(0,40,0,.35),
    0 18px 40px rgba(0,0,0,.35);
}
.gl-bunker {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #e8d4a8, #c4a574 70%);
  box-shadow: inset 0 2px 8px rgba(80,50,10,.35);
}
.gl-b1 { width: 14%; height: 10%; left: 22%; top: 38%; }
.gl-b2 { width: 10%; height: 8%; right: 24%; top: 48%; }
.gl-green {
  position: absolute;
  width: 22%; height: 18%;
  right: 26%; bottom: 22%;
  border-radius: 50%;
  background: radial-gradient(circle at 45% 40%, #7ae05a, #2f9a28 75%);
  box-shadow: inset 0 0 16px rgba(0,50,0,.3);
}
.gl-cup,
.gl-hole {
  position: absolute; left: 48%; top: 52%;
  width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 50%; background: #111;
  box-shadow: 0 0 0 2px rgba(255,255,255,.25);
}
.gl-flagpole {
  position: absolute; left: 48%; bottom: 48%;
  width: 3px; height: 54px;
  background: #eee;
  transform: translateX(-50%);
  transform-origin: bottom center;
}
.gl-flag {
  position: absolute; left: 3px; top: 2px;
  width: 22px; height: 14px;
  background: #e53935;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  animation: glFlag 1.2s ease-in-out infinite alternate;
}
@keyframes glFlag {
  from { transform: scaleX(1); }
  to { transform: scaleX(.85) skewY(-4deg); }
}
.gl-tree {
  position: absolute;
  width: 0; height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-bottom: 28px solid #1a5c28;
  filter: drop-shadow(0 4px 3px rgba(0,0,0,.25));
}
.gl-tree::after {
  content: "";
  position: absolute; left: -3px; top: 22px;
  width: 6px; height: 8px; background: #5a3a1a;
}
.gl-t1 { left: 18%; top: 28%; transform: scale(1.1); }
.gl-t2 { right: 20%; top: 30%; transform: scale(.9); }
.gl-t3 { left: 40%; top: 18%; transform: scale(1.25); }
.gl-ball {
  position: absolute;
  width: 22px; height: 22px;
  left: 28%; bottom: 28%;
  z-index: 3;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,.45));
  opacity: .95;
}
.gl-ball.is-flying {
  animation: glShot 2.4s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes glShot {
  0%   { left: 28%; bottom: 28%; transform: scale(1) rotate(0deg); opacity: 1; }
  35%  { left: 48%; bottom: 58%; transform: scale(.85) rotate(180deg); }
  70%  { left: 62%; bottom: 36%; transform: scale(.7) rotate(320deg); }
  100% { left: 66%; bottom: 32%; transform: scale(.55) rotate(400deg); opacity: .9; }
}
.gl-shot-trail {
  position: absolute; z-index: 2;
  left: 30%; bottom: 34%;
  width: 0; height: 3px;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(255,255,255,.55), transparent);
  opacity: 0;
  transform-origin: left center;
  transform: rotate(-28deg);
}
.gl-shot-trail.on {
  animation: glTrail 2.4s ease-out forwards;
}
@keyframes glTrail {
  0% { width: 0; opacity: 0; }
  20% { width: 18%; opacity: .7; }
  100% { width: 38%; opacity: 0; }
}

.stage.is-live .poster { opacity: 0; pointer-events: none; }
.stage.is-live #match-video:not(.hide) { opacity: 1; }
.stage.is-live .stage-shade { opacity: .18; }
.stage.is-live .vs-board {
  display: block;
  z-index: 3;
}
.stage.is-live .player-card {
  top: 40%;
}
.live-tabs,
.live-tabs.hide { display: none !important; }
.live-hud {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(6, 14, 20, .82);
  border: 1px solid rgba(255,255,255,.1);
  backdrop-filter: blur(4px);
}
.live-hud.hide { display: none; }
.live-hud-top, .live-hud-bottom {
  display: flex; align-items: center; gap: 8px; flex-wrap: nowrap;
}
.live-hud-bottom { margin-top: 6px; }
.live-badge {
  background: #00c2b8; color: #041018; font-weight: 800;
  font-size: 11px; padding: 2px 7px; border-radius: 3px;
  font-family: Rajdhani, sans-serif;
  flex: 0 0 auto;
}
.live-score {
  margin-left: 12px;
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px;
  color: #7fe7ff;
  flex: 0 0 auto;
  white-space: nowrap;
}
.stroke-boxes { display: flex; gap: 4px; }
.stroke-boxes span {
  width: 22px; height: 22px; display: flex; align-items: center; justify-content: center;
  border-radius: 4px; background: rgba(255,255,255,.08); font-size: 12px; font-weight: 700;
}
.stroke-boxes span.on { background: #1e4f9a; }
.slip-item.is-locked { opacity: .85; border-left: 3px solid var(--green); }
.slip-item .locked-tag {
  font-size: 10px; color: var(--green); font-weight: 700; letter-spacing: .04em;
}
.stage-shade {
  position: absolute; inset: 0; z-index: 2;
  background: linear-gradient(180deg, rgba(6,20,15,.25), rgba(6,20,15,.85));
  pointer-events: none;
}
.match-banner {
  position: absolute; top: 12px; left: 14px; z-index: 3;
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 16px;
  letter-spacing: .04em; color: var(--gold);
  text-shadow: 0 1px 6px rgba(0,0,0,.6);
}
.phase-label {
  position: absolute; top: 12px; right: 14px; z-index: 3;
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px;
  background: rgba(0,0,0,.45); padding: 4px 10px; border-radius: 6px;
}
.vs-board {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: block;
  width: auto;
  pointer-events: none;
  transform: none;
}
.player-card {
  position: absolute;
  top: 46%;
  width: 150px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.player-card:first-child {
  left: 60px;
  transform: translate(-18%, -50%);
}
.player-card:last-child {
  right: 60px;
  left: auto;
  transform: translate(18%, -50%);
}
.player-card img.avatar {
  width: 72px; height: 72px; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--green);
  background: #0a1a14;
}
.player-card .name {
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px;
  line-height: 1.1;
  text-shadow: 0 1px 6px rgba(0,0,0,.75);
}
.player-card .meta { font-size: 12px; color: var(--muted); text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.player-card .score {
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 28px;
  color: var(--gold);
  text-shadow: 0 1px 6px rgba(0,0,0,.75);
}
.vs-mid { display: none !important; }
.hole-progress {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  padding: 0 0 6px;
  pointer-events: none;
}
.hole-progress.hide { display: none; }
.hole-progress-track {
  height: 7px; border-radius: 0; background: rgba(255,255,255,.12); overflow: hidden;
}
.hole-progress-fill {
  height: 100%; width: 0%; background: linear-gradient(90deg, var(--fairway), var(--green));
  transition: width .4s ease;
}
.hole-progress-label {
  margin-top: 4px; text-align: center;
  font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 14px;
  text-shadow: 0 1px 6px rgba(0,0,0,.7);
}
.stage.is-live .match-banner { top: 28px; }
.stage.is-live .phase-label { top: 28px; }

.results {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 14, 10, .78);
}
.results.hide { display: none; }
.results-inner {
  text-align: center; padding: 20px 28px;
  background: rgba(15, 36, 28, .95); border: 1px solid var(--line); border-radius: 12px;
  min-width: 260px;
}
.results-inner h2 {
  margin: 0 0 12px; font-family: Rajdhani, sans-serif; font-size: 22px; color: var(--gold);
}
.results-inner .winner-name {
  font-size: 20px; font-weight: 700; margin-bottom: 6px;
}
.results-inner .scoreline { color: var(--muted); font-size: 14px; }

.status-bar {
  display: flex; justify-content: space-between;
  padding: 8px 16px; background: #0c1c15; border-bottom: 1px solid var(--line);
  font-size: 13px; color: var(--muted);
}
.status-bar #match-status { color: var(--green); font-weight: 600; }

.markets { padding: 12px 16px 20px; flex: 1; }
.markets-toolbar {
  display: flex;
  align-items: center;
  position: relative;
  min-height: 44px;
  margin-bottom: 12px;
}
.market-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 0; z-index: 1; }
.market-tabs button {
  padding: 8px 14px; border-radius: 8px;
  background: #132820; color: var(--muted); border: 1px solid transparent;
}
.market-tabs button.active {
  color: var(--text); border-color: var(--green);
  background: linear-gradient(180deg, #1a3d2c, #122820);
}
.market-table { display: grid; gap: 8px; }
.bet-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center;
  gap: 10px; padding: 10px 12px;
  background: rgba(15, 36, 28, .7); border: 1px solid var(--line); border-radius: 8px;
}
.bet-row .label { font-size: 14px; }
.bet-row .sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.odd-btn {
  min-width: 72px; padding: 8px 12px; border-radius: 8px;
  background: #1a3d2c; color: var(--green); font-family: Rajdhani, sans-serif;
  font-weight: 700; font-size: 18px; border: 1px solid rgba(62, 207, 122, .35);
}
.odd-btn:hover { background: #214a36; }
.odd-btn.on { background: var(--green); color: #062010; border-color: var(--green); }
.odd-btn:disabled { opacity: .4; cursor: default; }
.odds-pair { display: flex; gap: 8px; }

.ticket {
  background: rgba(8, 20, 15, .95);
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
}
.ticket-head {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; background: transparent; color: var(--text); width: 100%;
  text-align: left;
}
.ticket-head h2 {
  margin: 0; flex: 1; font-family: Rajdhani, sans-serif; font-size: 18px; letter-spacing: .04em;
}
.ticket-count {
  background: var(--green); color: #062010; font-weight: 700;
  font-size: 12px; min-width: 20px; height: 20px; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 6px;
}
.ticket-count.hide { display: none; }
.ticket-chevron::before { content: "▾"; color: var(--muted); }
.ticket.is-collapsed .ticket-chevron::before { content: "▸"; }
.ticket.is-collapsed .ticket-panel { display: none; }
.ticket-panel { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.ticket-panel-inner { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.ticket-tools { text-align: right; }
.linkish { background: transparent; color: var(--muted); font-size: 12px; text-decoration: underline; }
.stake-row {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted);
}
.stake-row input {
  width: 72px; text-align: center; padding: 6px;
  background: #12241c; border: 1px solid var(--line); border-radius: 6px; color: var(--text);
}
.stake-row button {
  width: 28px; height: 28px; border-radius: 6px; background: #1a3228; color: #fff;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 10px; border-radius: 999px; background: #132820; color: var(--muted);
  border: 1px solid var(--line); font-family: Rajdhani, sans-serif; font-weight: 700;
}
.chip.on { color: #062010; background: var(--green); border-color: var(--green); }
.slip-body { flex: 1; min-height: 80px; }
.slip-body.is-empty { display: flex; align-items: center; justify-content: center; }
.slip-empty { color: var(--muted); font-size: 13px; }
.slip-item {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.slip-item .rm { background: transparent; color: var(--danger); font-size: 16px; }
.ticket-totals {
  display: grid; gap: 6px; font-size: 12px; color: var(--muted);
}
.ticket-totals strong { float: right; color: var(--text); font-family: Rajdhani, sans-serif; font-size: 16px; }
.submit-btn {
  width: 100%; padding: 12px; border-radius: 8px;
  background: linear-gradient(180deg, #3ecf7a, #1a8f4c);
  color: #062010; font-family: Rajdhani, sans-serif; font-weight: 700; font-size: 18px;
  letter-spacing: .04em;
}
.submit-btn:disabled { opacity: .4; cursor: default; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: #12241c; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 80; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.help-modal {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.7); padding: 16px;
}
.help-modal.hide { display: none; }
.help-modal-card {
  width: min(520px, 100%); max-height: 80vh; overflow: auto;
  background: #0f241c; border: 1px solid var(--line); border-radius: 12px;
}
.help-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.help-modal-head h2 { margin: 0; font-family: Rajdhani, sans-serif; font-size: 18px; }
.help-close { background: transparent; color: var(--muted); font-size: 24px; line-height: 1; }
.help-modal-body { padding: 16px; font-size: 14px; line-height: 1.5; color: var(--muted); }
.help-modal-body h3 { color: var(--text); margin: 12px 0 6px; font-size: 14px; }
.stats-footer { padding: 0 16px 16px; }
.stats-clear {
  background: #1a3228; color: var(--muted); padding: 8px 12px; border-radius: 6px; font-size: 12px;
}
.stat-row {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px;
}
.stat-row .win { color: var(--ok); }
.stat-row .loss { color: var(--danger); }

.hide { display: none !important; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .ticket { border-left: 0; border-top: 1px solid var(--line); }
  .stage {
    width: calc(100% - 12px);
    margin-left: 6px;
    margin-right: 6px;
    max-height: min(48vh, 420px);
  }
  .player-card { width: 120px; }
  .player-card img.avatar { width: 56px; height: 56px; }
}
