/* ==========================================================================
   Variables & base
   ========================================================================== */
:root {
  --bg-dark: #0d0d0d;
  --bg-panel: #1a1a1a;
  --bg-header: #000;
  --text: #fff;
  --text-muted: #b0b0b0;
  --accent-yellow: #f5d020;
  --accent-green: #22c55e;
  --accent-pink: #ec4899;
  --meron-red: #dc2626;
  --wala-blue: #2563eb;
  --close-gold: #b8860b;
  --chip-outline-20: #22c55e;
  --chip-outline-50: #3b82f6;
  --chip-outline-100: #a855f7;
  --chip-outline-200: #f97316;
  --chip-outline-500: #ef4444;
  --chip-outline-1000: #eab308;
  --chip-outline-2000: #ec4899;
  --chip-outline-5000: #06b6d4;
  --radius: 4px;
  --header-h: 52px;
  --bet-panel-min-w: 320px;
  --bet-panel-max-w: 420px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   App shell
   ========================================================================== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header
   ========================================================================== */
.header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: var(--header-h);
  background: var(--bg-header);
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .header {
    gap: 12px;
    padding: 0 16px;
  }
}

.header__menu {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
}

.header__menu span {
  display: block;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}

.header__balance-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.header__balance {
  font-weight: 700;
  color: var(--accent-yellow);
  font-size: 0.9rem;
}

@media (min-width: 768px) {
  .header__balance {
    font-size: 1rem;
  }
}

.header__refresh {
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
}

.header__refresh:hover {
  background: var(--bg-panel);
}

.header__refresh svg {
  width: 18px;
  height: 18px;
}

.header__actions {
  display: flex;
  gap: 8px;
}

/* Buttons (shared) */
.btn {
  padding: 8px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.98);
}

.btn--cash-in {
  background: var(--accent-green);
  color: var(--text);
  font-size: 0.7rem;
  padding: 6px 12px;
}

@media (min-width: 768px) {
  .btn--cash-in {
    font-size: 0.75rem;
    padding: 8px 16px;
  }
}

.btn--cash-out {
  background: var(--accent-pink);
  color: var(--text);
  font-size: 0.7rem;
  padding: 6px 12px;
}

@media (min-width: 768px) {
  .btn--cash-out {
    font-size: 0.75rem;
    padding: 8px 16px;
  }
}

/* ==========================================================================
   Main layout
   ========================================================================== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

@media (min-width: 768px) {
  .main {
    flex-direction: row;
  }
}

/* ==========================================================================
   Video section (left)
   ========================================================================== */
.video-section {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-dark);
  min-height: 300px;
}

@media (min-width: 768px) {
  .video-section {
    min-height: 400px;
  }
}

@media (min-width: 1024px) {
  .video-section {
    min-height: 500px;
  }
}

.video-section__title {
  background: var(--bg-header);
  padding: 8px 12px;
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .video-section__title {
    padding: 10px 16px;
  }
}

.event-title {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
}

@media (min-width: 768px) {
  .event-title {
    font-size: 0.85rem;
  }
}

.video-section__player {
  flex: 1;
  min-height: 200px;
  position: relative;
  background: #111;
}

.video-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0a0a0a;
}

/* Video.js: fill container and maintain aspect ratio */
.video-section__player .video-js {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.video-section__player .video-js video {
  object-fit: contain;
}

.video-placeholder__overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
}

.video-placeholder__overlay.hidden {
  display: none;
}

.video-error-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 2;
}

.video-error-overlay.hidden {
  display: none;
}

.video-error-overlay__text {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.video-placeholder__text {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.1em;
}

/* ==========================================================================
   Bet panel (right)
   ========================================================================== */
.bet-panel {
  background: var(--bg-panel);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  overflow-y: auto;
  max-height: calc(100vh - var(--header-h));
}

@media (min-width: 768px) {
  .bet-panel {
    min-width: 340px;
    max-width: 400px;
    border-left: 1px solid rgba(255, 255, 255, 0.08);
  }
}

@media (min-width: 1024px) {
  .bet-panel {
    min-width: var(--bet-panel-min-w);
    max-width: var(--bet-panel-max-w);
  }
}

.bet-panel__titles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: -16px -16px 0 -16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.bet-panel__title {
  background: #2a2a2a;
  padding: 14px 12px;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  letter-spacing: 0.08em;
}

.bet-panel__values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding-top: 4px;
}

