/* style.css — Kura's Cards
   Foundation layer only. Component-specific styles live in each page module.
   All design tokens are CSS custom properties — never hardcode values elsewhere.
   ─────────────────────────────────────────────────────────────────────────── */


/* ── RESET ──────────────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--color-ink);
  background: var(--color-bg);
  min-height: 100dvh;
  overflow: hidden; /* screens handle their own scroll */
}

img, svg {
  display: block;
  max-width: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
}

ul, ol { list-style: none; }

a { color: inherit; text-decoration: none; }


/* ── DESIGN TOKENS ───────────────────────────────────────────────────────────
   Single source of truth for all colors, spacing, radius, timing, and z-index.
   Never use raw values — always reference a variable.
   ──────────────────────────────────────────────────────────────────────────── */

:root {

  /* ── COLORS — parchment theme ────────────────────────────────────────────── */

  /* Base surfaces */
  --color-bg:             #F2DFC0;   /* warm parchment — main body */
  --color-surface:        #E8C99A;   /* deeper parchment — cards, stat blocks */
  --color-surface-raised: #EDD9A8;   /* slightly lifted surface */

  /* Dark ink — header, nav, buttons */
  --color-ink:            #1A1628;   /* deep navy black — primary text + surfaces */
  --color-ink-mid:        #2D2050;   /* mid ink — secondary dark surfaces */
  --color-ink-soft:       #3D2F6E;   /* soft ink — borders on dark surfaces */

  /* Gold accents */
  --color-gold:           #D4A96A;   /* primary gold — borders, badges, active nav */
  --color-gold-dark:      #8B6A3E;   /* dark gold — muted labels on parchment */
  --color-gold-light:     #F2DFC0;   /* lightest gold — text on dark surfaces */

  /* Action colors */
  --color-coral:          #C4513A;   /* primary action — buttons, alerts */
  --color-coral-hover:    #A8402B;   /* hover state */
  --color-coral-light:    #F5C4B3;   /* light coral — backgrounds */

  /* Accent blue */
  --color-blue:           #4A9FD4;   /* electric blue — info, secondary accent */
  --color-blue-light:     #6BBDE0;   /* lighter blue */

  /* Semantic */
  --color-success:        #0F6E56;   /* wins, positive states */
  --color-danger:         #993C1D;   /* losses, destructive states */
  --color-muted:          #9B8AB4;   /* muted purple — inactive nav, hints */
  --color-muted-dark:     #6B5F8A;   /* darker muted — inactive nav on dark bg */

  /* Text on surfaces */
  --color-text-primary:   #1A1628;   /* on parchment */
  --color-text-secondary: #8B6A3E;   /* labels, subtitles on parchment */
  --color-text-on-ink:    #E8C99A;   /* on dark ink surfaces */
  --color-text-muted:     #9B8AB4;   /* hints, disabled */

  /* Borders */
  --color-border:         #D4A96A;   /* standard border — gold */
  --color-border-ink:     #2D2050;   /* border on dark surfaces */
  --color-border-light:   rgba(212, 169, 106, 0.4); /* subtle border */


  /* ── PAPER TEXTURE ──────────────────────────────────────────────────────────
     SVG noise pattern embedded as data URI. Applied as a pseudo-element overlay
     on parchment surfaces at low opacity to simulate paper grain.
     Usage: add class .textured to any parchment surface.
  ──────────────────────────────────────────────────────────────────────────── */

  --texture-url: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='1'/%3E%3C/svg%3E");


  /* ── SPACING ─────────────────────────────────────────────────────────────── */

  --space-xs:   0.25rem;   /* 4px  */
  --space-sm:   0.5rem;    /* 8px  */
  --space-md:   0.75rem;   /* 12px */
  --space-lg:   1rem;      /* 16px */
  --space-xl:   1.5rem;    /* 24px */
  --space-2xl:  2rem;      /* 32px */
  --space-3xl:  3rem;      /* 48px */


  /* ── BORDER RADIUS ────────────────────────────────────────────────────────── */

  --radius-sm:    6px;    /* small elements — badges, pills */
  --radius-md:    10px;   /* stat cards, pack banner, inputs */
  --radius-lg:    14px;   /* panels, overlays, large cards */
  --radius-xl:    20px;   /* modal, phone shell */
  --radius-full:  9999px; /* pills, nav badges */
  --radius-none:  0;      /* sharp — match button, action strips */


  /* ── TYPOGRAPHY ──────────────────────────────────────────────────────────── */

  --font-size-xs:   0.6875rem;  /* 11px — labels, badges */
  --font-size-sm:   0.75rem;    /* 12px — secondary text */
  --font-size-md:   0.875rem;   /* 14px — body */
  --font-size-base: 1rem;       /* 16px — default */
  --font-size-lg:   1.125rem;   /* 18px — subheadings */
  --font-size-xl:   1.25rem;    /* 20px — headings */
  --font-size-2xl:  1.5rem;     /* 24px — large headings */
  --font-size-3xl:  2rem;       /* 32px — display */

  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-bold:   700;

  --line-height-tight:  1.2;
  --line-height-normal: 1.5;
  --line-height-loose:  1.7;

  --letter-spacing-tight:  -0.01em;
  --letter-spacing-normal:  0;
  --letter-spacing-wide:    0.04em;
  --letter-spacing-wider:   0.08em;


  /* ── TRANSITIONS ─────────────────────────────────────────────────────────── */

  --duration-fast:    100ms;
  --duration-normal:  175ms;   /* standard interaction feedback */
  --duration-slow:    250ms;   /* screen transitions, overlays */
  --duration-slower:  350ms;   /* larger layout changes */
  --easing-default:   cubic-bezier(0.4, 0, 0.2, 1);
  --easing-out:       cubic-bezier(0, 0, 0.2, 1);
  --easing-in:        cubic-bezier(0.4, 0, 1, 1);
  --easing-bounce:    cubic-bezier(0.34, 1.56, 0.64, 1);


  /* ── Z-INDEX SCALE ───────────────────────────────────────────────────────────
     Audit this table before adding any new z-index value.
     Never use a raw number — always reference a variable.
  ──────────────────────────────────────────────────────────────────────────── */

  --z-base:       0;     /* normal document flow */
  --z-card:       10;    /* card elements in hand and battlefield */
  --z-hud:        20;    /* match HUD — HP bars, timer, score */
  --z-anim:       50;    /* animation overlays — fireball, slash etc */
  --z-banner:     80;    /* challenge / invite banners */
  --z-overlay:    90;    /* disconnect, waiting, round result overlays */
  --z-modal:      200;   /* modal dialogs — above all page overlays */
  --z-toast:      300;   /* toast notifications — always on top */


  /* ── LAYOUT ──────────────────────────────────────────────────────────────── */

  --nav-height:        56px;
  --header-height:     52px;
  --max-width:         480px;   /* max app width on wide screens */
  --card-width:        120px;   /* standard card width in hand */
  --card-aspect:       calc(120px * 5 / 3);  /* 3:5 portrait ratio */
}


