:root {
  --bg-dark: #0d0707;
  --bg-card: rgba(26, 20, 24, 0.94);
  --bg-elevated: rgba(37, 32, 38, 0.96);
  --bg-stone: #1a1618;
  --bg-wood: #251a1c;
  --bg-iron: #37474f;
  --bg-tile: #2a3038;
  --p1-color: #8b1538;
  --p1-light: #c62848;
  --p2-color: #3d5a80;
  --p2-light: #5b7fa8;
  --accent: #ff8f00;
  --accent-deep: #e65100;
  --accent-glow: rgba(255, 143, 0, 0.48);
  --gold: #ffb300;
  --gold-bright: #ffc107;
  --border-gold: #c88719;
  --border-iron: #546067;
  --parchment: #e8ddd0;
  --text: #f2ebe3;
  --text-muted: #9a9088;
  --success: #5a8f5a;
  --danger: #b71c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --safe-top: var(--inset-top, env(safe-area-inset-top, 0px));
  --safe-bottom: var(--inset-bottom, env(safe-area-inset-bottom, 0px));
  --inset-top: env(safe-area-inset-top, 0px);
  --inset-bottom: env(safe-area-inset-bottom, 0px);
  --content-top-gap: 10px;
  --content-top: calc(var(--inset-top) + var(--content-top-gap));
  --font-display: 'Cinzel', Georgia, serif;
  --font-body: 'Nunito', system-ui, sans-serif;
  --panel-bg: linear-gradient(180deg, rgba(48, 40, 44, 0.96) 0%, rgba(20, 14, 16, 0.98) 100%);
  --frame-shadow:
    0 0 0 1px rgba(255, 193, 7, 0.12) inset,
    0 0 36px rgba(255, 143, 0, 0.18),
    0 10px 36px rgba(0, 0, 0, 0.6);
  --app-bg:
    radial-gradient(ellipse 100% 45% at 50% -5%, rgba(230, 81, 0, 0.28) 0%, transparent 55%),
    radial-gradient(ellipse 80% 38% at 50% 0%, rgba(255, 179, 0, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse 90% 55% at 50% 105%, rgba(0, 0, 0, 0.8) 0%, transparent 65%),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 4px,
      rgba(255, 255, 255, 0.008) 4px,
      rgba(255, 255, 255, 0.008) 5px
    ),
    linear-gradient(180deg, #0d0707 0%, #0a0505 45%, #070404 100%);
  --theme-top: #0d0707;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  background: var(--app-bg);
  background-color: var(--theme-top);
  color-scheme: dark;
}

html, body {
  width: 100%;
  max-width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
  overflow-x: hidden;
  touch-action: manipulation;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-body);
  background: var(--app-bg);
  background-color: var(--theme-top);
  color: var(--text);
  line-height: 1.4;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

#boot-splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0707;
  transition: opacity 0.35s ease, visibility 0s linear 0.35s;
}

#boot-splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.boot-splash-logo {
  display: block;
  width: min(78vw, 400px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.65));
}

#app-bg {
  position: fixed;
  inset: 0;
  background: var(--app-bg);
  background-color: var(--theme-top);
  pointer-events: none;
  z-index: 0;
}

#top-scrim {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--inset-top);
  background: linear-gradient(180deg, #0d0707 0%, #1a1012 100%);
  pointer-events: none;
  z-index: 1;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: 100%;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
  z-index: 2;
  background: transparent;
}

#screen-battle {
  padding: calc(4px + var(--content-top)) 4px calc(4px + var(--safe-bottom));
  overflow: hidden;
  min-height: 0;
  --combo-slot-height: 54px;
  /* Behold .screen position:absolute + inset:0 — relative her krymper brettet */
}

.screen {
  position: absolute;
  inset: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  padding: calc(8px + var(--content-top)) 16px calc(12px + var(--safe-bottom));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 1;
  transform: translate3d(28px, 0, 0) scale(0.985);
  filter: blur(5px);
  transition:
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.3s ease,
    filter 0.34s ease,
    visibility 0s linear 0.4s;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  will-change: transform, opacity;
}

.screen::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.screen.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 3;
  transform: translate3d(0, 0, 0) scale(1);
  filter: blur(0);
  transition:
    transform 0.44s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.34s ease,
    filter 0.36s ease,
    visibility 0s;
}

.screen.from-back {
  transform: translate3d(-28px, 0, 0) scale(0.985);
}

.screen.leaving {
  opacity: 0;
  visibility: visible;
  pointer-events: none;
  z-index: 2;
  transform: translate3d(-52px, 0, 0) scale(0.99);
  filter: blur(7px);
  transition:
    transform 0.34s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.26s ease,
    filter 0.3s ease,
    visibility 0s linear 0.34s;
}

.screen.leaving.to-back {
  transform: translate3d(52px, 0, 0) scale(0.99);
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .screen.active,
  .screen.leaving,
  .screen.from-back {
    transition: none;
    transform: none;
    filter: none;
  }
}

@keyframes logoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes scorePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