.bet-panel__status {
  background: var(--accent-green);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: var(--radius);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bet-panel__fight {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 12px 16px;
  border-radius: var(--radius);
  letter-spacing: 0.08em;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

@media (min-width: 768px) {
  .totals-single {
    gap: 16px;
  }
}

.totals-single__item {
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent-yellow);
  padding: 10px 8px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: var(--radius);
  letter-spacing: 0.02em;
  word-break: break-word;
}

@media (min-width: 400px) {
  .totals-single__item {
    font-size: 1.25rem;
    padding: 12px 10px;
  }
}

@media (min-width: 768px) {
  .totals-single__item {
    font-size: 1.4rem;
    padding: 12px;
  }
}

@media (max-width: 960px) {
  .totals-single__item {
    font-size: 1.4rem;
  }
}

.bet-options-full {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (min-width: 768px) {
  .bet-options-full {
    gap: 12px;
  }
}

.bet-option-full {
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bet-option-full--meron .bet-option-full__header {
  background: var(--meron-red);
}

.bet-option-full--wala .bet-option-full__header {
  background: var(--wala-blue);
}

.bet-option-full__header {
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

@media (min-width: 768px) {
  .bet-option-full__header {
    padding: 10px 8px;
  }
}

.bet-option-full__title {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text);
  letter-spacing: 0.05em;
}

@media (min-width: 768px) {
  .bet-option-full__title {
    font-size: 1rem;
  }
}

.bet-option-full__subtitle {
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
}

@media (min-width: 768px) {
  .bet-option-full__subtitle {
    font-size: 0.75rem;
  }
}

.bet-option-full__payout {
  background: rgba(0, 0, 0, 0.4);
  padding: 6px;
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.02em;
}

@media (min-width: 768px) {
  .bet-option-full__payout {
    padding: 8px;
    font-size: 0.8rem;
  }
}

.bet-option-full__user {
  background: rgba(0, 0, 0, 0.4);
  padding: 6px;
  text-align: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-green);
  letter-spacing: 0.02em;
}

@media (min-width: 768px) {
  .bet-option-full__user {
    padding: 8px;
    font-size: 0.75rem;
  }
}

.btn--bet-full {
  background: var(--accent-green);
  color: var(--text);
  padding: 10px 6px;
  border: none;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: opacity 0.15s, transform 0.1s;
  min-height: 80px;
}

@media (min-width: 768px) {
  .btn--bet-full {
    padding: 12px 8px;
    gap: 6px;
  }
}

.btn--bet-full:active {
  transform: scale(0.98);
}

.btn--bet-full__icon {
  font-size: 1.1rem;
  font-weight: 700;
  width: 28px;
  height: 28px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 768px) {
  .btn--bet-full__icon {
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
  }
}

.btn--bet-full__text-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.btn--bet-full__text {
  font-size: 0.7rem;
  line-height: 1.2;
  text-align: center;
  letter-spacing: 0.03em;
}

@media (min-width: 768px) {
  .btn--bet-full__text {
    font-size: 0.75rem;
  }
}

.btn--bet-full__sub {
  font-size: 0.6rem;
  font-weight: 500;
  opacity: 0.9;
}

@media (min-width: 768px) {
  .btn--bet-full__sub {
    font-size: 0.65rem;
  }
}

.bet-input-section-new {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 768px) {
  .bet-input-section-new {
    gap: 12px;
  }
}

.bet-input-section-new__balance {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

@media (min-width: 768px) {
  .bet-input-section-new__balance {
    padding: 10px 12px;
    gap: 8px;
  }
}

.bet-input-section-new__balance-label {
  font-size: 0.85rem;
  color: var(--text);
  font-weight: 500;
}

@media (min-width: 768px) {
  .bet-input-section-new__balance-label {
    font-size: 0.9rem;
  }
}

.bet-input-section-new__balance-value {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-yellow);
  letter-spacing: 0.02em;
}

@media (min-width: 768px) {
  .bet-input-section-new__balance-value {
    font-size: 1.1rem;
  }
}

.bet-input-section-new__copy {
  width: 28px;
  height: 28px;
  padding: 0;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  transition: background 0.15s;
}

@media (min-width: 768px) {
  .bet-input-section-new__copy {
    width: 32px;
    height: 32px;
  }
}

.bet-input-section-new__copy:hover {
  background: rgba(255, 255, 255, 0.2);
}

.bet-input-section-new__copy svg {
  width: 16px;
  height: 16px;
}

@media (min-width: 768px) {
  .bet-input-section-new__copy svg {
    width: 18px;
    height: 18px;
  }
}

.bet-input-section-new__row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

@media (min-width: 768px) {
  .bet-input-section-new__row {
    gap: 12px;
  }
}

.bet-input-section-new__input-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

@media (min-width: 768px) {
  .bet-input-section-new__input-wrap {
    gap: 6px;
  }
}

.bet-input-section-new__label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

@media (min-width: 768px) {
  .bet-input-section-new__label {
    font-size: 0.85rem;
  }
}

.bet-input-section-new__input {
  width: 100%;
  padding: 12px 14px;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent-yellow);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
}

@media (min-width: 768px) {
  .bet-input-section-new__input {
    padding: 14px 16px;
    font-size: 1.5rem;
  }
}

.bet-input-section-new__input:focus {
  outline: none;
  border-color: var(--accent-yellow);
}

.btn--clear-new {
  background: var(--accent-pink);
  color: var(--text);
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s;
  letter-spacing: 0.03em;
}

@media (min-width: 768px) {
  .btn--clear-new {
    padding: 14px 20px;
    font-size: 0.9rem;
    gap: 8px;
  }
}

.btn--clear-new:active {
  transform: scale(0.98);
}

.btn--clear-new svg {
  width: 16px;
  height: 16px;
}

@media (min-width: 768px) {
  .btn--clear-new svg {
    width: 18px;
    height: 18px;
  }
}

/* Chips */
.chips {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (min-width: 768px) {
  .chips {
    gap: 10px;
  }
}

.chips__row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

@media (min-width: 400px) {
  .chips__row {
    gap: 8px;
  }
}

.chip {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  color: #000;
  background: #fff;
  border: 3px solid;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  position: relative;
}

@media (min-width: 400px) {
  .chip {
    width: 52px;
    height: 52px;
    font-size: 0.8rem;
  }
}

@media (min-width: 768px) {
  .chip {
    width: 56px;
    height: 56px;
    font-size: 0.85rem;
  }
}

.chip:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

.chip:active {
  transform: scale(0.95);
}

.chip--20   { border-color: var(--chip-outline-20); }
.chip--50   { border-color: var(--chip-outline-50); }
.chip--100  { border-color: var(--chip-outline-100); }
.chip--200  { border-color: var(--chip-outline-200); }
.chip--500  { border-color: var(--chip-outline-500); }
.chip--1000 { border-color: var(--chip-outline-1000); }
.chip--2000 { border-color: var(--chip-outline-2000); }
.chip--5000 { border-color: var(--chip-outline-5000); }

/* ==========================================================================
   Bead Plate Section
   ========================================================================== */
.bead-plate-section {
  margin-top: 16px;
  padding: 16px;
  background: var(--bg-panel);
  border-radius: var(--radius);
}

.bead-plate-section__title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--accent-yellow);
  text-align: center;
  margin-bottom: 12px;
  letter-spacing: 0.05em;
}