/* ── PAPER TEXTURE UTILITY ───────────────────────────────────────────────── */

.textured {
  position: relative;
  isolation: isolate;
}

.textured::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--texture-url);
  background-size: 200px 200px;
  opacity: 0.04;
  pointer-events: none;
  border-radius: inherit;
  z-index: 1;
}


/* ── SCREEN SYSTEM ───────────────────────────────────────────────────────── */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: var(--max-width);
  margin: 0 auto;
  overflow: hidden;
}

.screen--splash {
  background: var(--color-ink);
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
}

.screen--auth {
  background: var(--color-bg);
  overflow-y: auto;
  padding: var(--space-2xl) var(--space-xl);
}

.screen--hub {
  background: var(--color-bg);
}

.screen--lobby,
.screen--match,
.screen--match-end,
.screen--pack {
  background: var(--color-ink);
}

.screen--error {
  background: var(--color-ink);
  align-items: center;
  justify-content: center;
  gap: var(--space-xl);
  padding: var(--space-xl);
  text-align: center;
}


/* ── SPLASH ──────────────────────────────────────────────────────────────── */

.splash__logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.splash__img {
  width: 120px;
  height: 120px;
  object-fit: contain;
}

.splash__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-gold);
  letter-spacing: var(--letter-spacing-wide);
}