@keyframes chipFound {
  0% { transform: scale(0.85); opacity: 0.5; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

#screen-home .logo-heading {
  animation: logoFloat 4s ease-in-out infinite;
}

.btn-primary:not(:disabled) {
  animation: btnGlow 3s ease-in-out infinite;
}

@keyframes btnGlow {
  0%, 100% { box-shadow: 0 4px 16px rgba(255, 143, 0, 0.4), inset 0 1px 0 rgba(255, 230, 160, 0.38), inset 0 -2px 0 rgba(0, 0, 0, 0.35); }
  50% { box-shadow: 0 4px 24px rgba(255, 143, 0, 0.58), inset 0 1px 0 rgba(255, 230, 160, 0.48), inset 0 -2px 0 rgba(0, 0, 0, 0.35); }
}

.player-score.score-pulse {
  animation: scorePop 0.55s ease-out;
}

#screen-battle .word-chip.found-p1,
#screen-battle .word-chip.found-p2 {
  animation: chipFound 0.35s ease-out;
}

/* Home */
.logo-area {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px 12px 16px;
  overflow: visible;
}

.logo-heading {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  line-height: 0;
  overflow: visible;
  padding: 18px 24px;
}

.logo-heading::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 92%;
  height: 92%;
  background: radial-gradient(ellipse at center, rgba(255, 179, 0, 0.42) 0%, rgba(255, 143, 0, 0.16) 48%, transparent 74%);
  pointer-events: none;
  z-index: 0;
}

.app-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: min(94vw, 360px);
  height: auto;
  margin: 0 auto;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.65));
}

.app-logo--home {
  width: min(82vw, 320px);
}

.app-logo--auth {
  width: min(85vw, 340px);
}

.game-frame {
  background: var(--panel-bg);
  border: 3px solid var(--border-gold);
  border-radius: 14px;
  box-shadow: var(--frame-shadow);
}

.home-menu {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 16px 14px;
}

.home-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  width: 100%;
}

.game-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 8vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--gold);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6), 0 0 24px var(--accent-glow);
}

.tagline {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
}

.home-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  margin: 0;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.btn {
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  text-align: center;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(180deg, #ffc107 0%, #ff8f00 32%, #e65100 68%, #bf360c 100%);
  color: #fff8e7;
  border: 2px solid var(--gold-bright);
  box-shadow:
    0 4px 20px rgba(255, 143, 0, 0.48),
    inset 0 1px 0 rgba(255, 230, 160, 0.42),
    inset 0 -2px 0 rgba(0, 0, 0, 0.35);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
}

.btn-secondary {
  background: linear-gradient(180deg, #45525a 0%, #2a3138 100%);
  color: var(--text);
  border: 2px solid var(--border-iron);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.4);
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

.btn-large {
  min-height: 52px;
  padding: 14px 24px;
  font-size: 1.1rem;
}

.btn-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.btn:has(.btn-icon) .btn-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 2.5rem 0 2rem;
  min-height: 1.35em;
}

.btn-icon {
  font-size: 1.3rem;
}

.btn:has(.btn-icon) {
  position: relative;
}

.btn:has(.btn-icon) .btn-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:empty {
  display: none;
}

.stats-bar {
  display: flex;
  justify-content: space-around;
  background: linear-gradient(180deg, rgba(40, 34, 38, 0.96), rgba(18, 12, 14, 0.98));
  border-radius: var(--radius);
  border: 2px solid var(--border-gold);
  padding: 14px 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-shadow: var(--frame-shadow);
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gold);
  font-family: var(--font-display);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rank-progress {
  width: 100%;
  max-width: 320px;
  margin: 0 auto 10px;
  padding: 0 4px;
}

.rank-progress--season {
  margin-bottom: 12px;
}

.rank-progress-heading {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.rank-progress-track {
  height: 6px;
  border-radius: 3px;
  background: var(--bg-elevated);
  overflow: hidden;
  margin-bottom: 4px;
}

.rank-progress-fill {
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--p1-color), var(--gold));
  transition: width 0.4s ease;
}

.rank-progress-fill--season {
  background: linear-gradient(90deg, var(--p2-color), var(--gold));
}

.rank-progress-label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
}

.rank-progress-hint {
  margin: 0 0 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.profile-name-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  cursor: pointer;
  text-align: center;
  font: inherit;
  color: inherit;
}

.profile-name-btn:active {
  transform: scale(0.98);
}

.profile-name-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 0;
  max-width: 100%;
}

.profile-name-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.results-section-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gold);
}

.results-unranked-note {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(92, 107, 122, 0.2);
  border: 1px solid var(--border-iron);
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.results-achievements {
  width: 100%;
  margin-top: 10px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 143, 0, 0.08);
  border: 2px solid var(--border-gold);
}

.achievement-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.achievement-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
}

.achievement-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  background: var(--gold);
}

.achievement-icon--chip {
  width: 32px;
  height: 32px;
}

.achievement-chip .meta strong {
  display: block;
  font-size: 0.9rem;
}