/* Horizontal Bead Plate */
.bead-plate-horizontal {
  display: grid;
  grid-template-columns: repeat(auto-fill, 20px);
  gap: 4px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  min-height: 100px;
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.bead-plate-horizontal__bead {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
}

.bead-plate-horizontal__bead--meron {
  background: var(--meron-red);
}

.bead-plate-horizontal__bead--wala {
  background: var(--wala-blue);
}

.bead-plate-horizontal__bead--draw {
  background: var(--accent-green);
}

.bead-plate-horizontal__bead--cancelled {
  background: #6b7280;
}

/* Statistics Display */
.bead-plate-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 12px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
}

@media (min-width: 400px) {
  .bead-plate-stats {
    gap: 10px;
  }
}

.bead-plate-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bead-plate-stat__circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  border: 3px solid rgba(255, 255, 255, 0.3);
}

@media (min-width: 400px) {
  .bead-plate-stat__circle {
    width: 56px;
    height: 56px;
    font-size: 1.1rem;
  }
}

.bead-plate-stat--meron .bead-plate-stat__circle {
  background: var(--meron-red);
}

.bead-plate-stat--wala .bead-plate-stat__circle {
  background: var(--wala-blue);
}

.bead-plate-stat--draw .bead-plate-stat__circle {
  background: var(--accent-green);
}

.bead-plate-stat--cancelled .bead-plate-stat__circle {
  background: #6b7280;
}

.bead-plate-stat__label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

@media (min-width: 400px) {
  .bead-plate-stat__label {
    font-size: 0.75rem;
  }
}

/* Derived Road Pattern Tracker */
.bead-plate-road {
  display: flex;
  gap: 2px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  min-height: 100px;
  max-height: 200px;
  overflow-x: auto;
  overflow-y: hidden;
}

.bead-plate-road__column {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 24px;
}

.bead-plate-road__cell {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.bead-plate-road__cell--meron {
  background: var(--meron-red);
}

.bead-plate-road__cell--wala {
  background: var(--wala-blue);
}

.bead-plate-road__cell--draw {
  background: var(--accent-green);
}

.bead-plate-road__cell--cancelled {
  background: #6b7280;
}