.splash__loading {
  font-size: var(--font-size-sm);
  color: var(--color-muted-dark);
  letter-spacing: var(--letter-spacing-wider);
}


/* ── AUTH ────────────────────────────────────────────────────────────────── */

.auth__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  margin-bottom: var(--space-2xl);
}

.auth__logo {
  width: 144px;
  height: 144px;
  object-fit: contain;
}

.auth__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-coral);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--color-coral) 0%, var(--color-gold) 60%, var(--color-coral) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth__tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-xl);
}

.auth__tab {
  flex: 1;
  padding: var(--space-sm) 0;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration-normal) var(--easing-default),
              border-color var(--duration-normal) var(--easing-default);
}

.auth__tab.active {
  color: var(--color-ink);
  border-bottom-color: var(--color-coral);
}

.auth__fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.auth__field-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.auth__label {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  letter-spacing: var(--letter-spacing-wide);
}

.auth__input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-md);
  color: var(--color-ink);
  transition: border-color var(--duration-normal) var(--easing-default);
}

.auth__input:focus {
  outline: none;
  border-color: var(--color-coral);
}

.auth__input::placeholder { color: var(--color-text-muted); }

.auth__error {
  font-size: var(--font-size-sm);
  color: var(--color-danger);
  margin-bottom: var(--space-md);
  min-height: 1.25rem;
}

/* Starter deck step */
.auth__deck-step {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.auth__deck-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-ink);
}

.auth__deck-sub {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-top: calc(-1 * var(--space-sm));
}

.starter-decks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.starter-deck-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-align: left;
  transition: border-color var(--duration-normal) var(--easing-default),
              background var(--duration-normal) var(--easing-default);
}

.starter-deck-card.selected {
  border-color: var(--color-coral);
  background: var(--color-coral-light);
}

.starter-deck-card__name {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  color: var(--color-ink);
}

.starter-deck-card__desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  line-height: var(--line-height-loose);
}


/* ── HUB ─────────────────────────────────────────────────────────────────── */

.hub__content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-gutter: stable;
}

.tab-panel {
  padding: var(--space-lg);
  min-height: 100%;
}


/* ── BOTTOM NAV ──────────────────────────────────────────────────────────── */

.bottom-nav {
  height: var(--nav-height);
  background: var(--color-ink);
  border-top: 1px solid var(--color-border-ink);
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-shrink: 0;
  padding: 0 var(--space-sm);
  padding-bottom: env(safe-area-inset-bottom); /* iPhone notch */
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-md);
  font-size: var(--font-size-xs);
  color: var(--color-muted-dark);
  border-radius: var(--radius-sm);
  position: relative;
  transition: color var(--duration-normal) var(--easing-default);
}

.nav-tab.active { color: var(--color-gold); }

.nav-tab__icon {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-tab__label {
  font-size: var(--font-size-xs);
  letter-spacing: var(--letter-spacing-wide);
}

.nav-tab__badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  background: var(--color-coral);
  color: var(--color-gold-light);
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}


/* ── BUTTONS ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-xl);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  transition: background var(--duration-normal) var(--easing-default),
              color var(--duration-normal) var(--easing-default),
              opacity var(--duration-normal) var(--easing-default),
              transform var(--duration-fast) var(--easing-default);
  -webkit-user-select: none;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }

/* Primary — coral on parchment */
.btn--primary {
  background: var(--color-coral);
  color: var(--color-gold-light);
  border: 1px solid var(--color-coral);
}
.btn--primary:hover { background: var(--color-coral-hover); }

/* Ghost — outlined */
.btn--ghost {
  background: transparent;
  color: var(--color-ink);
  border: 1px solid var(--color-border);
}
.btn--ghost:hover { background: var(--color-surface); }

