/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════════════════════════════════════
   TOKENS — DARK (default)
══════════════════════════════════════════════════════════════ */
:root {
  --bg:          #090910;
  --surface:     #0F0F1A;
  --surface-2:   #16162A;
  --border:      #1E1E30;
  --border-hi:   #2E2E48;
  --text:        #FFFFFF;
  --muted:       #4E4E68;
  --accent:      #5F52F0;
  --accent-hi:   #7B6FF5;
  --accent-dim:  rgba(95,82,240,.14);
  --accent-glow: rgba(95,82,240,.30);
  --overlay-bg:  rgba(5,5,12,.85);

  --r:    12px;   /* standard radius */
  --rp:   100px;  /* pill */
  --rc:   22px;   /* card / overlay */

  --sh-sm:   0 2px 10px rgba(0,0,0,.55);
  --sh-card: 0 24px 64px rgba(0,0,0,.80), 0 4px 16px rgba(0,0,0,.5);
}


/* ── Global ─────────────────────────────────────────────────── */
html { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  /* Mobile: prevent pull-to-refresh, remove tap flash */
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}
/* Remove tap highlight on all interactive elements */
button, a, input, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}


/* ── Views ──────────────────────────────────────────────────── */
.view { display: none; min-height: 100svh; flex-direction: column; align-items: center; }
.view.active { display: flex; }

/* ══════════════════════════════════════════════════════════════
   HOME
══════════════════════════════════════════════════════════════ */
.home-wrap {
  width: 100%;
  max-width: 360px;
  padding: 64px 20px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Brand */
.brand-title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 2.2rem;
  color: var(--accent-hi);
  text-align: center;
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}

/* ── Nick pill ──────────────────────────────────────────────── */

.nick-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: 12px;
  padding: 16px 24px;
  margin-bottom: 6px;
  cursor: pointer;
  user-select: none;
}
.nick-pill-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  max-width: 180px;
  flex-shrink: 0;
  transition: max-width .25s ease, opacity .2s ease;
}
.nick-pill.nick-editing .nick-pill-left {
  max-width: 0;
  opacity: 0;
}
.nick-pill-icon { font-size: 15px; color: rgba(255,255,255,.8); flex-shrink: 0; }
.nick-pill-label { font-size: 0.87rem; font-weight: 500; color: rgba(255,255,255,.75); white-space: nowrap; }
.nick-pill-name {
  font-size: 0.87rem;
  font-weight: 700;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
/* Inline input inside pill */
.nick-pill-input {
  background: none;
  border: none;
  outline: none;
  font-size: 0.87rem;
  font-weight: 700;
  color: #ffffff;
  font-family: inherit;
  text-align: center;
  width: 160px;
  cursor: text;
}
.nick-pill-input::placeholder { color: rgba(255,255,255,.45); font-weight: 400; }
.nick-pill-edit {
  flex-shrink: 0;
  font-size: 11px;
  color: rgba(255,255,255,.45);
  pointer-events: none;
}

/* ── Auth hint ──────────────────────────────────────────────── */
.auth-hint {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  margin-top: -4px;
}
.btn-auth-link {
  background: none; border: none;
  font-size: inherit; font-family: inherit; font-weight: 700;
  color: var(--accent-hi);
  cursor: pointer; padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
  transition: color .15s;
}
.btn-auth-link:hover { color: var(--text); }

/* ── Auth logout row ────────────────────────────────────────── */
.auth-logout-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; gap: 8px;
  margin-top: -4px;
}
.auth-logout-label {
  font-size: 0.78rem; color: var(--muted);
  display: flex; align-items: center; gap: 6px;
}
.auth-logout-label i { color: #22C55E; }
.auth-logout-label strong { color: var(--text); font-weight: 700; }
.btn-auth-logout {
  background: none; border: none;
  font-size: 0.78rem; font-family: inherit; font-weight: 600;
  color: var(--muted); cursor: pointer;
  padding: 6px 10px; border-radius: 8px;
  display: flex; align-items: center; gap: 5px;
  transition: color .15s, background .15s;
  min-height: 36px;
}
.btn-auth-logout:hover { color: var(--text); background: var(--surface); }

/* ── Auth tabs inside modal ─────────────────────────────────── */
.auth-tabs {
  display: flex; width: 100%;
  background: var(--surface-2);
  border-radius: 10px; padding: 3px; gap: 3px;
}
.auth-tab {
  flex: 1; padding: 9px 0;
  border: none; background: transparent; border-radius: 8px;
  font-size: 0.87rem; font-weight: 600; font-family: inherit;
  color: var(--muted); cursor: pointer;
  transition: background .15s, color .14s;
}
.auth-tab.active { background: var(--surface); color: var(--text); }

/* ── Auth error ─────────────────────────────────────────────── */
.auth-error {
  font-size: 0.8rem; color: #F87171; font-weight: 600;
  text-align: center; width: 100%; margin-top: -4px;
}

/* ── Nick pill locked (when auth'd) ────────────────────────── */
.nick-pill--locked { cursor: default; }
.nick-pill--locked .nick-pill-edit { display: none; }

/* ── Mode label ─────────────────────────────────────────────── */
.mode-label {
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
  width: 100%;
  margin: 6px 0 2px;
}

/* ── Mode buttons ───────────────────────────────────────────── */
.btn-mode {
  width: 100%;
  height: 56px;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 20px;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  outline: none;
  transition: background .15s, transform .1s;
}
.btn-mode:hover  { background: var(--surface-2); }
.btn-mode:active { transform: scale(.985); }

.btn-mode-icon {
  flex-shrink: 0;
  color: var(--accent-hi);
  font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  width: 22px;
}

/* ── Join row ───────────────────────────────────────────────── */
.join-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
}