.achievement-chip .meta span {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.player-card-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-card-hero {
  text-align: center;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 2px solid var(--border-gold);
}

.player-card-name {
  margin: 0 0 6px;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 1.4rem;
}

.player-card-ranks {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.player-card-rank-sep {
  margin: 0 6px;
}

.player-card-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.card-stat {
  text-align: center;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-iron);
}

.card-stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--gold);
}

.card-stat-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.player-card-section h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--parchment);
}

.card-section-count {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.82rem;
}

.player-card-section--ranks {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.player-card-section--ranks .rank-progress {
  max-width: none;
  margin: 0;
  padding: 0;
}

.card-records .highlight-item {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-elevated);
  font-size: 0.88rem;
}

.card-records .highlight-item:last-child {
  border-bottom: none;
}

.achievement-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.achievement-tiers {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.achievement-tier-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 8px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.achievement-tier-count {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}

.achievement-tier-title--bronze {
  color: #d4a574;
}

.achievement-tier-title--silver {
  color: #c8d0d8;
}

.achievement-tier-title--gold {
  color: var(--gold);
}

.achievement-badge--bronze.unlocked {
  border-color: #b87333;
  box-shadow: inset 0 0 12px rgba(184, 115, 51, 0.12);
}

.achievement-badge--silver.unlocked {
  border-color: #a8b4c0;
  box-shadow: inset 0 0 12px rgba(168, 180, 192, 0.12);
}

.achievement-badge--gold.unlocked {
  border-color: var(--border-gold);
  box-shadow: inset 0 0 12px rgba(255, 143, 0, 0.08);
}

.achievement-badge--bronze.unlocked .achievement-icon {
  background: #d4a574;
}

.achievement-badge--silver.unlocked .achievement-icon {
  background: #c8d0d8;
}

.achievement-chip--bronze .achievement-icon {
  background: #d4a574;
}

.achievement-chip--silver .achievement-icon {
  background: #c8d0d8;
}

.achievement-chip--gold .achievement-icon {
  background: var(--gold);
}

.achievement-badge {
  padding: 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-iron);
  opacity: 0.45;
}

.achievement-badge.unlocked {
  opacity: 1;
  border-color: var(--border-gold);
  box-shadow: inset 0 0 12px rgba(255, 143, 0, 0.08);
}

.achievement-badge .achievement-icon {
  width: 24px;
  height: 24px;
  background: var(--text-muted);
}

.achievement-badge.unlocked .achievement-icon {
  background: var(--gold);
}

.achievement-badge strong {
  display: block;
  font-size: 0.82rem;
  margin-top: 6px;
}

.achievement-badge span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.h2h-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.h2h-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-iron);
  font-size: 0.88rem;
}

.h2h-row--clickable {
  width: 100%;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.h2h-row--clickable:hover,
.h2h-row--clickable:focus-visible {
  border-color: var(--gold);
  background: rgba(255, 215, 100, 0.06);
  outline: none;
}

.h2h-row--vs {
  cursor: default;
}

.h2h-row .score {
  font-weight: 700;
  color: var(--gold);
}

/* Friends */
.friends-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
  padding-bottom: 24px;
}

.friend-code-card,
.friends-add,
.friends-section {
  background: var(--bg-card);
  border: 2px solid var(--border-iron);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.friend-code-label,
.friends-add label {
  display: block;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.friend-code-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.friend-code-value {
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.12em;
  color: var(--gold);
}

.friends-hint,
.friends-lookup {
  margin: 10px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.friends-lookup.error {
  color: var(--danger, #e85d5d);
}

.friends-lookup.success {
  color: var(--gold);
}

.friends-section h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.friends-count {
  color: var(--text-muted);
  font-weight: 600;
}

.friends-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friends-list--compact {
  max-height: 220px;
  overflow-y: auto;
}

.friend-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-elevated);
  border-radius: calc(var(--radius) - 4px);
  border: 1px solid var(--border-iron);
}

.friend-row-info {
  min-width: 0;
}

.friend-row-name {
  display: block;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.friend-row-meta {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.friend-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.friends-badge {
  margin-left: 8px;
  min-width: 1.4rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #1a0a0a;
  font-size: 0.75rem;
  font-weight: 800;
}

.home-actions .btn {
  position: relative;
}

.home-actions .friends-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  margin-left: 0;
}

.player-card-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.invite-banner {
  position: fixed;
  top: calc(var(--safe-top, 0px) + var(--content-top-gap, 10px));
  left: 12px;
  right: 12px;
  z-index: 1500;
  background: linear-gradient(135deg, rgba(45, 18, 18, 0.96), rgba(26, 10, 10, 0.98));
  border: 2px solid var(--gold-dim, #b8860b);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.invite-banner-body {
  padding: 12px 14px;
}

.invite-banner-text {
  margin: 0 0 10px;
  font-weight: 700;
  text-align: center;
}

.invite-banner-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.lobby-invite {
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  background: var(--bg-card);
  border: 2px solid var(--border-iron);
  border-radius: var(--radius);
}

.lobby-invite-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  text-align: center;
  color: var(--text-muted);
}

/* Settings */
.settings-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}

.settings-group {
  background: var(--bg-card);
  border: 2px solid var(--border-iron);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.settings-group-title {
  margin: 0 0 12px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg-elevated);
}

.settings-row:last-of-type {
  border-bottom: none;
  padding-bottom: 0;
}

.settings-row-text {
  min-width: 0;
}

.settings-label {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
}

.settings-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.settings-toggle {
  flex-shrink: 0;
  width: 52px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid var(--border-iron);
  background: var(--bg-elevated);
  position: relative;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.settings-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
}

.settings-toggle[aria-pressed="true"] {
  background: rgba(155, 35, 53, 0.35);
  border-color: var(--p1-color);
}

.settings-toggle[aria-pressed="true"]::after {
  transform: translateX(22px);
  background: var(--gold);
}

.settings-account-name {
  margin: 0 0 12px;
  font-weight: 700;
  color: var(--gold);
}

.settings-hint {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.settings-hint.warning {
  color: #e8945a;
}

.settings-version {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 4px 0 0;
}

/* Header — game-style centered title */
.screen-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  flex-shrink: 0;
  padding: 0 52px;
}

.screen-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  width: 100%;
  font-family: var(--font-display);
  color: var(--gold);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  letter-spacing: 0.04em;
}

.game-back,
.screen-header .btn-back {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border: 2px solid var(--border-gold);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #45525a, #2a3138);
  color: var(--gold-bright);
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  z-index: 2;
}

.game-back::before {
  content: '←';
}

.game-back.hidden {
  display: none;
}

.btn-back {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border-gold);
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #45525a, #2a3138);
  color: var(--gold-bright);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Level grid */
.level-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 1fr;
  gap: 12px;
  align-items: stretch;
}