/* Ghost on dark surfaces */
.btn--ghost-ink {
  background: transparent;
  color: var(--color-gold);
  border: 1px solid var(--color-border-ink);
}
.btn--ghost-ink:hover { background: var(--color-ink-mid); }

/* Danger */
.btn--danger {
  color: var(--color-danger);
  border-color: var(--color-danger);
}

/* Sizes */
.btn--full { width: 100%; }
.btn--sm   { padding: var(--space-xs) var(--space-md); font-size: var(--font-size-sm); }
.btn--lg   { padding: var(--space-lg) var(--space-2xl); font-size: var(--font-size-base); }

/* Sharp variant — for match actions */
.btn--sharp { border-radius: var(--radius-none); }


/* ── MODAL ───────────────────────────────────────────────────────────────── */

.overlay--modal {
  z-index: var(--z-modal);
  background: rgba(26, 22, 40, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.modal {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.modal__title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-ink);
}

.modal__body {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  line-height: var(--line-height-loose);
}

.modal__actions {
  display: flex;
  gap: var(--space-md);
  justify-content: flex-end;
}


/* ── TOAST ───────────────────────────────────────────────────────────────── */

.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--space-lg));
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: calc(100% - var(--space-2xl));
  max-width: 360px;
  pointer-events: none;
}

.toast {
  background: var(--color-ink);
  color: var(--color-gold-light);
  font-size: var(--font-size-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-ink);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity var(--duration-slow) var(--easing-out),
              transform var(--duration-slow) var(--easing-out);
  pointer-events: none;
  text-align: center;
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}


/* ── BANNERS & OVERLAYS ──────────────────────────────────────────────────── */

.overlay--banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-banner);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-md) var(--space-lg);
}

.banner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
}

.banner__label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  display: block;
}

.banner__name {
  font-size: var(--font-size-md);
  color: var(--color-ink);
  font-weight: var(--font-weight-bold);
}

.banner__title {
  font-size: var(--font-size-xs);
  color: var(--color-gold-dark);
}

.banner__actions {
  display: flex;
  gap: var(--space-sm);
  flex-shrink: 0;
}

/* Waiting / disconnect overlays */
.overlay--waiting,
.overlay--disconnect {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  background: rgba(26, 22, 40, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.waiting {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  text-align: center;
  max-width: 280px;
  width: 100%;
}

.waiting__msg {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
}

.waiting__name {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-ink);
}

/* Round result flash */
.overlay--round-result {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.round-result {
  background: var(--color-ink);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-xl);
  padding: var(--space-xl) var(--space-2xl);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.round-result__label {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-gold);
  letter-spacing: var(--letter-spacing-wide);
}

.round-result__score {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-on-ink);
}

/* Title unlock */
.overlay--title {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  background: rgba(26, 22, 40, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
}

.title-unlock {
  background: var(--color-surface);
  border: 1px solid var(--color-gold);
  border-radius: var(--radius-xl);
  padding: var(--space-2xl);
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  max-width: 300px;
  width: 100%;
}

.title-unlock__label {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  letter-spacing: var(--letter-spacing-wider);
  text-transform: uppercase;
}

.title-unlock__name {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-ink);
  letter-spacing: var(--letter-spacing-wide);
}


/* ── MATCH HUD ───────────────────────────────────────────────────────────── */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-ink);
  border-bottom: 1px solid var(--color-border-ink);
  z-index: var(--z-hud);
  flex-shrink: 0;
}

.hud__player {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 80px;
}

.hud__player--right { align-items: flex-end; }

.hud__hp {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-bold);
  color: var(--color-gold);
}

.hud__shield {
  font-size: var(--font-size-xs);
  color: var(--color-blue-light);
  min-height: 1rem;
}

.hud__center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud__round {
  font-size: var(--font-size-xs);
  color: var(--color-muted-dark);
  letter-spacing: var(--letter-spacing-wider);
  text-transform: uppercase;
}

.hud__score {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-on-ink);
}

.hud__timer {
  font-size: var(--font-size-sm);
  color: var(--color-muted-dark);
  font-variant-numeric: tabular-nums;
  transition: color var(--duration-normal) var(--easing-default);
}