.join-input-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    /* border: 1px solid var(--border); */
    border-radius: var(--r);
    padding: 0 18px;
    height: 50px;
    transition: border-color .15s;
}
.join-input-wrap:focus-within { border-color: var(--border-hi); }
.join-icon { font-size: 15px; color: var(--muted); flex-shrink: 0; }

.join-input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  font-size: 0.9rem;
  font-family: inherit;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 2px;
}
.join-input::placeholder { color: var(--muted); text-transform: none; letter-spacing: 0; font-size: 0.88rem; }

.btn-join-arrow {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border-radius: 30%;
    background: var(--accent);
    border: none;
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    /* box-shadow: 0 4px 16px var(--accent-glow); */
    transition: opacity .15s, transform .1s;
}
.btn-join-arrow:hover  { filter: brightness(1.15); }
.btn-join-arrow:active { transform: scale(.93); }

/* ══════════════════════════════════════════════════════════════
   CREATE ROOM
══════════════════════════════════════════════════════════════ */
.create-wrap {
  width: 100%;
  max-width: 360px;
  padding: 36px 20px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.create-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-top: -4px;
  margin-bottom: 6px;
}

/* ── Word field ─────────────────────────────────────────────── */
.field-wrap {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: none;
  border-radius: var(--r);
  padding: 0 16px;
  height: 54px;
}
.field-icon { font-size: 15px; color: var(--muted); flex-shrink: 0; }

.field-input {
  flex: 1; min-width: 0;
  background: none; border: none; outline: none;
  font-size: 0.97rem;
  font-family: inherit;
  color: var(--text);
}
.field-input::placeholder { color: var(--muted); }

.field-eye {
  flex-shrink: 0;
  background: none; border: none;
  padding: 4px;
  font-size: 16px;
  color: var(--muted);
  cursor: pointer;
  display: flex; align-items: center;
  transition: color .15s;
}
.field-eye:hover { color: var(--accent-hi); }

/* ── Type segmented ─────────────────────────────────────────── */
.type-seg-control {
  width: 100%;
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 4px;
  gap: 4px;
}
.type-seg {
  flex: 1;
  padding: 10px 0;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 0.87rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  transition: background .16s, color .14s;
}
.type-seg.active { background: var(--surface-2); color: var(--text); }

/* ── Create button ──────────────────────────────────────────── */
.btn-create {
    width: 100%;
    padding: 14px 20px;
    border-radius: var(--r);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 0.97rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    /* box-shadow: 0 4px 20px var(--accent-glow); */
    transition: opacity .15s, transform .1s, box-shadow .15s;
    margin-top: 2px;  
}
.btn-create:hover  { filter: brightness(0.85); }
.btn-create:active { transform: scale(.98); }
.btn-create:disabled { opacity: .4; cursor: not-allowed; }

/* ── Room result ────────────────────────────────────────────── */
.room-result {
  width: 100%;
  border-radius: var(--r);
  padding: 4px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: pop-in .22s ease;
}
.link-block {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--r);
  padding: 10px 10px 10px 16px;
  overflow: hidden;
}
.link-block-icon { flex-shrink: 0; font-size: 13px; color: var(--muted); }
.link-url {
  flex: 1;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.btn-copy {
  flex-shrink: 0;
  width: 34px; height: 34px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-copy:hover { filter: brightness(1.15); }
.room-code-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--r);
}
.room-code-big-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
}
.room-code-big-value {
  font-family: 'Unbounded', sans-serif;
  font-size: 2rem;
  font-weight: 800;
  color: var(--accent-hi);
  letter-spacing: 4px;
}

