/* =========================================================
   OTP — Shared Styles
   Used by all OTP app pages: dashboard, timer, history, payouts.
   ========================================================= */

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

:root {
  /* Brand & surface colors */
  --black:    #060608;
  --black2:   #0d0d12;
  --surface:  #12121a;
  --surface2: #1a1a26;

  /* Accents */
  --blue:      #3bb8f5;
  --blue-dim:  #1a6fa8;
  --blue-glow: rgba(59,184,245,0.13);

  --red:      #e02020;
  --red-dim:  #8a1212;
  --red-glow: rgba(224,32,32,0.13);

  --green:     #22c55e;
  --green-dim: #166534;
  --green-glow: rgba(34,197,94,0.13);

  --gold:     #f0c040;
  --silver:   #a0a8b8;
  --bronze:   #c87040;

  /* Text */
  --white: #f0f0f8;
  --muted: #6a6a80;

  /* Borders */
  --border: rgba(255,255,255,0.07);

  /* Semantic for timer */
  --warning: #e67e22;
  --danger:  #e74c3c;
}

/* Both html AND body need overflow-x:hidden on iOS/WKWebView — without the
   rule on html, a single over-wide child can still scroll the whole page
   horizontally (visible in Capacitor as the "sideways drag" symptom).
   width: 100% + max-width: 100vw caps the layout to the viewport so a
   mis-sized child shows up as a clipped element, not a scrolling page. */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}
html { scroll-behavior: smooth; }

body {
  background-color: var(--black);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(59,184,245,0.05) 0%, transparent 55%),
    repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(255,255,255,0.01) 4px, rgba(255,255,255,0.01) 8px);
  min-height: 100vh;
  font-family: 'Barlow', sans-serif;
  font-weight: 400;
  line-height: 1.6;
  color: var(--white);
  overflow-x: hidden;
}

/* Defensive — prevent common offenders from pushing the page wider than
   the viewport on narrow screens. Scoped to .is-native + narrow widths so
   it only kicks in where it matters.  */
img, video, canvas, svg { max-width: 100%; height: auto; }
pre, code { white-space: pre-wrap; word-wrap: break-word; }
.is-native table { max-width: 100%; }
@media (max-width: 500px) {
  /* On narrow phones, reduce the chance of long words / URLs breaking out. */
  body { word-break: break-word; overflow-wrap: anywhere; }
}

/* =========================================================
   NAVIGATION
   ========================================================= */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  height: 64px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(6,6,8,0.9);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  cursor: pointer;
}
.nav-logo-img { width: 34px; height: 34px; object-fit: contain; }
.nav-logo-text { display: flex; flex-direction: column; line-height: 1; }
.nav-logo-text span:first-child {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.12em;
  color: var(--white);
}
.nav-logo-text span:last-child {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.58rem;
  letter-spacing: 0.35em;
  color: var(--blue);
  text-transform: uppercase;
}

.nav-logo-wide {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 16px;
  border-radius: 3px;
  transition: all 0.2s;
  border: 1px solid transparent;
}
.nav-link:hover { color: var(--white); }
.nav-link.active {
  color: var(--blue);
  border-color: var(--blue-dim);
  background: rgba(59,184,245,0.08);
}

.nav-right { display: flex; align-items: center; gap: 10px; }
.nav-user {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(59,184,245,0.1);
  border: 1px solid var(--blue-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Bebas Neue', sans-serif;
  font-size: 0.85rem;
  color: var(--blue);
}

/* =========================================================
   PAGE LAYOUT
   ========================================================= */
.page {
  padding: 88px 32px 48px;
  max-width: 1200px;
  margin: 0 auto;
}
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}
.page-eyebrow {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.4em;
  text-transform: uppercase;
  color: var(--blue);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.page-eyebrow::before {
  content: '';
  width: 20px;
  height: 1px;
  background: var(--blue-dim);
}
.page-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: 0.07em;
  color: var(--white);
  line-height: 1;
}
.page-title .accent-blue { color: var(--blue); }
.page-title .accent-red  { color: var(--red); }
.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* =========================================================
   BUTTONS
   ========================================================= */