.level-card {
  display: flex;
  flex-direction: column;
  min-height: 148px;
  height: 100%;
  background: linear-gradient(180deg, rgba(40, 34, 38, 0.92), rgba(18, 12, 14, 0.96));
  border-radius: var(--radius);
  padding: 16px;
  border: 2px solid var(--border-iron);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s, box-shadow 0.2s;
}

.level-card:active {
  transform: scale(0.97);
}

.level-card.random {
  grid-column: 1 / -1;
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(255, 143, 0, 0.12), rgba(18, 12, 14, 0.96));
}

.level-card.random .level-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.level-card.selected {
  border-color: var(--gold-bright);
  box-shadow: 0 0 16px var(--accent-glow);
}

.level-card.completed {
  border-color: var(--gold-bright);
  box-shadow: 0 0 14px var(--accent-glow);
}

.level-card .level-num {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.level-card .level-title {
  font-size: 1rem;
  font-weight: 700;
  margin: 4px 0;
  font-family: var(--font-display);
  line-height: 1.25;
  min-height: 2.5em;
}

.level-card .level-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.level-card .level-stars {
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.9rem;
}

/* Setup */
.setup-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.level-preview {
  background: linear-gradient(180deg, rgba(40, 34, 38, 0.92), rgba(18, 12, 14, 0.96));
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  border: 2px solid var(--border-gold);
  box-shadow: var(--frame-shadow);
}

.level-preview h3 {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.level-preview p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.player-setup {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.player-setup .player-input-group {
  width: 100%;
}

.player-input-group {
  flex: 1;
  min-width: 0;
}

.player-slot-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gold);
  padding: 12px;
  text-align: center;
  background: rgba(10, 8, 6, 0.5);
  border: 2px solid #5a4a38;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
}

.player-input-group label {
  display: block;
  font-size: 0.7rem;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}

.input-hint {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.68rem;
  letter-spacing: normal;
  text-transform: none;
  color: var(--text-muted);
  opacity: 0.9;
}

.player-input-group input {
  width: 100%;
  padding: 14px 12px;
  border: 2px solid #5a4a38;
  border-radius: var(--radius-sm);
  background: rgba(10, 8, 6, 0.65);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
}

.player-input-group input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 10px var(--accent-glow);
}

.player-input-group input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.vs-badge {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  padding: 0;
}

.color-picker {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
  padding: 4px 2px;
  width: 100%;
}

.color-picker-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.color-swatch {
  width: 100%;
  max-width: 40px;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.color-swatch.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 215, 0, 0.35), 0 0 10px var(--accent-glow);
}

.mode-selector label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.mode-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-btn {
  background: var(--bg-card);
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius);
  padding: 14px;
  color: var(--text);
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}

.mode-btn > span:first-of-type {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
  color: var(--gold);
}

.mode-btn strong {
  display: block;
  font-size: 0.95rem;
}

.mode-btn small {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.mode-btn.active {
  border-color: var(--gold);
  background: rgba(255, 143, 0, 0.12);
  box-shadow: 0 0 12px var(--accent-glow);
}

/* Battle HUD */
.battle-hud {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  margin-bottom: 10px;
  padding-top: 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  gap: 8px;
}

.battle-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 6px;
  flex-shrink: 0;
  min-width: 72px;
  gap: 2px;
}