.hud__timer.hud-timer--urgent { color: var(--color-coral); }

.hud--active .hud__hp { color: var(--color-gold-light); }

.hud__your-turn {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-ink-mid);
  font-size: var(--font-size-sm);
  color: var(--color-gold);
  letter-spacing: var(--letter-spacing-wide);
  flex-shrink: 0;
}

.hud__your-turn.visible { display: flex; }

.hud__plays-left {
  color: var(--color-muted-dark);
  font-size: var(--font-size-xs);
}


/* ── ANIMATION LAYER ─────────────────────────────────────────────────────── */

.anim-layer {
  position: absolute;
  inset: 0;
  z-index: var(--z-anim);
  pointer-events: none;
  overflow: hidden;
}


/* ── HAND ─────────────────────────────────────────────────────────────────── */

.hand {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  overflow-x: auto;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.hand::-webkit-scrollbar { display: none; }


/* ── MATCH ACTIONS ───────────────────────────────────────────────────────── */

.match__actions {
  display: flex;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  padding-bottom: calc(var(--space-md) + env(safe-area-inset-bottom));
  background: var(--color-ink);
  border-top: 1px solid var(--color-border-ink);
  flex-shrink: 0;
}

.match__actions .btn { flex: 1; }


/* ── CARD (base) ─────────────────────────────────────────────────────────── */

.card {
  width: var(--card-width);
  aspect-ratio: 3 / 5;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
  transition: transform var(--duration-normal) var(--easing-bounce);
  -webkit-user-select: none;
  user-select: none;
}

.card:active { transform: scale(0.95) translateY(-4px); }

.card--back {
  background: var(--color-ink-mid);
  border-color: var(--color-border-ink);
  cursor: default;
}


/* ── FOIL / ULTRA SHIMMER ────────────────────────────────────────────────── */

@keyframes shimmer-foil {
  0%   { background-position: -200% center; }
  100% { background-position:  200% center; }
}

@keyframes shimmer-ultra {
  0%   { background-position: -200% center; opacity: 0.6; }
  50%  { opacity: 1; }
  100% { background-position:  200% center; opacity: 0.6; }
}

.card--foil::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 20%,
    rgba(212, 169, 106, 0.35) 40%,
    rgba(255, 255, 255, 0.25) 50%,
    rgba(75, 159, 212, 0.35) 60%,
    transparent 80%
  );
  background-size: 200% 100%;
  pointer-events: none;
  border-radius: inherit;
  animation: shimmer-foil 2.5s linear infinite;
}

.card--ultra::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 10%,
    rgba(212, 169, 106, 0.5) 30%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(196, 81, 58, 0.4)  70%,
    rgba(75, 159, 212, 0.5) 85%,
    transparent 95%
  );
  background-size: 200% 100%;
  pointer-events: none;
  border-radius: inherit;
  animation: shimmer-ultra 1.8s linear infinite;
}


/* ── ERROR SCREEN ────────────────────────────────────────────────────────── */

.error__msg {
  font-size: var(--font-size-md);
  color: var(--color-gold-light);
  max-width: 280px;
  line-height: var(--line-height-loose);
}


/* ── SCROLLBAR ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track {
  background: var(--color-surface);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb {
  background: var(--color-gold);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-surface);
}
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox */
* { scrollbar-width: thin; scrollbar-color: var(--color-gold) var(--color-surface); }


/* ── FOCUS VISIBLE ───────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--color-coral);
  outline-offset: 2px;
}

:focus:not(:focus-visible) { outline: none; }


/* ── REDUCED MOTION ──────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* ── RESPONSIVE ──────────────────────────────────────────────────────────── */

/* Center the app on wide screens like a mobile frame */
@media (min-width: 520px) {
  .screen {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--max-width);
    box-shadow: 0 0 0 1px var(--color-border-light);
  }

  .toast-container {
    left: 50%;
    transform: translateX(-50%);
  }
}

/* Slightly larger touch targets on bigger screens */
@media (min-width: 360px) {
  .nav-tab {
    padding: var(--space-xs) var(--space-lg);
  }
}