.btn,
.btn-sm {
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  font-weight: 700;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  white-space: nowrap;
}
.btn { font-size: 0.75rem; padding: 10px 24px; }
.btn-sm { font-size: 0.72rem; letter-spacing: 0.18em; padding: 7px 18px; }

.btn-primary,
.btn-red {
  background: var(--red);
  color: var(--white);
  border: 1px solid var(--red);
  box-shadow: 0 0 18px rgba(224,32,32,0.2);
}
.btn-primary:hover,
.btn-red:hover {
  background: #f03030;
  box-shadow: 0 0 28px rgba(224,32,32,0.35);
  transform: translateY(-1px);
}

.btn-secondary,
.btn-outline {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}
.btn-secondary:hover,
.btn-outline:hover {
  color: var(--white);
  border-color: rgba(255,255,255,0.2);
}

.btn-accent,
.btn-blue {
  background: transparent;
  color: var(--blue);
  border: 1px solid var(--blue-dim);
}
.btn-accent:hover,
.btn-blue:hover {
  background: var(--blue-glow);
  border-color: var(--blue);
}

.btn-green {
  background: var(--green);
  color: var(--black);
  border: 1px solid var(--green);
  font-weight: 700;
}
.btn-green:hover { background: #30d060; }

/* =========================================================
   FORM CONTROLS
   ========================================================= */
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }

.form-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-input,
.form-select {
  background: var(--black2);
  border: 1px solid var(--border);
  color: var(--white);
  font-family: 'Barlow', sans-serif;
  font-size: 0.95rem;
  padding: 9px 12px;
  border-radius: 3px;
  outline: none;
  transition: border-color 0.2s;
  width: 100%;
}
.form-input:focus,
.form-select:focus { border-color: var(--blue-dim); }
.form-input::placeholder { color: rgba(106,106,128,0.5); }
.form-select { cursor: pointer; }
.form-select option { background: var(--black2); }

/* Date inputs — make the whole field click to open the picker and brighten the icon */
.form-input[type="date"],
.form-input[type="time"],
.form-input[type="datetime-local"] {
  cursor: pointer;
  position: relative;
  color-scheme: dark;            /* enables dark variant of native date picker UI */
}
/* Make the native picker indicator larger, brighter, and cover the whole field
   so clicking anywhere opens the calendar in Chromium browsers */
.form-input[type="date"]::-webkit-calendar-picker-indicator,
.form-input[type="time"]::-webkit-calendar-picker-indicator,
.form-input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(1) brightness(0.85);
  opacity: 0.85;
  padding: 4px;
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 100%;          /* the indicator covers the whole input — click anywhere */
  background: transparent;
}
.form-input[type="date"]::-webkit-calendar-picker-indicator:hover { opacity: 1; }

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

/* =========================================================
   CARDS & PANELS
   ========================================================= */
.section-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
}
.section-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-card-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: var(--white);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-card-title .dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 6px var(--blue);
}
.section-card-title .dot.red   { background: var(--red);   box-shadow: 0 0 6px var(--red); }
.section-card-title .dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.section-card-body { padding: 20px; }

/* =========================================================
   STAT TILES
   ========================================================= */
.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s;
}
.stat-tile::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent-color, var(--blue-dim)), transparent);
}
.stat-tile:hover { border-color: rgba(59,184,245,0.2); }
.stat-tile-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.stat-tile-value {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 2.2rem;
  letter-spacing: 0.05em;
  line-height: 1;
  color: var(--accent-color, var(--blue));
}
.stat-tile-sub {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-top: 4px;
}
.stat-tile.red   { --accent-color: var(--red); }
.stat-tile.green { --accent-color: var(--green); }
.stat-tile.white { --accent-color: var(--white); }

/* =========================================================
   BADGES
   ========================================================= */
.badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 2px;
  display: inline-block;
}
.badge-complete,
.badge-c {
  background: rgba(34,197,94,0.1);
  border: 1px solid var(--green-dim);
  color: var(--green);
}
.badge-inprogress,
.badge-ip {
  background: rgba(59,184,245,0.1);
  border: 1px solid var(--blue-dim);
  color: var(--blue);
}
.badge-upcoming {
  background: rgba(224,32,32,0.1);
  border: 1px solid var(--red-dim);
  color: var(--red);
}

/* =========================================================
   MODAL
   ========================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--black2);
  border: 1px solid var(--border);
  border-radius: 4px;
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 28px 32px;
  position: relative;
}
.modal::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--blue-dim), transparent);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 14px;
}
.modal-title {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.4rem;
  letter-spacing: 0.1em;
  color: var(--blue);
}
.modal-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.modal-close:hover {
  color: var(--white);
  border-color: rgba(255,255,255,0.2);
}
.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}

/* =========================================================
   ANIMATIONS
   ========================================================= */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-danger {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.2; }
}

/* =========================================================
   UTILITIES
   ========================================================= */
.text-blue   { color: var(--blue); }
.text-red    { color: var(--red); }
.text-green  { color: var(--green); }
.text-muted  { color: var(--muted); }
.text-white  { color: var(--white); }

/* =========================================================
   RESPONSIVE
   ========================================================= */
@media (max-width: 768px) {
  /* Hide the top nav entirely on mobile — the fixed .mobile-bottom-nav
     covers all navigation. This reclaims the ~70px of empty space the
     top nav was leaving behind on every page. */
  nav:not(.mobile-bottom-nav) { display: none !important; }
  /* Pages that reserved space for the top nav no longer need it.
     Catch both the generic .page and any per-page .*-page container. */
  .page { padding: 14px 16px 40px; }
  body { padding-top: 0 !important; }
  [class$="-page"] { padding-top: 14px !important; }
  .form-row { grid-template-columns: 1fr; }
}

/* =========================================================
   TOURNAMENT SUB-NAV
   Secondary navigation that appears at the top of tournament-specific
   pages (Dashboard, Timer, Tables, Payouts).
   ========================================================= */
.subnav {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  z-index: 90;
  background: rgba(13,13,18,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 8px 32px;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
}
.subnav::-webkit-scrollbar { height: 4px; }
.subnav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.subnav-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  padding-right: 14px;
  margin-right: 8px;
  border-right: 1px solid var(--border);
  white-space: nowrap;
  flex-shrink: 0;
}

.subnav-link {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 3px;
  text-decoration: none;
  color: var(--muted);
  border: 1px solid transparent;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.subnav-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.03);
}
.subnav-link.active {
  color: var(--blue);
  background: var(--blue-glow);
  border-color: var(--blue-dim);
}

/* When sub-nav is present, push the page content down a bit more */
.has-subnav .page,
.has-subnav .container,
.has-subnav [class$="-page"] {
  padding-top: 116px;
}

@media (max-width: 768px) {
  .subnav { padding: 6px 16px; }
  .subnav-label { display: none; }
  .has-subnav .page,
  .has-subnav .container,
  .has-subnav [class$="-page"] {
    padding-top: 110px;
  }
}

/* Hide sub-nav in fullscreen mode (timer/tables) */
body.fs-active .subnav { display: none !important; }
body.fs-active .has-subnav .page,
body.fs-active .has-subnav .container,
body.fs-active .has-subnav [class$="-page"] {
  padding-top: 16px;
}

/* =========================================================
   TOURNAMENT ANNOUNCEMENTS
   Toast-style broadcasts that appear on Timer and Tables pages.
   ========================================================= */