.player-score {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: transform 0.2s, box-shadow 0.2s;
  min-width: 0;
  overflow: hidden;
}

.player-score.active-turn {
  transform: scale(1.05);
  box-shadow: 0 0 20px var(--accent-glow);
}

.player-score.p1 {
  background: rgba(196, 98, 42, 0.25);
  border-left: 3px solid var(--p1-color);
}

.player-score.p2 {
  background: rgba(92, 107, 122, 0.25);
  border-right: 3px solid var(--p2-color);
  text-align: right;
}

.player-score .player-name {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score .score-value {
  font-size: 1.5rem;
  font-weight: 800;
}

.timer {
  font-size: 1.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--gold-bright);
  font-family: var(--font-display);
  text-shadow: 0 0 12px rgba(255, 143, 0, 0.35);
}

.timer.warning {
  color: var(--danger);
  animation: timerPulse 0.5s ease-in-out infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.level-name {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.progress-duel {
  display: flex;
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 8px;
  background: var(--bg-elevated);
  width: 100%;
  max-width: 100%;
}

.progress-bar {
  height: 100%;
  transition: width 0.4s ease;
}

.progress-bar.p1 {
  background: var(--p1-color);
}

.progress-bar.p2 {
  background: var(--p2-color);
}

.turn-indicator {
  text-align: center;
  padding: 6px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 8px;
}

.turn-indicator.hidden {
  display: none;
}

/* Word list */
.word-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
}

.word-chip {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-tile);
  border: 1px solid #4a5668;
  color: var(--parchment);
  transition: all 0.3s;
  line-height: 1.2;
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}

.word-chip.found-p1 {
  background: var(--p1-color);
  color: white;
  text-decoration: line-through;
}

.word-chip.found-p2 {
  background: var(--p2-color);
  color: white;
  text-decoration: line-through;
}

.word-chip.bonus {
  border: 1px solid var(--gold);
  color: var(--gold);
}

.word-chip.bonus.found-p1,
.word-chip.bonus.found-p2 {
  border-color: transparent;
}

/* Grid */
#screen-battle .word-list {
  gap: 5px;
  margin-bottom: 4px;
  max-height: 14vh;
  overflow-y: auto;
  flex-shrink: 0;
  scrollbar-width: none;
}

#screen-battle .word-list::-webkit-scrollbar {
  display: none;
}

#screen-battle .word-chip {
  padding: 4px 9px;
  font-size: 0.72rem;
}

#screen-battle .battle-hud {
  padding-top: 0;
  margin-top: 0;
  margin-bottom: 4px;
}

#screen-battle .player-score {
  padding: 6px 8px;
}

#screen-battle .player-score .score-value {
  font-size: 1.25rem;
}

#screen-battle .timer {
  font-size: 1.5rem;
}

#screen-battle .progress-duel {
  margin-bottom: 4px;
}

.grid-container {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: stretch;
  min-height: 0;
  width: 100%;
  gap: 4px;
}

.grid-viewport {
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

.grid-stage {
  transform-origin: center center;
  will-change: transform;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

#game-grid {
  touch-action: none;
  display: block;
  border-radius: var(--radius-sm);
  border: 3px solid var(--border-gold);
  box-shadow:
    0 0 24px rgba(255, 143, 0, 0.25),
    inset 0 0 40px rgba(0, 0, 0, 0.65);
}

.battle-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.battle-footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-left: auto;
}

.combo-meter-slot {
  flex-shrink: 0;
  width: 100%;
  height: var(--combo-slot-height);
  padding: 2px 0;
}

.combo-meter {
  width: 100%;
  height: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid rgba(255, 215, 0, 0.28);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.combo-meter-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}

.combo-meter-label {
  color: var(--gold-bright);
  font-weight: 700;
  font-size: 0.82rem;
  letter-spacing: 0.02em;
}

.combo-meter-hint {
  color: var(--text-muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.combo-meter-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 215, 0, 0.25);
  overflow: hidden;
}

.combo-meter-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #c4622a, var(--gold-bright));
  box-shadow: 0 0 10px rgba(255, 143, 0, 0.45);
  transform-origin: left center;
  transition: width 0.05s linear;
}

.combo-meter-fill.urgent {
  background: linear-gradient(90deg, var(--danger), #ff8f00);
  animation: comboUrgentPulse 0.45s ease-in-out infinite alternate;
}

@keyframes comboUrgentPulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.25); }
}

.combo-meter.hidden {
  visibility: hidden;
  opacity: 0;
}

.combo-display {
  color: var(--gold);
  font-weight: 700;
  animation: comboPop 0.3s ease;
}

.combo-display.hidden {
  display: none;
}

@keyframes comboPop {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Results */
.results-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 24px;
}

.winner-crown {
  font-size: 64px;
  animation: crownBounce 0.6s ease;
}

