/* =====================================================
   RESET
   ===================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* =====================================================
   TOKENS
   ===================================================== */
:root {
  --boy:        #3B82F6;
  --boy-bg:     #EFF6FF;
  --boy-border: #BFDBFE;

  --girl:        #EC4899;
  --girl-bg:     #FDF2F8;
  --girl-border: #FBCFE8;

  --green:       #16A34A;
  --green-bg:    #DCFCE7;

  --page-bg:   #F8F5FF;
  --surface:   #FFFFFF;
  --border:    #E8E3F0;
  --shadow:    0 1px 3px rgba(0,0,0,0.06), 0 4px 16px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.14);

  --text-primary:   #1A1035;
  --text-secondary: #6B5F7C;
  --text-muted:     #A899B8;

  --radius:    16px;
  --radius-sm: 10px;

  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Outfit', system-ui, sans-serif;
}

/* =====================================================
   BASE
   ===================================================== */
html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =====================================================
   OFFLINE BANNER
   ===================================================== */
.offline-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 999;
  background: #EF4444;
  color: #fff;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  padding: 8px 16px;
}
.offline-banner.visible { display: block; }

/* =====================================================
   PAGE + BACKGROUND
   ===================================================== */
.page {
  position: relative;
  min-height: 100dvh;
}

.bg-deco {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-circle {
  position: absolute;
  border-radius: 50%;
  opacity: 0.45;
  filter: blur(70px);
}

.bg-c1 {
  width: 420px; height: 420px;
  background: #C7D8FF;
  top: -150px; left: -100px;
}
.bg-c2 {
  width: 360px; height: 360px;
  background: #FFC7E8;
  bottom: -100px; right: -80px;
}
.bg-c3 {
  width: 280px; height: 280px;
  background: #E8D5FF;
  top: 45%; left: 35%;
}

/* =====================================================
   APP CONTAINER
   ===================================================== */
.app {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px 100px;
}

/* =====================================================
   HEADER
   ===================================================== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0 16px;
  gap: 12px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-icon {
  font-size: 34px;
  line-height: 1;
  flex-shrink: 0;
}

.header-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.header-sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 3px;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D1D5DB;
  transition: background 0.3s;
  flex-shrink: 0;
}
.conn-dot.online  { background: var(--green); }
.conn-dot.offline { background: #EF4444; }

.status-badge {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}
.status-badge.open      { background: var(--boy-bg);   color: var(--boy); }
.status-badge.locked    { background: #FEF3C7;          color: #92400E; }
.status-badge.resolved  { background: var(--green-bg);  color: var(--green); }
.status-badge.cancelled { background: #F3F4F6;          color: #6B7280; }

/* =====================================================
   TABS
   ===================================================== */
.tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,0.7);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
}

.tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-active {
  background: var(--surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(0,0,0,0.1);
}

/* =====================================================
   TAB PANELS
   ===================================================== */
.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tab-panel.hidden { display: none; }

/* =====================================================
   CARD BASE
   ===================================================== */
.question-card,
.trend-card,
.parent-card,
.history-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.card-eyebrow {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* =====================================================
   QUESTION CARD
   ===================================================== */
.question-text {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 8px;
}

.pot-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* =====================================================
   LOCKED NOTICE
   ===================================================== */
.notice-locked {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: #92400E;
  text-align: center;
}

/* =====================================================
   RESULT BANNER
   ===================================================== */
.result-banner {
  border-radius: var(--radius);
  padding: 18px 20px;
  animation: fadeSlideDown 0.3s ease;
}
.result-banner.win {
  background: linear-gradient(135deg, #F0FFF4, #DCFCE7);
  border: 1px solid #86EFAC;
}
.result-banner.loss {
  background: linear-gradient(135deg, #FFF5F5, #FEE2E2);
  border: 1px solid #FCA5A5;
}
.result-banner.refund {
  background: linear-gradient(135deg, #FFFBEB, #FEF3C7);
  border: 1px solid #FDE68A;
}
.result-banner-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
}
.result-banner.win   .result-banner-title { color: #14532D; }
.result-banner.loss  .result-banner-title { color: #7F1D1D; }
.result-banner.refund .result-banner-title { color: #78350F; }
.result-banner-rows { display: flex; flex-direction: column; gap: 5px; }
.result-banner-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}
.result-banner-row span:first-child { color: var(--text-secondary); }
.result-banner-row span:last-child  { font-weight: 600; }

/* =====================================================
   TREND BAR
   ===================================================== */
.trend-bar {
  display: flex;
  height: 40px;
  border-radius: 12px;
  overflow: hidden;
  gap: 3px;
  margin-bottom: 10px;
}

.trend-boy, .trend-girl {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
  min-width: 0;
}

.trend-boy {
  background: linear-gradient(90deg, #2563EB, var(--boy));
  border-radius: 10px 0 0 10px;
}
.trend-girl {
  background: linear-gradient(90deg, #DB2777, var(--girl));
  border-radius: 0 10px 10px 0;
}

.trend-label {
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,0.25);
  white-space: nowrap;
  overflow: hidden;
}

.trend-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: 8px;
}
.legend-swatch:first-child { margin-left: 0; }
.legend-boy  { background: var(--boy); }
.legend-girl { background: var(--girl); }

/* =====================================================
   OUTCOME CARDS
   ===================================================== */
.outcomes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.outcome-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.outcome-card.outcome-boy.has-my-bet {
  border-color: var(--boy);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1), var(--shadow);
}
.outcome-card.outcome-girl.has-my-bet {
  border-color: var(--girl);
  box-shadow: 0 0 0 3px rgba(236,72,153,0.1), var(--shadow);
}
.outcome-card.is-winner {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.1), var(--shadow);
}
.outcome-card.is-loser {
  opacity: 0.45;
  filter: grayscale(0.4);
}

/* card top section */
.outcome-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px 14px;
}

.outcome-emoji {
  font-size: 42px;
  line-height: 1;
  flex-shrink: 0;
}

.outcome-info { flex: 1; min-width: 0; }

.outcome-label {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
}
.outcome-boy  .outcome-label { color: var(--boy); }
.outcome-girl .outcome-label { color: var(--girl); }

.outcome-summary {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 4px;
}

.outcome-odds {
  font-size: 14px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 20px;
  flex-shrink: 0;
}
.outcome-boy  .outcome-odds { background: var(--boy-bg);  color: var(--boy); }
.outcome-girl .outcome-odds { background: var(--girl-bg); color: var(--girl); }

/* winner ribbon */
.winner-ribbon {
  background: var(--green-bg);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  padding: 6px;
  border-top: 1px solid #BBF7D0;
  border-bottom: 1px solid #BBF7D0;
}

/* bettor list */
.bettor-list { border-top: 1px solid var(--border); }

.bettor-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
}
.bettor-row:last-child { border-bottom: none; }

.bettor-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.outcome-boy  .bettor-avatar { background: var(--boy-bg);  color: var(--boy); }
.outcome-girl .bettor-avatar { background: var(--girl-bg); color: var(--girl); }

.bettor-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bettor-you {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.bettor-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.bettor-edit-btn {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.bettor-edit-btn:hover { background: var(--page-bg); }

.bettor-del-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.15s;
}
.bettor-del-btn:hover { color: #EF4444; }

/* outcome footer (bet button) */
.outcome-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.bet-btn {
  width: 100%;
  padding: 13px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  transition: opacity 0.15s, transform 0.1s;
}
.bet-btn:active { opacity: 0.8; transform: scale(0.98); }
.bet-btn.faded  { opacity: 0.4; cursor: not-allowed; transform: none; }
.outcome-boy  .bet-btn:not(.faded) { background: var(--boy); }
.outcome-girl .bet-btn:not(.faded) { background: var(--girl); }
.bet-btn.faded { background: #9CA3AF; }

/* =====================================================
   BET BOTTOM SHEET
   ===================================================== */
.sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(15, 5, 30, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  animation: fadeIn 0.2s ease;
}

.sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 0 20px 48px;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

.sheet-drag {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 14px auto 20px;
}

.sheet-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  margin-bottom: 4px;
}
.sheet-title.boy  { color: var(--boy); }
.sheet-title.girl { color: var(--girl); }

.sheet-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 22px;
}

/* name field */
.sheet-field {
  margin-bottom: 16px;
}
.sheet-field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.sheet-text-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 500;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--page-bg);
  color: var(--text-primary);
  transition: border-color 0.2s;
  -webkit-appearance: none;
  outline: none;
}
.sheet-text-input:focus { border-color: var(--text-secondary); }
.sheet-text-input.boy-focus:focus  { border-color: var(--boy); }
.sheet-text-input.girl-focus:focus { border-color: var(--girl); }

.sheet-field-hint {
  font-size: 12px;
  font-weight: 500;
  margin-top: 5px;
  min-height: 16px;
}
.hint-ok  { color: var(--green); }
.hint-err { color: #EF4444; }

/* amount input */
.sheet-amount-wrap {
  position: relative;
  margin-bottom: 12px;
}
.sheet-amount-prefix {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-secondary);
  pointer-events: none;
}
.sheet-amount-input {
  width: 100%;
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 700;
  text-align: right;
  padding: 14px 20px 14px 48px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--page-bg);
  color: var(--text-primary);
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.2s;
}
.sheet-amount-input.boy-focus:focus  { border-color: var(--boy); }
.sheet-amount-input.girl-focus:focus { border-color: var(--girl); }