.announce-toast {
  position: fixed;
  top: 130px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 700;
  background: linear-gradient(135deg, rgba(224,32,32,0.95), rgba(59,184,245,0.92));
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 18px 28px;
  min-width: 320px;
  max-width: 600px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.05);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  backdrop-filter: blur(8px);
}
.announce-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.announce-toast::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #fff, transparent);
  opacity: 0.5;
}
.announce-eyebrow {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.85);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.announce-icon {
  font-size: 0.95rem;
}
.announce-text {
  font-family: 'Bebas Neue', sans-serif;
  font-size: 1.45rem;
  letter-spacing: 0.05em;
  color: #fff;
  line-height: 1.15;
  word-break: break-word;
}
.announce-meta {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.62rem;
  letter-spacing: 0.15em;
  color: rgba(255,255,255,0.7);
  margin-top: 6px;
}

/* Pulsing dot on the announce eyebrow */
.announce-pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #fff;
  animation: announcePulse 1.2s ease-in-out infinite;
}
@keyframes announcePulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* In fullscreen mode, position higher since the nav is gone */
body.fs-active .announce-toast { top: 60px; }

@media (max-width: 600px) {
  .announce-toast { min-width: 280px; max-width: calc(100vw - 32px); padding: 14px 18px; }
  .announce-text { font-size: 1.15rem; }
}

/* TD Broadcast button & modal */
.broadcast-btn {
  background: rgba(224,32,32,0.08);
  border: 1px solid var(--red-dim);
  color: var(--red);
}
.broadcast-btn:hover {
  background: rgba(224,32,32,0.16);
  color: #fff;
}

.quick-pick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 14px;
}
.quick-pick-btn {
  background: var(--black);
  border: 1px solid var(--border);
  color: var(--white);
  padding: 9px 12px;
  border-radius: 3px;
  cursor: pointer;
  text-align: left;
  font-family: 'Barlow', sans-serif;
  font-size: 0.82rem;
  transition: all 0.15s;
}
.quick-pick-btn:hover {
  border-color: var(--blue-dim);
  background: var(--blue-glow);
}
.quick-pick-btn-icon { margin-right: 6px; }

/* =========================================================
   MOBILE BOTTOM NAVIGATION
   Replaces the top nav on phones with a fixed bottom bar.
   Standard mobile app pattern — way more thumb-friendly.
   ========================================================= */
.mobile-bottom-nav {
  display: none;       /* hidden on desktop */
}

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex;
    position: fixed;
    top: auto !important;         /* undo the generic `nav { top: 0 }` rule */
    bottom: 0; left: 0; right: 0;
    z-index: 500;
    background: rgba(10,10,15,0.96);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
    padding: 6px 4px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom));   /* iPhone home indicator */
    justify-content: space-around;
    align-items: stretch;
  }
  .mobile-bottom-nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 8px 4px;
    text-decoration: none;
    color: var(--muted);
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: color 0.15s;
    min-height: 50px;     /* touch target */
  }
  .mobile-bottom-nav-link:hover { color: var(--white); }
  .mobile-bottom-nav-link.active {
    color: var(--blue);
  }
  .mobile-bottom-nav-icon {
    font-size: 1.3rem;
    line-height: 1;
  }

  /* Add space at the bottom of every page so content isn't hidden behind the bar */
  body { padding-bottom: 80px; }
}

/* ─────────────────────────────────────────────────────────────────
 * Native app (Capacitor) — hide pricing/upgrade UI
 * Option A: web-only subscriptions. In iOS/Android app wrappers,
 * all upgrade CTAs are hidden to comply with Apple Guideline 3.1.3
 * and keep Google Play review friction low. Managing an existing
 * subscription (via Stripe Portal) is still allowed.
 * Toggle via the .is-native class on <body>, set by otp-platform.js.
 * ───────────────────────────────────────────────────────────────── */

/* Hide anything explicitly marked as a pricing/upgrade CTA */
.is-native .pricing-cta,
.is-native .upgrade-cta,
.is-native .upsell-card,
.is-native [data-hide-in-app] {
  display: none !important;
}

/* Hide the "View pricing plans" link on profile */
.is-native .pricing-link {
  display: none !important;
}