@keyframes crownBounce {
  0% { transform: scale(0) rotate(-20deg); }
  60% { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

#winner-text {
  font-size: 1.8rem;
  font-weight: 800;
}

.results-subtitle {
  color: var(--text-muted);
}

.results-scores {
  display: flex;
  gap: 12px;
  width: 100%;
}

.result-player {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
}

.result-player.p1 {
  border-top: 3px solid var(--p1-color);
}

.result-player.p2 {
  border-top: 3px solid var(--p2-color);
}

.result-player .name {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.result-player .score {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--gold);
  font-family: var(--font-display);
}

.result-player .words {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.results-stats {
  width: 100%;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: left;
}

.results-stats .highlight-item {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--bg-elevated);
}

.results-stats .highlight-item:last-child {
  border-bottom: none;
}

.rematch-prompt,
.rematch-waiting,
.rematch-opponent-left {
  width: 100%;
  margin-top: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 2px solid var(--border-gold);
  text-align: center;
}

.rematch-opponent-left p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.rematch-opponent-left .btn-large {
  width: 100%;
}

.online-invite-friends {
  width: 100%;
  margin-top: 8px;
  padding-top: 4px;
}

.online-invite-title {
  margin: 0 0 4px;
  font-size: 0.95rem;
  color: var(--gold);
  font-family: var(--font-display);
}

.online-invite-hint {
  margin: 0 0 10px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.player-card-view-banner {
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(255, 143, 0, 0.18), rgba(139, 21, 56, 0.14));
  border: 2px solid var(--border-gold);
  text-align: center;
  font-weight: 700;
  color: var(--parchment);
  font-size: 0.92rem;
}

#screen-player-card.player-card--opponent .screen-header h2 {
  color: var(--gold);
}

.rematch-prompt-text {
  margin: 0 0 14px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--parchment);
}

.rematch-prompt-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rematch-waiting p {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin-top: 8px;
}

.results-actions .btn-large {
  width: 100%;
  min-height: 54px;
}

.pause-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 340px);
  padding: 20px 16px;
  border: 2px solid var(--border-gold);
  border-radius: var(--radius);
  box-shadow: var(--frame-shadow);
}

.pause-warning {
  margin: -8px 0 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(196, 98, 42, 0.15);
  border: 1px solid rgba(196, 98, 42, 0.35);
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.4;
  text-align: center;
  width: 100%;
}

#pause-overlay .battle-overlay-title {
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  margin-bottom: 8px;
}

/* Help */
.help-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.help-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(180deg, rgba(40, 34, 38, 0.92), rgba(18, 12, 14, 0.96));
  border-radius: var(--radius);
  padding: 12px 14px;
  border: 2px solid var(--border-iron);
}

.help-card-body {
  flex: 1;
  min-width: 0;
}

.help-card.highlight {
  border-color: var(--gold);
  background: rgba(255, 143, 0, 0.08);
}

#screen-help .screen-header {
  margin-bottom: 12px;
}

#screen-help .help-content {
  padding-top: 0;
}

#screen-home {
  justify-content: flex-start;
  gap: 4px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-top: calc(2px + var(--inset-top, env(safe-area-inset-top, 0px)) + 4px);
  padding-bottom: calc(6px + var(--safe-bottom));
}

#screen-home .logo-area {
  flex-shrink: 0;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 8px 2px;
  margin-top: 0;
}

#screen-home .logo-heading {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0;
}

#screen-home .app-logo--home {
  width: min(84vw, 300px);
  margin-left: auto;
  margin-right: auto;
}

#screen-home .home-menu {
  flex-shrink: 0;
  padding: 10px 12px;
}

#screen-home .home-actions {
  gap: 8px;
}

#screen-home .btn-large {
  min-height: 48px;
  padding: 11px 18px;
  font-size: 1.02rem;
}

#screen-home .home-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding-top: 4px;
  padding-bottom: 0;
}

#screen-home .profile-bar {
  padding: 10px 14px;
  background: linear-gradient(180deg, #45525a 0%, #2a3138 100%);
  border: 2px solid var(--border-iron);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 4px 12px rgba(0, 0, 0, 0.4);
  font-family: var(--font-display);
  letter-spacing: 0.03em;
}

#screen-home .profile-bar #profile-name {
  color: var(--text);
  font-family: inherit;
}

@media (max-height: 740px) {
  #screen-home .logo-heading {
    padding: 0;
  }

  #screen-home .app-logo--home {
    width: min(76vw, 260px);
  }

  #screen-home .home-menu {
    padding: 8px 10px;
  }

  #screen-home .home-actions {
    gap: 6px;
  }

  #screen-home .btn-large {
    min-height: 44px;
    padding: 9px 16px;
    font-size: 0.98rem;
  }
}

.level-preview,
.daily-hero,
.room-code-display {
  border: 2px solid var(--border-gold);
  box-shadow: inset 0 0 20px rgba(255, 143, 0, 0.05);
}

.help-icon {
  flex-shrink: 0;
  margin-top: 1px;
  font-size: 1.5rem;
}

.help-card h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}

.help-card p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.profile-bar {
  border-radius: var(--radius);
  border: 2px solid var(--border-gold);
  padding: 12px 16px;
  font-size: 0.9rem;
  width: 100%;
  box-shadow: var(--frame-shadow);
}