/* ══════════════════════════════════════════════════════════════
   GAME VIEW
══════════════════════════════════════════════════════════════ */
#view-game {
  padding-bottom: max(80px, calc(60px + env(safe-area-inset-bottom)));
}

.game-topbar {
  width: 100%;
  max-width: 560px;
  display: flex; align-items: center;
  padding: 20px 20px 16px;
  gap: 12px;
}
.game-title {
  flex: 1;
  text-align: center;
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 1.4rem;
  color: var(--accent-hi);
}
.attempt-counter {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  border: none;
  border-radius: 12px;
  padding: 6px 14px;
  white-space: nowrap;
}

.room-badge {
  font-size: 0.77rem;
  color: var(--muted);
  font-weight: 500;
  border: none;
  background: var(--surface);
  border-radius: 12px;
  padding: 6px 16px;
  margin-bottom: 8px;
}
.room-badge strong { color: var(--text); font-weight: 700; }

.input-row {
  width: 100%;
  max-width: 560px;
  padding: 0 20px;
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.btn-send {
  flex-shrink: 0;
  width: 48px; height: 48px;
  border-radius: 12px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn-send:hover  { filter: brightness(1.15); }
.btn-send:active { transform: scale(.93); }
.btn-send:disabled { opacity: .3; cursor: not-allowed; }

.stats-row {
  width: 100%;
  max-width: 560px;
  padding: 0 20px;
  display: flex; justify-content: space-between; align-items: center;
  font-size: 0.79rem;
  color: var(--muted);
  margin-bottom: 16px;
}
.stat-best { font-weight: 700; color: var(--accent-hi); }

/* ── Leaderboard ────────────────────────────────────────────── */
.leaderboard-panel { width: 100%; max-width: 560px; padding: 0 20px; margin-bottom: 16px; }
.lb-header {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.7rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.lb-header i { color: var(--accent-hi); }
.lb-list {
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
}
.lb-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  font-size: 0.84rem;
  border-radius: 10px;
  transition: background .15s;
}
.lb-row:hover { background: var(--surface-2); }
.lb-row.lb-first { background: rgba(95,82,240,.15); }
.lb-row.lb-first:hover { background: rgba(95,82,240,.22); }
.lb-row.lb-won .lb-name::after { content: ' ✓'; color: #22C55E; font-weight: 700; }
.lb-rank {
  width: 22px; height: 22px;
  font-size: 0.72rem; font-weight: 800;
  color: var(--muted);
  text-align: center;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.lb-row.lb-first .lb-rank {
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 0.68rem;
}
.lb-name { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-score { font-variant-numeric: tabular-nums; font-weight: 700; font-size: .85rem; color: var(--accent-hi); flex-shrink: 0; }
.lb-att  { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; margin-left: 6px; }
.lb-word { font-size: 0.74rem; color: var(--muted); margin-left: 4px; }
.lb-empty { padding: 18px; font-size: 0.82rem; color: var(--muted); text-align: center; }

.giveup-row { width: 100%; max-width: 560px; padding: 18px 20px 0; text-align: center; }

/* ══════════════════════════════════════════════════════════════
   GUESS LIST
══════════════════════════════════════════════════════════════ */
.guesses-list {
  width: 100%; max-width: 560px;
  padding: 0 20px;
  display: flex; flex-direction: column;
  gap: 7px;
}

.g-item {
  display: flex; align-items: center; gap: 10px;
  animation: pop-in .24s cubic-bezier(.34,1.4,.64,1);
}
@keyframes pop-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.g-dot {
  flex-shrink: 0; width: 11px; height: 11px;
  border-radius: 50%;
  filter: drop-shadow(0 0 5px currentColor);
}

.g-pill {
  flex: 1; position: relative;
  height: 50px;
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  display: flex; align-items: center;
  border: none;
}

.g-fill {
  position: absolute; inset: 0; right: auto;
  width: 0; border-radius: inherit;
  opacity: .14;
  transition: width .85s cubic-bezier(.4,0,.2,1);
}
.g-word {
  position: relative; z-index: 1;
  font-size: 0.93rem; font-weight: 600;
  padding-left: 18px; flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.g-score {
  position: relative; z-index: 1;
  font-size: 0.8rem; font-variant-numeric: tabular-nums;
  color: var(--muted);
  padding-right: 18px; letter-spacing: -.3px; flex-shrink: 0;
}

.g-item.is-win .g-pill { border: 1.5px solid rgba(255,215,0,.5); }

/* ══════════════════════════════════════════════════════════════
   OVERLAYS
══════════════════════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: var(--overlay-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fade-in .2s ease;
}
.overlay.hidden { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.overlay-card {
  background: var(--surface);
  border: none;
  border-radius: 12px;
  padding: 36px 28px 32px;
  max-width: 340px; width: 90%;
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
  gap: 14px;
  animation: card-in .3s cubic-bezier(.34,1.46,.64,1);
  position: relative; overflow: hidden;
}
@keyframes card-in {
  from { transform: scale(.92) translateY(12px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}
.overlay-card--win::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(ellipse at top, rgba(255,215,0,.07), transparent 60%);
  pointer-events: none;
}

/* FA icon in overlays */
.ov-icon-fa {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  color: var(--accent-hi);
  margin-bottom: 2px;
}
.ov-icon-fa--win {
  background: rgba(255,215,0,.12);
  color: #FFD700;
}
.ov-icon-fa--bounce { animation: icon-bounce .5s cubic-bezier(.34,1.56,.64,1) .1s both; }
@keyframes icon-bounce {
  from { transform: scale(0) rotate(-15deg); opacity: 0; }
  to   { transform: scale(1) rotate(0);      opacity: 1; }
}

.overlay-card h2 { font-size: 1.4rem; font-weight: 800; letter-spacing: -.5px; }
.ov-sub { font-size: 0.84rem; color: var(--muted); line-height: 1.5; }
.ov-word {
  font-size: 1.2rem; font-weight: 800; letter-spacing: 3px;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px 28px;
  width: 100%;
  color: var(--accent-hi);
  text-transform: uppercase;
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS (shared)
══════════════════════════════════════════════════════════════ */
.btn-primary {
  width: 100%;
  padding: 13px 20px;
  border-radius: 12px;
  border: none;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem; font-weight: 700; font-family: inherit;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover  { filter: brightness(1.12); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .35; cursor: not-allowed; }

/* Accent variant for overlays */
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { filter: brightness(1.12); }

.back-btn {
  align-self: flex-start;
  display: flex; align-items: center; gap: 7px;
  background: none; border: none;
  font-size: 0.82rem; font-weight: 600; font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 10px 4px;
  min-height: 44px;
  transition: color .15s;
  margin-bottom: 2px;
}
.back-btn:hover  { color: var(--text); }
.back-btn:active { color: var(--text); }

.btn-ghost-sm {
  background: none; border: none;
  font-size: 0.83rem; font-family: inherit;
  color: var(--muted);
  cursor: pointer;
  padding: 12px 16px;
  min-height: 44px;
  font-weight: 500;
  transition: color .15s;
}
.btn-ghost-sm:hover  { color: var(--text); }
.btn-ghost-sm:active { color: var(--text); }

/* ── Kill native browser password reveal button ─────────────── */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear { display: none; }
input[type="password"]::-webkit-contacts-auto-fill-button,
input[type="password"]::-webkit-credentials-auto-fill-button { display: none; }

/* ── Kill browser autofill blue background ──────────────────── */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 100px var(--surface) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
}

/* ── Input (overlays) ───────────────────────────────────────── */
.input {
  width: 100%; height: 48px;
  padding: 0 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem; font-family: inherit;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--accent); }
.input.center { text-align: center; font-size: 1rem; font-weight: 600; letter-spacing: .5px; }
.input::placeholder { color: var(--muted); }

/* ── Toast ──────────────────────────────────────────────────── */
#toast {
  position: fixed; top: 20px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: 0.86rem; font-weight: 600;
  padding: 10px 22px;
  border-radius: var(--rp);
  z-index: 300;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, top .2s;
  white-space: nowrap; max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; top: 24px; }

.hidden { display: none !important; }

/* ── TG Banner ──────────────────────────────────────────────── */
.tg-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: rgba(37,99,235,.08);
  border: 1px solid rgba(37,99,235,.18);
  border-radius: var(--r);
  text-decoration: none; color: var(--text);
  transition: background .15s, transform .1s;
  margin-top: 14px; width: 100%;
}
.tg-banner:hover  { background: rgba(37,99,235,.14); }
.tg-banner:active { transform: scale(.99); }

.tg-banner--game {
  width: 100%; max-width: 560px;
  margin: 18px 20px 0; align-self: center;
}
.tg-banner-icon {
  flex-shrink: 0; width: 36px; height: 36px;
  border-radius: 50%;
  background: #2563EB; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.tg-banner-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tg-banner-title { font-size: 0.87rem; font-weight: 700; }
.tg-banner-sub   { font-size: 0.73rem; color: var(--muted); line-height: 1.4; }
.tg-banner-arr   { flex-shrink: 0; color: var(--muted); font-size: 13px; }

/* ══════════════════════════════════════════════════════════════
   NICK COSMETICS
══════════════════════════════════════════════════════════════ */
.nick-color-purple  { color: #7B6FF5 !important; }
.nick-color-cyan    { color: #22D3EE !important; }
.nick-color-green   { color: #4ADE80 !important; }
.nick-color-red     { color: #F87171 !important; }
.nick-color-orange  { color: #FB923C !important; }
.nick-color-pink    { color: #F472B6 !important; }
.nick-color-gold    { color: #FFD700 !important; }
.nick-color-mint    { color: #6EE7B7 !important; }

.nick-effect-shadow   { text-shadow: 2px 2px 6px rgba(0,0,0,.9) !important; }
.nick-effect-glow     { text-shadow: 0 0 10px currentColor, 0 0 20px currentColor !important; }
.nick-effect-gradient {
  background: linear-gradient(90deg, #7B6FF5, #F472B6) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  background-clip: text !important;
}
.nick-effect-rgb      { animation: nick-rgb 3s linear infinite !important; }
.nick-effect-fire     { animation: nick-fire 2s ease-in-out infinite !important; }

@keyframes nick-rgb {
  0%   { color: #FF0000; } 14% { color: #FF8800; }
  28%  { color: #FFFF00; } 42% { color: #00FF00; }
  57%  { color: #00CCFF; } 71% { color: #0044FF; }
  85%  { color: #8800FF; } 100%{ color: #FF0000; }
}
@keyframes nick-fire {
  0%,100% { color: #FF4500; text-shadow: 0 0 8px #FF4500, 0 0 16px #FF8C00; }
  50%     { color: #FF8C00; text-shadow: 0 0 12px #FF8C00, 0 0 24px #FFD700; }
}

/* ══════════════════════════════════════════════════════════════
   SHOP VIEW
══════════════════════════════════════════════════════════════ */
.shop-wrap {
  width: 100%; max-width: 420px;
  padding: 0 20px max(80px, calc(60px + env(safe-area-inset-bottom)));
  display: flex; flex-direction: column; align-items: stretch; gap: 14px;
  margin: 0 auto;
}
.shop-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 0 6px;
}
.shop-topbar .brand-title { flex: 1; margin: 0; font-size: 1.5rem; }
.shop-topbar .back-btn { flex-shrink: 0; margin: 0; }

.shop-balance-badge {
  flex-shrink: 0;
  display: flex; align-items: center; gap: 6px;
  background: var(--surface); border-radius: 12px;
  padding: 6px 14px; font-size: 0.82rem; font-weight: 700;
  color: #FFD700;
}
.shop-balance-badge i { font-size: 13px; }

.shop-preview-box {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 18px; background: var(--surface);
  border-radius: 12px;
}
.shop-preview-label { font-size: 0.7rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.shop-preview-nick  { font-size: 1.3rem; font-weight: 700; color: var(--text); min-height: 1.6em; }

/* Unauth */
.shop-unauth { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 32px 0; }
.shop-unauth-text { font-size: 0.9rem; color: var(--muted); text-align: center; line-height: 1.6; }

/* Sections */
.shop-section-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-top: 4px;
}

/* Color grid */
.shop-colors-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}
.shop-color-card {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; padding: 14px 8px 10px; border-radius: 14px;
  background: var(--surface); border: 2px solid transparent;
  cursor: pointer; transition: border-color .15s, transform .1s;
  position: relative;
}
.shop-color-card:active { transform: scale(.96); }
.shop-color-card:hover  { filter: brightness(1.1); }
.shop-color-card.owned  { border-color: var(--border-hi); }
.shop-color-card.active { border-color: var(--accent); }
.shop-color-card.active::after { content: '✓'; position: absolute; top: 5px; right: 7px; font-size: 10px; color: var(--accent-hi); font-weight: 800; }
.shop-color-swatch { width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; }
.shop-color-name   { font-size: 0.72rem; font-weight: 700; color: var(--text); text-align: center; }
.shop-color-price  { font-size: 0.66rem; color: var(--muted); display: flex; align-items: center; gap: 3px; }
.shop-color-price i { color: #FFD700; font-size: 10px; }
.shop-btn-buy {
  margin-top: 2px; padding: 5px 10px;
  background: var(--accent); border: none; border-radius: 8px;
  font-size: 0.7rem; font-weight: 700; font-family: inherit;
  color: #fff; cursor: pointer; transition: opacity .15s;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.shop-btn-buy--full { width: 100%; }
.shop-btn-buy:hover { filter: brightness(1.15); }
.shop-btn-buy:disabled { opacity: .35; cursor: not-allowed; }
.shop-btn-buy.bought  { background: var(--surface-2); color: var(--muted); }

/* Effects list */
.shop-effects-list { display: flex; flex-direction: column; gap: 8px; }
.shop-effect-card {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; border-radius: 12px;
  background: var(--surface); border: 2px solid transparent;
  cursor: pointer; transition: border-color .15s;
}
.shop-effect-card.active { border-color: var(--accent); }
.shop-effect-card.active .shop-effect-name::after { content: ' ✓'; color: var(--accent-hi); font-weight: 800; }
.shop-effect-preview { font-size: 1rem; font-weight: 700; flex-shrink: 0; width: fit-content; }
.shop-effect-info    { flex: 1; min-width: 0; }
.shop-effect-name    { font-size: 0.87rem; font-weight: 700; }
.shop-effect-desc    { font-size: 0.73rem; color: var(--muted); margin-top: 2px; }
.shop-effect-right   { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.shop-effect-price   { font-size: 0.72rem; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.shop-effect-price i { color: #FFD700; }

/* Rarity badges */
.rarity-badge {
  font-size: 0.6rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 20px;
}
.rarity-common    { background: rgba(100,100,120,.3); color: #888; }
.rarity-rare      { background: rgba(59,130,246,.2);  color: #60A5FA; }
.rarity-epic      { background: rgba(139,92,246,.2);  color: #A78BFA; }
.rarity-legendary { background: rgba(255,165,0,.2);   color: #FFD700; }

/* Reset row */
.shop-reset-row {
  display: flex; gap: 8px; margin-top: 4px;
  padding-bottom: 8px;
}
.btn-shop-reset {
  flex: 1; padding: 10px; border-radius: 10px;
  background: var(--surface); border: none;
  font-size: 0.78rem; font-weight: 600; font-family: inherit;
  color: var(--muted); cursor: pointer; transition: color .15s;
}
.btn-shop-reset:hover { color: var(--text); }

/* Shop button on home */
.btn-mode--shop .btn-mode-icon { color: #FFD700; }
.btn-mode--shop:hover { background: rgba(255,215,0,.10); }

/* Shop content hidden */
.shop-content { display: flex; flex-direction: column; gap: 10px; }

/* ══════════════════════════════════════════════════════════════
   FIX: Nick effects overflow clipping
══════════════════════════════════════════════════════════════ */
/* Дать место glow/shadow эффектам */
.lb-name { overflow: visible; }
.nick-pill-name { overflow: visible; }
.lb-name span[class*="nick-"] { padding: 0 3px; }
/* Эффекты с анимацией — inline-block для корректного рендера */
.nick-effect-rgb, .nick-effect-fire, .nick-effect-glow { display: inline-block; }

/* ══════════════════════════════════════════════════════════════
   STATS VIEW
══════════════════════════════════════════════════════════════ */
.stats-wrap {
  width: 100%; max-width: 420px; margin: 0 auto;
  padding: 0 20px max(80px, calc(60px + env(safe-area-inset-bottom)));
  display: flex; flex-direction: column; gap: 12px;
}

/* My stats card */
.stats-my-card {
  background: var(--surface); border-radius: 12px;
  padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.stats-rank-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border-radius: 20px;
  padding: 6px 16px;
}
.stats-rank-icon { font-size: 1.1rem; }
.stats-rank-name { font-size: 0.87rem; font-weight: 700; color: var(--accent-hi); }

.stats-nick-row { font-size: 1.2rem; font-weight: 800; min-height: 1.4em; }
.stats-nick { overflow: visible; }

.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  width: 100%; gap: 6px;
}
.stats-cell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--surface-2); border-radius: 10px; padding: 10px 4px;
}
.stats-cell-val   { font-size: 1.15rem; font-weight: 800; color: var(--text); }
.stats-cell-label { font-size: 0.6rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Rank progress bar */
.stats-rank-progress {
  width: 100%; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden;
}
.stats-rank-bar { height: 100%; background: var(--accent); border-radius: 2px; transition: width .6s ease; }
.stats-rank-next { font-size: 0.72rem; color: var(--muted); }

/* Section label */
.stats-section-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 7px;
}
.stats-section-label i { color: var(--accent-hi); }

/* Top 10 list */
.stats-top10 {
  background: var(--surface); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column; gap: 2px; padding: 4px;
}
.stats-top10-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px; transition: background .15s;
}
.stats-top10-row:hover { background: var(--surface-2); }
.stats-top10-row.top-me { background: rgba(95,82,240,.15); }
.stats-top10-rank {
  width: 22px; height: 22px; border-radius: 6px;
  font-size: 0.72rem; font-weight: 800; color: var(--muted);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stats-top10-row:first-child .stats-top10-rank { background: var(--accent); color: #fff; }
.stats-top10-icon  { font-size: 0.9rem; flex-shrink: 0; }
.stats-top10-login { flex: 1; font-weight: 700; font-size: 0.87rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stats-top10-rank-name { font-size: 0.72rem; color: var(--muted); flex-shrink: 0; }
.stats-top10-wins  { font-weight: 800; font-size: 0.87rem; color: var(--accent-hi); flex-shrink: 0; margin-left: 6px; }
.stats-top10-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 0.84rem; }

/* Stats button on home — blue/cyan */
.btn-mode--stats .btn-mode-icon { color: #22D3EE; }
.btn-mode--stats:hover { background: rgba(34,211,238,.10); }

/* Stats topbar: center title, pin back button left */
.stats-wrap .shop-topbar {
  position: relative;
  justify-content: center;
}
.stats-wrap .shop-topbar .back-btn {
  position: absolute;
  left: 0;
}

/* Top10 two-line nick+sub layout */
.stats-top10-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stats-top10-nick {
  font-weight: 700;
  font-size: 0.87rem;
  white-space: nowrap;
  overflow: visible;
}
.stats-top10-sub {
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Stats pagination */
.stats-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 0 4px;
}
.btn-page {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  color: var(--text);
  width: 34px;
  height: 34px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter .15s;
}
.btn-page:hover:not(:disabled) { filter: brightness(1.2); }
.btn-page:disabled { opacity: .35; cursor: default; }
.top-page-info { font-size: 0.85rem; color: var(--muted); min-width: 40px; text-align: center; }

/* ── Lobby ─────────────────────────────────────────────────────────────────── */
.lobby-wrap {
  width: 100%;
  max-width: 360px;
  padding: 28px 20px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.lobby-topbar {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  min-height: 36px;
}
.lobby-topbar .back-btn { position: absolute; left: 0; top: 50%; transform: translateY(-50%); }
.lobby-title {
  font-family: 'Unbounded', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: var(--accent-hi);
  margin: 0;
}
.btn-lobby-create {
  position: absolute;
  right: 0;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: filter .15s;
}
.btn-lobby-create:hover { filter: brightness(1.12); }

.lobby-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.lobby-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 40px 0 40px;
  width: 100%;
}
.lobby-empty i { font-size: 2rem; opacity: .35; display: block; margin-bottom: 12px; }
.lobby-empty p { margin: 4px 0 0; }
.lobby-create-btn {
  width: 100%;
  margin-top: 4px;
}

/* Cards like btn-mode */
.lobby-card {
    width: 100%;
    min-height: 84px;
    background: var(--surface);
    border-radius: var(--r);
    padding: 0 20px 0 20px;
    display: flex;
    align-items: center;
    gap: 23px;
    transition: background .15s;
}
.lobby-card:hover { background: var(--surface-2); }
.lobby-card-icon {
    flex-shrink: 0;
    font-size: 22px;
    width: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-hi);
}
.lobby-card-icon.is-lock { color: #fb923c; }
.lobby-card-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.lobby-card-name {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lobby-card-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.lobby-badge {
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 6px;
  padding: 2px 7px;
  white-space: nowrap;
}
.lobby-badge--shared { background: rgba(95,82,240,.22); color: #9b8ff8; }
.lobby-badge--solo   { background: rgba(34,211,238,.15); color: #22D3EE; }
.lobby-badge--lock   { background: rgba(251,146,60,.18); color: #fb923c; }
.lobby-badge--open   { background: rgba(74,222,128,.13); color: #4ade80; }
.lobby-players {
  font-size: 0.72rem;
  color: var(--muted);
}
.btn-lobby-join {
  background: var(--accent);
  border: none;
  border-radius: 10px;
  color: #fff;
  padding: 9px 18px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter .15s;
}
.btn-lobby-join:hover { filter: brightness(1.12); }

/* Password overlay inside lobby */
.lobby-pw-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.lobby-pw-card {
  background: var(--surface);
  border-radius: 18px;
  padding: 24px 20px;
  width: min(340px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.lobby-pw-title { font-weight: 700; font-size: 1rem; margin: 0; text-align: center; }
.lobby-pw-btns { display: flex; gap: 10px; }
.lobby-pw-btns button { flex: 1; padding: 10px; border-radius: 10px; border: none; font-weight: 700; font-size: 0.9rem; cursor: pointer; }
.lobby-pw-btns .btn-secondary { background: var(--surface-2); color: var(--text); }
.lobby-pw-btns .btn-secondary:hover { filter: brightness(1.1); }

/* Privacy toggle in create */
.create-settings-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 4px 0 0;
  text-align: center;
  width: 100%;
}

/* Shop: hide preview */
.shop-preview-box { display: none; }
/* Shop: hide rarity in effects */
.rarity-badge { display: none; }

/* ══════════════════════════════════════════════════════════════
   MOBILE — предотвращаем iOS-зум при фокусе (font-size < 16px)
══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* iOS не зумирует если font-size >= 16px */
  .input,
  .join-input,
  .field-input,
  .nick-pill-input {
    font-size: 16px;
  }
}

/* ══════════════════════════════════════════════════════════════
   MOBILE ≤ 480px
══════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Home */
  .home-wrap {
    padding: 44px 16px max(64px, calc(40px + env(safe-area-inset-bottom)));
    gap: 8px;
  }
  .brand-title { font-size: 1.9rem; margin-bottom: 4px; }
  .nick-pill   { padding: 14px 18px; }
  .btn-mode    { height: 58px; }
  .join-input-wrap { height: 52px; }
  .btn-join-arrow  { width: 52px; height: 52px; }

  /* Create room */
  .create-wrap {
    padding: 28px 16px max(64px, calc(40px + env(safe-area-inset-bottom)));
    gap: 10px;
  }
  .field-wrap  { height: 56px; }
  .type-seg    { padding: 12px 0; }
  .btn-create  { padding: 16px 20px; font-size: 1rem; }
  .room-code-big-value { font-size: 1.7rem; }

  /* Game topbar */
  .game-topbar { padding: 14px 16px 10px; }
  .game-title  { font-size: 1.15rem; }
  .attempt-counter { font-size: 0.72rem; padding: 5px 10px; }

  /* Game body */
  .input-row      { padding: 0 16px; }
  .stats-row      { padding: 0 16px; margin-bottom: 12px; }
  .leaderboard-panel { padding: 0 16px; }
  .guesses-list   { padding: 0 16px; }
  .giveup-row     { padding: 14px 16px 0; }

  /* Game input + send */
  .input  { height: 52px; font-size: 16px; }
  .btn-send { width: 52px; height: 52px; font-size: 17px; }

  /* Guess pills */
  .g-pill  { height: 52px; }
  .g-word  { font-size: 0.95rem; }
  .g-score { font-size: 0.78rem; }

  /* Leaderboard rows */
  .lb-row  { padding: 11px 12px; }

  /* Overlays */
  .overlay-card {
    width: 92%;
    padding: 28px 20px 24px;
    gap: 12px;
  }
  .ov-word { font-size: 1.05rem; padding: 11px 20px; }
  .btn-primary { padding: 14px 20px; font-size: 0.97rem; }

  /* Room badge */
  .room-badge { font-size: 0.73rem; }
}

/* ══════════════════════════════════════════════════════════════
   МАЛЕНЬКИЕ ЭКРАНЫ ≤ 375px (iPhone SE, старые Android)
══════════════════════════════════════════════════════════════ */
@media (max-width: 375px) {
  .brand-title  { font-size: 1.6rem; }
  .game-title   { font-size: 1rem; }
  .home-wrap    { padding: 36px 14px max(56px, calc(36px + env(safe-area-inset-bottom))); }
  .create-wrap  { padding: 24px 14px max(56px, calc(36px + env(safe-area-inset-bottom))); }
  .input-row, .stats-row, .leaderboard-panel,
  .guesses-list, .giveup-row { padding-left: 14px; padding-right: 14px; }
  .overlay-card { width: 96%; padding: 24px 16px 20px; }
  .room-code-big-value { font-size: 1.5rem; letter-spacing: 2px; }
}

/* ══════════════════════════════════════════════════════════════
   НИЗКИЙ ЭКРАН (iPhone SE вертикально, ≤ 667px высота)
══════════════════════════════════════════════════════════════ */
@media (max-height: 667px) {
  .home-wrap  { padding-top: 28px; padding-bottom: 36px; gap: 7px; }
  .brand-title { font-size: 1.6rem; margin-bottom: 2px; }
  .create-wrap { padding-top: 20px; gap: 8px; }
  .game-topbar { padding-top: 10px; padding-bottom: 8px; }
  .overlay-card { padding: 22px 20px 18px; gap: 10px; }
  .ov-icon-fa   { width: 48px; height: 48px; font-size: 1.2rem; }
}