/* ═════════════════════════════════════════════════════════════════
 *  MOBILE POLISH LAYER
 *  Applies on narrow viewports (phone-size browsers) and in the
 *  Capacitor native app. Desktop remains unchanged.
 *  Scoped tighter than the existing @media blocks above so they
 *  cascade cleanly on top of them.
 * ═════════════════════════════════════════════════════════════════ */

/* ─── Universal touch + iOS fixes ────────────────────────────────── */

/* Prevent iOS from auto-zooming on input focus. 16px is the magic threshold. */
@media (max-width: 768px) {
  input, select, textarea,
  .form-input, .form-select, .form-textarea {
    font-size: 16px !important;
  }
}

/* iOS safe-area insets — notch at top, home indicator at bottom.
   Native app only, so the web view doesn't double-pad. */
.is-native nav {
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
}
.is-native body {
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* ─── Phone layout (<= 480px) ────────────────────────────────────── */

@media (max-width: 480px) {

  /* Tighter page padding — reclaim the edges */
  body { padding: 0 !important; }
  main, .page-content, .container { padding: 14px !important; }

  /* ─── Nav: compact, horizontal-scroll, no overflow ─── */
  nav {
    padding: 10px 14px !important;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav::-webkit-scrollbar { display: none; }
  .nav-logo-text { display: none; } /* icon only on phones to save space */
  .nav-logo-img { width: 28px; height: 28px; }
  .nav-links {
    gap: 2px;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-link {
    padding: 8px 10px !important;
    font-size: 0.68rem !important;
    letter-spacing: 0.1em !important;
    white-space: nowrap;
    min-height: 44px;
    display: flex;
    align-items: center;
  }
  .nav-right { gap: 6px; }
  .nav-user { padding: 4px 8px; }

  /* ─── Buttons: touch-friendly ─── */
  .btn, .btn-sm {
    min-height: 44px;
    padding: 11px 18px !important;
    letter-spacing: 0.14em !important;
  }
  /* Primary action buttons in modals and forms become full-width */
  .modal-actions .btn,
  .modal-actions .btn-sm {
    flex: 1 !important;
    min-width: 0;
  }

  /* ─── Headings: slightly smaller, less dominant ─── */
  h1 { font-size: 1.6rem !important; }
  h2 { font-size: 1.3rem !important; }
  h3 { font-size: 1.05rem !important; }
  .page-eyebrow { font-size: 0.6rem !important; letter-spacing: 0.2em !important; }
  .page-title { font-size: 1.5rem !important; }

  /* ─── Cards: trim padding, flatter corners ─── */
  .home-card, .profile-card, .dashboard-card, .card {
    padding: 14px !important;
    border-radius: 4px !important;
    margin-bottom: 12px !important;
  }
  .profile-card-header, .card-header {
    padding-bottom: 10px !important;
    margin-bottom: 10px !important;
  }

  /* ─── Grid collapses ─── */
  /* Any 3+ column grid: single column on phones; 2-column where sensible */
  .grid-3, .grid-4 { grid-template-columns: 1fr !important; }
  .stat-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .form-row { grid-template-columns: 1fr !important; gap: 10px !important; }

  /* Stat tiles — bigger key number, trimmer label */
  .stat-tile, .stat-card {
    padding: 12px !important;
  }
  .stat-value, .stat-number {
    font-size: 1.5rem !important;
  }
  .stat-label {
    font-size: 0.62rem !important;
    letter-spacing: 0.14em !important;
  }

  /* ─── Form fields ─── */
  .form-field { margin-bottom: 12px !important; }
  .form-label {
    font-size: 0.65rem !important;
    letter-spacing: 0.14em !important;
    margin-bottom: 5px !important;
  }
  .form-input, .form-select, .form-textarea {
    padding: 11px 12px !important;
    min-height: 44px;
  }

  /* ─── Modals: closer to fullscreen so content fits ─── */
  .modal-overlay .modal {
    width: calc(100% - 20px) !important;
    max-width: 100% !important;
    max-height: calc(100vh - 60px) !important;
    margin: 20px 10px !important;
    border-radius: 6px !important;
  }
  .modal-header {
    padding: 14px 16px !important;
  }
  .modal-form {
    padding: 14px 16px !important;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
  }

  /* ─── Tournament tables view ─── */
  .seat-row {
    min-height: 48px;
    padding: 10px 12px !important;
  }
  .seat-num {
    width: 28px !important;
    font-size: 1.05rem !important;
  }
  .seat-name {
    font-size: 0.95rem !important;
  }
  .seat-status {
    font-size: 0.6rem !important;
    padding: 4px 7px !important;
    letter-spacing: 0.1em !important;
  }

  /* ─── Action menu (seat tap menu) — never clip off-screen ─── */
  .action-menu {
    width: calc(100vw - 20px) !important;
    max-width: 320px !important;
    left: 10px !important;
    right: 10px !important;
  }
  .action-item {
    padding: 14px 16px !important;
    min-height: 44px;
  }

  /* ─── Pricing cards stack cleanly ─── */
  .pricing-grid {
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }
  .tier-card {
    padding: 20px !important;
  }

  /* ─── Hide decorative pieces that steal screen on phones ─── */
  .decorative-only,
  .hero-image-side,
  .nav-right .nav-user-email {
    display: none !important;
  }

  /* ─── Footer: stack + tighten ─── */
  footer {
    flex-direction: column !important;
    gap: 10px !important;
    padding: 20px 14px !important;
    text-align: center;
  }

  /* ─── Timer page: biggest digits possible ─── */
  .timer-display, .big-clock {
    font-size: clamp(3.5rem, 20vw, 7rem) !important;
    letter-spacing: 0.02em !important;
  }
}

/* ─── Native-app-only polish (any viewport size) ────────────────── */

.is-native body {
  /* Prevent accidental text selection on long-press */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* Keep inputs selectable */
.is-native input,
.is-native textarea,
.is-native [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* Hide elements that only make sense on the web (links to desktop features, etc) */
.is-native .web-only-hint {
  display: none !important;
}

/* Native status bar area — fill with the app's dark theme so there's no
   white strip at the top of the webview on iOS. */
.is-native::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0;
  height: env(safe-area-inset-top, 0px);
  background: var(--black, #060608);
  z-index: 10000;
}

/* ─── Larger-phone / small-tablet (481–768px) ─────────────────── */

@media (min-width: 481px) and (max-width: 768px) {
  /* 2-up stat tiles instead of 1-up */
  .stat-grid { grid-template-columns: 1fr 1fr !important; }
  /* Pricing stays 1-column for readability */
  .pricing-grid { grid-template-columns: 1fr !important; }
}

/* ─── Blind-level table on mobile ────────────────────────────────── */
/* The level-table has 6 narrow columns of inputs that collectively
 * overflow a phone in portrait. Keep horizontal scroll (wrapper does that)
 * but tighten inputs so more fits before scrolling kicks in. */
@media (max-width: 480px) {
  .level-table-wrap {
    margin: 0 -14px;   /* bleed to screen edge so scroll area feels generous */
    padding: 0 14px;
  }
  .level-table th,
  .level-table td {
    padding: 6px 8px !important;
  }
  .level-table .level-input {
    width: 64px !important;
    font-size: 14px !important;
    padding: 8px 6px !important;
  }
  .level-table .level-input.compact {
    width: 56px !important;
  }
  .level-table .level-num {
    width: 42px !important;
    font-size: 0.9rem !important;
  }
  /* First column (level #) sticks when scrolling right */
  .level-table thead th:first-child,
  .level-table tbody td:first-child {
    position: sticky;
    left: 0;
    background: var(--black2, #060608);
    z-index: 1;
  }
  /* Add a swipe hint at the top */
  .level-table-wrap::before {
    content: "← swipe to see all columns →";
    display: block;
    text-align: center;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 0.6rem;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 4px 0 2px;
    opacity: 0.6;
  }
}