.profile-bar #profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--gold);
  font-size: 1rem;
}

.btn-hud {
  min-height: 40px;
  padding: 8px 18px;
  font-size: 0.88rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Auth — full-screen game login */
.screen-auth {
  justify-content: flex-start;
  align-items: stretch;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-top: calc(2px + var(--inset-top, env(safe-area-inset-top, 0px)) + 4px);
  padding-bottom: calc(12px + var(--safe-bottom));
  min-height: 0;
}

.screen-auth .auth-header:not(.hidden) {
  margin-top: 0;
}

.screen-auth .auth-header.hidden + .auth-layout {
  margin-top: 0;
}

.screen-auth .auth-header {
  flex-shrink: 0;
  width: 100%;
  max-width: 420px;
  margin: 0 auto 4px;
  padding: 0 52px;
}

.screen-auth .auth-header.hidden {
  display: none;
}

#auth-logo-area.hidden {
  display: none;
}

.auth-layout {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin: 0 auto;
  padding: 8px 0 calc(32px + var(--safe-bottom));
  flex-shrink: 0;
}

.auth-layout .logo-area {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 8px 2px;
  flex-shrink: 0;
  overflow: visible;
}

.auth-layout .logo-heading {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0;
  margin: 0;
}

.auth-layout .app-logo--home {
  width: min(84vw, 300px);
  margin-left: auto;
  margin-right: auto;
}

.game-panel {
  width: 100%;
  background: var(--panel-bg);
  border: 3px solid var(--border-gold);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--frame-shadow);
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gold);
  text-align: center;
  margin-bottom: 4px;
  letter-spacing: 0.06em;
}

.auth-panel-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-intro {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.auth-intro.hidden {
  display: none;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.auth-tab {
  padding: 12px;
  border: 2px solid var(--border-iron);
  border-radius: var(--radius-sm);
  background: rgba(10, 8, 6, 0.5);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
  cursor: pointer;
}

.auth-tab.active {
  border-color: var(--gold-bright);
  color: var(--gold-bright);
  background: rgba(255, 143, 0, 0.1);
  box-shadow: 0 0 12px rgba(255, 143, 0, 0.15);
}

.auth-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.auth-panel.active {
  display: flex;
}

.auth-account {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-account.hidden {
  display: none;
}

#auth-guest-panel.hidden {
  display: none;
}

.account-hero {
  text-align: center;
  padding: 8px 0 4px;
}

.account-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.account-hero h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--gold);
  margin-bottom: 4px;
}

.account-hero p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.auth-error {
  color: #ff6b5a;
  font-size: 0.85rem;
  text-align: center;
}

.auth-error.hidden {
  display: none;
}

.auth-forgot-wrap {
  text-align: center;
  margin-top: 12px;
}

.auth-intro--compact {
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.update-banner {
  position: fixed;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, rgba(26, 18, 8, 0.96), rgba(45, 32, 16, 0.96));
  border: 2px solid var(--border-gold);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  max-width: calc(100vw - 32px);
}

.update-banner.hidden {
  display: none;
}

.update-banner p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-light);
  white-space: nowrap;
}