.sheet-payout {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 22px;
}
.sheet-payout-val {
  font-weight: 700;
  color: var(--text-primary);
  font-size: 14px;
}

.sheet-buttons {
  display: flex;
  gap: 10px;
}

.sheet-cancel-btn {
  padding: 14px 20px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.sheet-cancel-btn:hover { background: var(--page-bg); }

.sheet-confirm-btn {
  flex: 1;
  padding: 14px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  transition: opacity 0.15s;
}
.sheet-confirm-btn:active { opacity: 0.8; }
.sheet-confirm-btn.boy  { background: var(--boy); }
.sheet-confirm-btn.girl { background: var(--girl); }

/* =====================================================
   PARENT PANEL
   ===================================================== */
.parent-section {
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.parent-section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.parent-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.text-input {
  width: 100%;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 400;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--page-bg);
  color: var(--text-primary);
  -webkit-appearance: none;
  outline: none;
  transition: border-color 0.2s;
}
.text-input:focus { border-color: var(--text-secondary); }

.parent-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.parent-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: opacity 0.15s;
}
.parent-btn:active { opacity: 0.8; }
.btn-start  { background: #1A1035; color: #fff; }
.btn-lock   { background: #FFFBEB; color: #92400E; border: 1.5px solid #FDE68A; }
.btn-cancel { background: #FFF5F5; color: #991B1B; border: 1.5px solid #FECACA; }

.reveal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.reveal-btn {
  padding: 16px 10px;
  border-radius: 14px;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: opacity 0.15s;
}
.reveal-btn:not(:disabled):active { opacity: 0.8; }
.reveal-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.reveal-btn.boy  { background: linear-gradient(135deg, #1D4ED8, var(--boy)); }
.reveal-btn.girl { background: linear-gradient(135deg, #BE185D, var(--girl)); }
.reveal-btn-emoji { font-size: 26px; }

.all-bets-list { display: flex; flex-direction: column; gap: 8px; }
.all-bet-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--page-bg);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.all-bet-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.all-bet-dot.boy  { background: var(--boy); }
.all-bet-dot.girl { background: var(--girl); }
.all-bet-name  { flex: 1; font-size: 13px; font-weight: 600; }
.all-bet-side  { font-size: 12px; color: var(--text-secondary); }
.all-bet-amt   { font-size: 13px; font-weight: 700; }

/* =====================================================
   HISTORY
   ===================================================== */
.history-card { margin-top: 4px; }
.history-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
}
.history-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.history-item-title { font-size: 13px; font-weight: 600; margin-bottom: 3px; }
.history-item-meta  { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; }
.history-item-bet   { font-size: 11px; color: var(--text-secondary); }

/* =====================================================
   TOAST
   ===================================================== */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: #1A1035;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 20px;
  border-radius: 30px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  opacity: 0;
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
  transition: opacity 0.25s ease;
}

/* =====================================================
   SHARED UTILITIES
   ===================================================== */
.empty-msg {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* =====================================================
   ANIMATIONS
   ===================================================== */
@keyframes fadeSlideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: none; }
}

/* =====================================================
   DESKTOP ADJUSTMENTS
   ===================================================== */
@media (min-width: 520px) {
  .app { padding-bottom: 60px; }
  .sheet-overlay { align-items: center; }
  .sheet {
    border-radius: 24px;
    margin-bottom: 40px;
  }
}