.btn-link {
  background: none;
  border: none;
  color: var(--gold);
  font-family: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* Daily challenge */
.daily-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.daily-hero {
  background: linear-gradient(135deg, rgba(196, 98, 42, 0.28), rgba(255, 143, 0, 0.14));
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  border: 2px solid var(--border-gold);
  box-shadow: 0 0 16px var(--accent-glow);
}

.daily-hero--blitz {
  background: linear-gradient(135deg, rgba(255, 143, 0, 0.32), rgba(196, 60, 20, 0.2));
  border-color: #ff8f00;
}

.daily-badge--blitz {
  background: linear-gradient(180deg, #ff8f00, #e65100);
  color: #1a1208;
  font-weight: 800;
}

.daily-badge {
  display: inline-block;
  background: linear-gradient(180deg, #ffd700, #b8860b);
  color: #1a1208;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  margin-bottom: 8px;
  font-family: var(--font-display);
}

.daily-hero h3 {
  font-size: 1.3rem;
  margin-bottom: 4px;
  font-family: var(--font-display);
  color: var(--gold);
}

.daily-hero p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.daily-note {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  line-height: 1.4;
}

.daily-note--blitz {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 143, 0, 0.35);
  color: var(--parchment);
}

.daily-podium-stats {
  background: var(--bg-card);
  border: 1px solid rgba(255, 215, 0, 0.22);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.daily-podium-title {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.daily-podium-hint {
  margin: 0 0 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.85;
}

.daily-podium-row {
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.daily-podium-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
}

.daily-podium-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.6em;
  font-family: var(--font-display);
  font-size: 0.95rem;
}

.daily-podium-medal--1 { color: var(--gold-bright); }
.daily-podium-medal--2 { color: #c0c0c0; }
.daily-podium-medal--3 { color: #cd7f32; }

.leaderboard-section h3 {
  font-size: 1rem;
  margin-bottom: 8px;
}

.my-rank {
  background: rgba(255, 143, 0, 0.12);
  border: 1px solid var(--gold);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.9rem;
  margin-bottom: 8px;
  text-align: center;
}

.leaderboard-list {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 56px 52px;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--bg-elevated);
  font-size: 0.85rem;
  align-items: center;
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-row:nth-child(1) .lb-rank { color: var(--gold); font-weight: 800; }
.leaderboard-row:nth-child(2) .lb-rank { color: #c0c0c0; font-weight: 700; }
.leaderboard-row:nth-child(3) .lb-rank { color: #cd7f32; font-weight: 700; }

.lb-rank { font-weight: 700; color: var(--text-muted); }
.lb-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { text-align: right; color: var(--gold); font-weight: 700; }
.lb-words { text-align: right; color: var(--text-muted); font-size: 0.75rem; }

.loading-text {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Solo battle mode */
#screen-battle.solo-mode .player-score.p2,
#screen-battle.solo-mode .progress-duel {
  display: none;
}

#screen-battle.solo-mode .player-score.p1 {
  flex: none;
  width: 100%;
  text-align: center;
  border-left: none;
  border-top: 3px solid var(--p1-color);
}

#screen-battle.solo-mode .battle-hud {
  flex-direction: column;
  gap: 8px;
}

#screen-battle.solo-mode .battle-center {
  order: -1;
}

/* Online */
.online-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.online-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.online-mode-tab {
  padding: 12px;
  border: 2px solid var(--border-iron);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
}

.online-mode-tab.active {
  border-color: var(--gold);
  color: var(--text);
  background: rgba(255, 143, 0, 0.12);
}

.online-mode-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.online-mode-panel.active {
  display: flex;
}

.online-intro {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.online-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.online-tab {
  padding: 12px;
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-muted);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
}

.online-tab.active {
  border-color: var(--gold);
  color: var(--text);
  background: rgba(255, 143, 0, 0.12);
}

.online-panel {
  display: none;
  flex-direction: column;
  gap: 16px;
}

.online-panel.active {
  display: flex;
}

.matchmaking-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 2px solid var(--border-gold);
  background: rgba(255, 143, 0, 0.1);
  text-align: center;
}

.matchmaking-banner.hidden {
  display: none;
}

.matchmaking-banner p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text);
}

.matchmaking-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 143, 0, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.level-select-mini select {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.code-input {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  max-width: 100%;
}

.room-code-value {
  display: block;
  font-size: clamp(1.8rem, 8vw, 2.5rem);
  font-weight: 800;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin: 8px 0 16px;
  max-width: 100%;
  overflow: hidden;
  font-family: var(--font-display);
  text-shadow: 0 0 16px var(--accent-glow);
}

.btn-small {
  min-height: 36px;
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* Lobby */
.lobby-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: center;
}

.room-code-display {
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
}

.room-code-label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.lobby-level {
  text-align: center;
  width: 100%;
}

.lobby-level h3 {
  font-size: 1.2rem;
}

.lobby-level p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lobby-players {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.lobby-player {
  flex: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  opacity: 0.5;
  transition: opacity 0.3s;
}

.lobby-player.ready {
  opacity: 1;
}

.lobby-player.p1 { border-top: 3px solid var(--p1-color); }
.lobby-player.p2 { border-top: 3px solid var(--p2-color); }

.lobby-slot {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.lobby-name {
  display: block;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 4px;
}

.lobby-vs {
  font-weight: 800;
  color: var(--text-muted);
}

.lobby-status {
  color: var(--text-muted);
  font-size: 0.95rem;
  text-align: center;
}

.lobby-status.countdown-active {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 16px var(--accent-glow);
  letter-spacing: 0.02em;
}

.battle-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(13, 7, 7, 0.86);
  backdrop-filter: blur(4px);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.24s ease, visibility 0.24s ease;
}

.battle-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.battle-overlay-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 12vw, 4rem);
  font-weight: 800;
  color: var(--gold);
  text-shadow: 0 0 24px var(--accent-glow);
  margin: 0 0 24px;
}

.battle-overlay-btn {
  min-width: min(280px, 80vw);
}

.battle-overlay-btn:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.player-slot-red {
  color: var(--p1-color);
}

.player-slot-blue {
  color: var(--p2-color);
}

.battle-overlay-sub {
  margin: 8px 0 0;
  font-size: 1rem;
  color: var(--text-muted);
}

.player-score.score-pulse {
  animation: scorePulse 0.6s ease;
}

@keyframes scorePulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.08); box-shadow: 0 0 24px var(--accent-glow); }
  100% { transform: scale(1); }
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(24px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-elevated);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 30px;
  font-weight: 600;
  font-size: 0.9rem;
  z-index: 1000;
  transition: transform 0.3s;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.hidden {
  display: block;
}

.hidden {
  display: none !important;
}

@media (min-width: 480px) {
  .level-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  #app {
    max-width: 480px;
    margin: 0 auto;
    border-left: 1px solid rgba(184, 134, 11, 0.3);
    border-right: 1px solid rgba(184, 134, 11, 0.3);
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
  }
}
