/* WordWeft Web Client — Theme support (dark/light) */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Design tokens live in ww2-tokens.css (loaded after this file), which
   redeclares every color token below in cascade order. The legacy :root and
   body.light-theme blocks that used to sit here were dead and were removed.
   The non-color tokens they also defined (--radius*, --safe-top/--safe-bottom)
   were NOT duplicated in ww2-tokens.css, so they moved there to keep working. */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html, body {
    height: 100dvh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

/* Screen management */
.screen {
    display: none;
    position: fixed;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.screen.active {
    display: block;
}

/* Buttons */
/* Suppress iOS Safari's text-selection callout on every interactive
 * surface — long-pressing the LASSO / JUMP / dock / chip buttons
 * during gameplay was triggering the "Copy / Look Up / Translate"
 * popover, which steals taps. Limit to interactive elements so
 * inputs + story text stay selectable. */
button,
.btn,
.player-order-chip,
.player-item,
.icon-btn,
[role="button"] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
    border-radius: var(--radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    -webkit-user-select: none;
    user-select: none;
}
.btn:active {
    transform: scale(0.97);
}
.btn:disabled {
    opacity: 0.4;
    cursor: default;
    transform: none;
}
.btn-large {
    width: 100%;
    height: 56px;
    font-size: 18px;
}
.btn-small {
    height: 36px;
    padding: 0 16px;
    font-size: 13px;
    border-radius: var(--radius-xs);
}
.btn-primary {
    background: var(--accent-indigo);
    color: white;
}
.btn-secondary {
    background: transparent;
    color: var(--accent-indigo);
    border: 2px solid var(--accent-indigo);
}
.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}
.game-mode-selector {
    margin-bottom: 16px;
}
.game-mode-selector label {
    display: block;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 8px;
}
.mode-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-mode {
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid var(--accent-indigo);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}
.btn-mode.active {
    background: rgba(124,111,232, 0.2);
    color: var(--accent-indigo);
    border-color: var(--accent-indigo);
}

/* Side-by-side music settings (Lobby | Waiting) */
/* Music selection — Android-parity. Per-section card grid (2 cols),
 * each card a row with the music name + a play/pause button on the
 * right. Card body click selects; play button click previews. Selected
 * state fills the card with the accent color. */
.music-section {
    margin-top: 16px;
}
.music-section h4 {
    margin: 0 0 4px;
}
.music-section-sub {
    margin: 0 0 10px;
    font-size: 12px;
    color: var(--text-muted, #8D7FAE);
    line-height: 1.4;
}
.music-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.music-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid rgba(124, 111, 232, 0.5);
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, border-color 0.15s;
    min-height: 44px;
}
.music-card:hover {
    background: rgba(124, 111, 232, 0.08);
}
.music-card.selected {
    background: rgba(124, 111, 232, 0.22);
    border-color: rgba(124, 111, 232, 0.9);
}
.music-card-name {
    color: #EEE6FF;
    font-weight: 600;
    font-size: 13px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.music-card-play {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border: none;
    background: rgba(124, 111, 232, 0.18);
    color: #B8A8FF;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-family: inherit;
}
.music-card-play:hover { background: rgba(124, 111, 232, 0.32); }
.music-card-play.playing {
    background: #7C6FE8;
    color: #FFFFFF;
}
@media (max-width: 380px) {
    .music-grid { grid-template-columns: 1fr; }
}

/* Color picker grid */
.color-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 8px 0;
}
.color-option {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}
.color-option:hover { transform: scale(1.15); }
.color-option.selected { border-color: white; transform: scale(1.15); }
.color-option.taken { opacity: 0.3; cursor: not-allowed; }

/* Lobby settings */
.lobby-settings {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 16px;
}
.setting-group {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
}
.setting-group > label {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.setting-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
    opacity: 0.7;
}

/* Story starter pills */
.starter-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 4px;
}

/* Service worker update banner */
#sw-update-banner {
    position: fixed;
    left: 50%;
    bottom: 16px;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #1E1E36;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.35);
    font-size: 14px;
}
#sw-update-banner button {
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}
#sw-update-reload {
    background: #7C6FE8;
    color: #fff;
}
#sw-update-dismiss {
    background: transparent;
    color: #888898;
    padding: 4px 8px;
    font-weight: 400;
}
.btn-starter {
    padding: 6px 12px;
    border-radius: 16px;
    border: 1.5px solid rgba(255,255,255,0.15);
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-starter.active {
    background: var(--accent-green);
    color: white;
    border-color: var(--accent-green);
}

/* Timer buttons */
.btn-timer {
    padding: 8px 14px;
    border-radius: 20px;
    border: 2px solid var(--accent-amber);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}
.btn-timer.active {
    background: rgba(245, 158, 11, 0.2);
    color: var(--accent-amber);
    border-color: var(--accent-amber);
}

/* Toggle switch */
.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    text-transform: none !important;
    font-weight: normal !important;
}
.toggle-input {
    display: none;
}
.toggle-slider {
    width: 44px;
    height: 24px;
    background: rgba(255,255,255,0.3);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-slider::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle-input:checked + .toggle-slider {
    background: var(--accent-amber);
}
.toggle-input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

.btn-green {
    background: var(--accent-green);
    color: white;
}
.btn-google {
    background: white;
    color: #333;
    font-size: 15px;
    height: 44px;
    padding: 0 20px;
    border-radius: var(--radius-sm);
    width: 100%;
}
.btn-icon {
    font-size: 18px;
}
.btn-back {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    margin: -8px;
}

/* Input */
.input-field {
    width: 100%;
    height: 52px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 16px;
    padding: 0 16px;
    outline: none;
    transition: border-color 0.2s;
}
.input-field:focus {
    border-color: var(--accent-indigo);
}
.input-field::placeholder {
    color: var(--text-muted);
}

/* Dialog */
.dialog {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}
.dialog.hidden {
    display: none;
}
.dialog-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 400px;
}
/* Dialog titles are <h2> (one level below the page <h1>) to keep the home
   screen's heading order from jumping h1 → h3. */
.dialog-content h2 {
    font-size: 20px;
    margin-bottom: 4px;
    font-weight: 700;
}
.dialog-subtitle {
    color: var(--text-secondary);
    font-size: 13px;
    margin-bottom: 16px;
}
.dialog-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}
.dialog-buttons .btn {
    flex: 1;
    height: 44px;
}

/* Avatar grid */
.avatar-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin-top: 16px;
}
.avatar-option {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    border-radius: 10px;
    cursor: pointer;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(245,240,255,0.08);
    transition: background 0.15s, border-color 0.15s;
}
.avatar-option:hover {
    background: rgba(124,111,232,0.15);
}
.avatar-option.selected {
    background: rgba(124,111,232,0.22);
    border: 1.5px solid var(--accent-indigo);
}

.hidden {
    display: none !important;
}

/* ─── Home Screen ─────────────────────────────────────── */

.home-container {
    min-height: 100%;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-input) 100%);
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 480px;
    margin: 0 auto;
}

.logo-section {
    text-align: center;
    margin-top: 24px;
    margin-bottom: 12px;
}
.logo-placeholder {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    border-radius: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    color: white;
    margin: 0 auto 16px;
}
.logo-img {
    width: 100px;
    height: 100px;
    border-radius: 24px;
    margin: 0 auto 16px;
    display: block;
}
.logo-section h1 {
    font-size: 42px;
    font-weight: 800;
    letter-spacing: -1px;
}
.tagline {
    color: var(--text-secondary);
    font-style: italic;
    font-size: 16px;
    margin-top: 8px;
}

/* User bar */
.user-bar {
    width: 100%;
    background: var(--bg-card);
    border-radius: 14px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.user-avatar {
    font-size: 28px;
}
.user-info {
    display: flex;
    flex-direction: column;
    flex: 1;
}
.user-name {
    font-weight: 700;
    font-size: 16px;
}
.user-level {
    font-size: 12px;
    color: var(--accent-indigo);
    font-weight: 600;
}
.xp-bar-container {
    flex: 1;
    height: 6px;
    background: var(--text-dim);
    border-radius: 3px;
    overflow: hidden;
}
.xp-bar {
    height: 100%;
    background: var(--accent-indigo);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}
.xp-text {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
}

.streak-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: rgba(245,158,11,0.15);
    border: 1px solid rgba(245,158,11,0.3);
    border-radius: 20px;
    padding: 8px 18px;
    margin-top: 12px;
}
.streak-fire { font-size: 18px; }
.streak-count {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-amber);
}
.streak-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.button-group {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

.auth-status {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

/* Daily challenge */
.daily-challenge {
    width: 100%;
    background: linear-gradient(135deg, rgba(124,111,232,0.15), rgba(154,135,242,0.15));
    border: 1px solid rgba(124,111,232,0.3);
    border-radius: var(--radius);
    padding: 16px;
    margin-top: 16px;
}
.challenge-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.challenge-icon { font-size: 18px; }
.challenge-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-indigo);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.challenge-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
}
.challenge-reward {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-amber);
    margin-top: 6px;
}


.top-icon-bar {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding: 8px 4px 0;
}
.top-icon-btn {
    background: none;
    border: none;
    font-size: 22px;
    padding: 6px 8px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s ease, transform 0.15s ease;
    line-height: 1;
}
.top-icon-btn:hover {
    opacity: 0.9;
    transform: scale(1.15);
}
.top-icon-btn:active {
    transform: scale(0.95);
}

/* ─── Lobby Screen ────────────────────────────────────── */

.lobby-container {
    min-height: 100%;
    background: linear-gradient(180deg, var(--bg-primary), var(--bg-secondary));
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    max-width: 480px;
    margin: 0 auto;
}
.lobby-container h2 {
    font-size: 22px;
    margin-bottom: 16px;
    display: inline-block;
    margin-left: 12px;
}

.room-code-display {
    background: linear-gradient(135deg, #2D1F5E, #3D2B7E);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    border: 1px solid rgba(154,135,242,0.25);
}
.room-code-label {
    font-size: 11px;
    color: #A78BFA;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}
.room-code-value {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 4px;
    flex: 1;
    font-family: 'Courier New', monospace;
}
.players-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.players-section h4 {
    color: var(--accent-indigo);
    font-size: 14px;
    margin-bottom: 10px;
    font-weight: 700;
}
.player-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: rgba(255,255,255,0.04);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.06);
}
.player-item-avatar {
    font-size: 24px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.05);
    border-radius: 50%;
}
.player-item-name {
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}
.player-item-host {
    font-size: 11px;
    color: var(--accent-green);
    background: rgba(16,185,129,0.15);
    padding: 3px 10px;
    border-radius: 10px;
    font-weight: 600;
}
.btn-lobby-music {
    float: right;
    background: rgba(124,111,232,0.15);
    border: 1px solid rgba(124,111,232,0.3);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 16px;
    cursor: pointer;
    color: var(--accent-indigo);
    margin-top: 4px;
    transition: opacity 0.2s;
}
.btn-lobby-music.muted {
    opacity: 0.4;
    text-decoration: line-through;
}
.lobby-invite-btn {
    display: block;
    margin: 8px auto 16px;
    color: var(--accent-green);
    border-color: var(--accent-green);
    font-size: 14px;
}
.lobby-status {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 20px;
    padding: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
}

/* Joiner waiting panel */
.lobby-waiting-panel {
    text-align: center;
    margin-top: 20px;
    padding: 24px 16px 16px;
}
.waiting-yarn {
    font-size: 64px;
    line-height: 1;
    display: inline-block;
    animation: waiting-pulse 1.4s ease-in-out infinite;
    will-change: transform;
}
.waiting-wefty-img {
    width: 96px;
    height: 96px;
    display: block;
}
@keyframes waiting-pulse {
    0%, 100% { transform: scale(0.85); }
    50%      { transform: scale(1.18) rotate(-6deg); }
}

/* Waving Wefty on the first tutorial slide — body static, arm waves */
.tutorial-wefty-wrap {
    position: relative;
    width: 180px;
    aspect-ratio: 1 / 1;
    margin: 0 auto 16px;
    animation: splash-body-bob 1.6s ease-in-out infinite;
}
.tutorial-wefty-body,
.tutorial-wefty-arm {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}
.tutorial-wefty-arm {
    transform-origin: 16% 48%;
    animation: wefty-arm-wave 0.9s ease-in-out infinite;
}

/* Celebrating Wefty on results screen */
.results-celebrate-wrap {
    display: flex;
    justify-content: center;
    margin: 0 auto 8px;
}
.results-celebrate {
    width: 160px;
    height: auto;
    animation: results-celebrate-bounce 0.9s ease-in-out infinite;
    will-change: transform;
}
@keyframes results-celebrate-bounce {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50%      { transform: translateY(-10px) rotate(3deg); }
}

/* Easter-egg: small waving Wefty in the home-screen corner — tap to
   get an invite to wefty.net. Positioned so it doesn't interfere
   with the main CTA stack. */
.wefty-egg {
    position: fixed;
    right: 14px;
    bottom: 14px;
    width: 64px;
    height: 64px;
    z-index: 50;
    display: block;
    text-decoration: none;
    cursor: pointer;
    animation: wefty-egg-bob 2.6s ease-in-out infinite;
    filter: drop-shadow(0 4px 12px rgba(0,0,0,0.35));
}
.wefty-egg img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}
.wefty-egg .wefty-egg-arm {
    transform-origin: 16% 48%;
    animation: wefty-arm-wave 0.9s ease-in-out infinite;
}
@keyframes wefty-egg-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}
@keyframes splash-body-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}
@keyframes wefty-arm-wave {
    0%, 100% { transform: rotate(-18deg); }
    50%      { transform: rotate(18deg); }
}

/* Wefty mascot: layered base + blink frame. Blink fades in briefly
   every few seconds; base gets a gentle "breathing" scale pulse. */
.wefty-mascot {
    position: relative;
    display: inline-block;
    line-height: 0;
    animation: wefty-breathe 3.6s ease-in-out infinite;
    will-change: transform;
}
.wefty-mascot img {
    display: block;
    width: 100%;
    height: auto;
}
.wefty-mascot .wefty-blink {
    position: absolute;
    inset: 0;
    opacity: 0;
    animation: wefty-blink-cycle 4.8s steps(1, end) infinite;
}
.wefty-lobby {
    width: 96px;
    display: block;
    margin: 4px auto 12px;
}
@keyframes wefty-breathe {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.04); }
}
@keyframes wefty-blink-cycle {
    /* Eyes open 95% of the time, closed for a ~120ms flash */
    0%, 95%  { opacity: 0; }
    96%, 98% { opacity: 1; }
    100%     { opacity: 0; }
}

.waiting-status {
    margin-top: 10px;
    font-size: 18px;
    font-weight: 600;
    color: var(--accent-purple);
}
.waiting-message {
    margin-top: 4px;
    font-size: 13px;
    font-style: italic;
    color: var(--text-muted);
    min-height: 18px;
    transition: opacity 0.4s ease;
}
.host-setup-card {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    text-align: left;
}
.host-setup-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent-purple);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 8px;
}
.host-setup-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-size: 13px;
}
/* App version badge on the home screen — small muted mono text so
   users can verify at a glance which deploy they're running.
   Horizontally centered regardless of parent alignment. */
.app-version {
    display: block;
    width: 100%;
    text-align: center;
    margin: 24px auto 0;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 10px;
    /* Was --text-dim (--ww-ink-3 #5A4F75 ≈ 2.5:1 on --ww-bg-0) plus 0.6
       opacity, which failed AA badly. --ww-ink-2 at full opacity is ≈5.15:1
       (dark) / ≈4.84:1 (light) — passes while staying visually muted. */
    color: var(--ww-ink-2);
    letter-spacing: 0.5px;
    opacity: 1;
    align-self: center;
}

.host-setup-row > span:first-child  { color: var(--text-muted); }
.host-setup-row > span:last-child   { color: var(--text-primary); font-weight: 500; }

/* Value pills on the joiner waiting screen — visually match the
   host's active-pill look in the lobby settings so the joiner sees
   what the host picked in the same language. Read-only. */
.host-setup-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: 20px;
    border: 2px solid var(--accent-indigo);
    background: rgba(124,111,232, 0.2);
    color: var(--accent-indigo) !important;
    font-size: 13px;
    font-weight: 600 !important;
    white-space: nowrap;
}
/* Starter pills use the 'free play' emerald accent — matches the
   active Starter look in the host controls. */
.host-setup-pill.pill-starter {
    border-color: var(--accent-green);
    background: rgba(16,185,129, 0.18);
    color: var(--accent-green) !important;
}
/* Timer pills use the gold accent to match the host controls. */
.host-setup-pill.pill-timer {
    border-color: var(--accent-amber);
    background: rgba(251,191,36, 0.18);
    color: var(--accent-amber) !important;
}

/* ─── Game Screen ─────────────────────────────────────── */

.game-container {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    max-width: 600px;
    margin: 0 auto;
}
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    padding-top: calc(12px + var(--safe-top));
    border-bottom: 1px solid var(--border);
}
.game-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.game-room-code {
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-indigo);
    background: rgba(124,111,232,0.15);
    padding: 4px 10px;
    border-radius: 6px;
}
.game-mode-label {
    font-size: 12px;
    color: var(--text-muted);
}

.story-area {
    flex: 1;
    overflow-y: auto;
    overflow-anchor: none;
    padding: 20px 16px;
    -webkit-overflow-scrolling: touch;
}
.story-text {
    font-size: 18px;
    line-height: 1.7;
    word-wrap: break-word;
}
.story-placeholder {
    color: var(--text-muted);
    font-style: italic;
}
.story-word {
    display: inline;
    transition: color 0.3s;
}
.story-word.new {
    animation: wordFadeIn 0.4s ease;
}
@keyframes wordFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

.turn-info {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border);
}
.turn-indicator {
    font-size: 14px;
    color: var(--text-secondary);
}
.turn-indicator .current-player {
    color: var(--accent-green);
    font-weight: 600;
}
.timer-display {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-amber);
    min-width: 36px;
    text-align: right;
}
.timer-display.urgent {
    color: var(--accent-red);
    animation: pulse 0.5s ease infinite alternate;
}
@keyframes pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

.typing-indicator {
    padding: 4px 16px 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    color: var(--text-muted);
}
.typing-dot {
    width: 5px;
    height: 5px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}
.typing-name {
    margin-left: 4px;
}

.input-section {
    padding: 12px 16px;
    padding-bottom: calc(12px + var(--safe-bottom));
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}
.input-row {
    display: flex;
    gap: 10px;
}
.word-input {
    flex: 1;
    height: 48px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 17px;
    padding: 0 16px;
    outline: none;
}
.word-input:focus {
    border-color: var(--accent-indigo);
}
.word-input::placeholder {
    color: var(--text-muted);
}
.word-input:disabled {
    opacity: 0.4;
}
.btn-submit {
    width: 72px;
    height: 48px;
    flex-shrink: 0;
}

/* Player order bar */
.player-order-bar {
    display: flex;
    gap: 6px;
    padding: 8px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    border-bottom: 1px solid var(--border);
}
.player-order-bar::-webkit-scrollbar { display: none; }
.player-order-chip {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 16px;
    border: 2px solid transparent;
    white-space: nowrap;
    flex-shrink: 0;
    font-size: 13px;
    opacity: 0.6;
    transition: all 0.2s;
}
.player-order-chip.active {
    opacity: 1;
    transform: scale(1.05);
}
.player-order-chip.me { font-weight: 700; }
.player-order-chip.disconnected { opacity: 0.3; }
.player-order-chip.disconnected .po-name::after { content: ' (left)'; font-size: 11px; color: var(--accent-red); }
.po-avatar { font-size: 16px; }
.po-name { font-size: 12px; }

/* Secret word area */
.secret-word-area {
    padding: 10px 16px;
    background: rgba(245,158,11,0.1);
    border-top: 1px solid rgba(245,158,11,0.2);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.secret-word-row {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}
.secret-label {
    font-size: 12px;
    color: var(--accent-amber);
}
.secret-word {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent-amber);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.secret-status {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ─── Results Screen ──────────────────────────────────── */

.results-container {
    min-height: 100%;
    background: linear-gradient(180deg, var(--bg-primary), var(--bg-secondary));
    padding: 24px;
    padding-top: calc(24px + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    max-width: 520px;
    margin: 0 auto;
    position: relative;  /* anchor for absolute-positioned .btn-results-moderate */
}
.results-container h2 {
    font-size: 28px;
    text-align: center;
    margin-bottom: 20px;
}
.results-container h4 {
    font-size: 16px;
    color: var(--text-secondary);
    margin: 20px 0 12px;
}

.story-grade-section {
    text-align: center;
    margin-bottom: 20px;
}
.result-grade {
    font-size: 64px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0;
    transform: scale(0.3);
}
.result-grade.animate-in {
    animation: gradeReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes gradeReveal {
    0% { opacity: 0; transform: scale(0.3); }
    60% { opacity: 1; transform: scale(1.15); }
    100% { opacity: 1; transform: scale(1); }
}
.result-genre {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.result-illustration {
    font-size: 48px;
    text-align: center;
}
.result-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 8px;
}
.result-tag {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 10px;
    background: rgba(124,111,232,0.15);
    color: var(--accent-indigo);
}
.result-feedback {
    font-size: 14px;
    color: #C7B8E8;
    text-align: center;
    line-height: 20px;
    margin-top: 12px;
    padding: 0 8px;
}
.result-retry-grade {
    margin-top: 16px;
    min-width: 160px;
}
.result-objectives {
    margin-top: 16px;
}
.result-objectives h4 {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.objective-result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-card);
    border-radius: var(--radius-xs);
    margin-bottom: 6px;
}
.objective-word {
    font-style: italic;
    color: var(--accent-amber);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 13px;
}
.obj-success { color: var(--accent-green); font-weight: 600; }
.obj-fail { color: var(--accent-red); font-weight: 600; }

.result-story-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 20px;
}
.result-story-card h4 {
    margin: 0 0 8px;
    color: var(--accent-indigo);
}
.result-story-text {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
}

.score-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.score-bar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateX(-10px);
}
.score-label {
    width: 80px;
    font-size: 13px;
    color: var(--text-secondary);
}
.score-bar {
    flex: 1;
    height: 8px;
    background: var(--text-dim);
    border-radius: 4px;
    overflow: hidden;
}
.score-fill {
    height: 100%;
    border-radius: 4px;
    width: 0%;
    transition: width 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
.score-bar-item.animate-in {
    animation: scoreSlideIn 0.3s ease forwards;
}
@keyframes scoreSlideIn {
    to { opacity: 1; transform: translateX(0); }
}
.player-stats-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.player-stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
}
.player-stat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.player-stat-avatar {
    font-size: 22px;
}
.player-stat-name {
    font-weight: 600;
    font-size: 15px;
    flex: 1;
}
.player-stat-impact {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-indigo);
}
.player-stat-title {
    font-size: 13px;
    color: var(--accent-amber);
    font-style: italic;
}
.player-stat-details {
    display: flex;
    gap: 16px;
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.xp-earned-section {
    text-align: center;
    margin-top: 16px;
}
.xp-earned-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--accent-green);
}

/* Finish Story button (green, matching Android) */
.btn-finish {
    color: var(--accent-amber) !important;
    border: 1px solid rgba(245,158,11,0.3);
    background: transparent;
    border-radius: var(--radius-sm);
    font-weight: 600;
}
.btn-game-moderate {
    background: transparent;
    border: 1px solid rgba(238,230,255,0.18);
    color: #B8A8FF;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 999px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    margin-left: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-game-moderate:hover { background: rgba(124,111,232,0.18); }

/* Results-screen ⚠️ button — pinned top-right of the results card so
 * the player can report someone whose offensive content they only
 * registered when they saw the full assembled story in the recap. */
.btn-results-moderate {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: 1px solid rgba(238,230,255,0.18);
    color: #B8A8FF;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: 999px;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    z-index: 5;
}
.btn-results-moderate:hover { background: rgba(124,111,232,0.18); }
.btn-finish:hover { background: rgba(245,158,11,0.15); }
.btn-finish.voted {
    color: var(--text-muted) !important;
    border-color: var(--text-muted);
    opacity: 0.6;
}

/* Results section cards */
.result-section-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
}
.result-section-title {
    margin: 0 0 12px;
    font-size: 16px;
    color: var(--accent-indigo);
    font-weight: 700;
}
.result-summary-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    text-align: center;
}

/* Story header with action buttons (btn-icon overrides the generic one with border style) */
.result-story-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
.result-story-header h4 { margin: 0; color: var(--accent-indigo); }
.result-story-actions { display: flex; gap: 4px; }
.btn-icon {
    background: transparent;
    border: 1px solid var(--text-dim);
    border-radius: var(--radius-xs);
    font-size: 16px;
    padding: 4px 8px;
    cursor: pointer;
    color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-card); }

/* Score values with /100 */
.score-value {
    width: 50px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

/* XP Breakdown */
.xp-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.xp-row:last-child { border-bottom: none; }
.xp-row-name { flex: 1; font-weight: 600; }
.xp-row-value { color: #10B981; font-weight: 700; }
.xp-row-level { color: var(--accent-indigo); font-size: 13px; font-weight: 600; }

/* Podium */
.result-podium-section {
    margin-bottom: 16px;
}
.podium-display {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 8px;
    margin-top: 12px;
    padding-bottom: 8px;
}
.podium-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 80px;
    opacity: 0;
}
.podium-col.animate-in {
    animation: podiumEntrance 0.5s ease forwards;
}
@keyframes podiumEntrance {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}
.podium-avatar { font-size: 28px; margin-bottom: 4px; }
.podium-name { font-weight: 700; font-size: 13px; margin-bottom: 2px; }
.podium-score { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.podium-bar {
    width: 90px;
    border-radius: var(--radius-xs) var(--radius-xs) 0 0;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
}
.podium-rank {
    font-weight: 800;
    font-size: 18px;
    color: rgba(255,255,255,0.9);
}

/* Report Cards */
.report-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 12px;
}
.report-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.report-rank { font-weight: 700; color: var(--text-muted); font-size: 14px; }
.report-impact {
    font-size: 22px;
    font-weight: 800;
    color: var(--accent-indigo);
    background: rgba(124,111,232,0.12);
    border-radius: var(--radius-xs);
    padding: 4px 10px;
}
.report-comment {
    font-style: italic;
    color: var(--text-muted);
    font-size: 13px;
    margin: 4px 0 10px;
}
.report-stats-grid {
    display: flex;
    gap: 24px;
    margin-bottom: 10px;
}
.report-stat { text-align: center; }
.report-stat-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-indigo);
}
.report-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}
.report-language {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.lang-badge {
    background: rgba(16,185,129,0.15);
    color: #10B981;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-xs);
    font-size: 13px;
}
.lang-name { color: var(--accent-green); font-size: 13px; }
.report-best {
    color: var(--text-muted);
    font-size: 12px;
    margin-left: auto;
}
.report-longest {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Objective toast notification */
.objective-toast {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--accent-amber);
    border-radius: var(--radius-sm);
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-primary);
    z-index: 1000;
    transition: top 0.3s ease;
    white-space: nowrap;
}
.objective-toast.show { top: 20px; }

/* Host migration bar */
/* Pause banner (2-player disconnect) */
.pause-banner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: linear-gradient(180deg, rgba(245,158,11,0.15), rgba(245,158,11,0.05));
    border-bottom: 1px solid rgba(245,158,11,0.3);
    padding: 12px 16px;
    text-align: center;
    animation: slideDown 0.3s ease;
}
.pause-text {
    color: var(--accent-amber);
    font-weight: 600;
    font-size: 14px;
}
.pause-sub {
    color: var(--accent-amber);
    opacity: 0.7;
    font-size: 12px;
    margin-top: 4px;
}
.pause-progress {
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.pause-progress-fill {
    height: 100%;
    background: var(--accent-amber);
    border-radius: 2px;
    width: 100%;
    transition: width 1s linear;
}
.pause-actions {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

.host-migration-bar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 50;
    background: linear-gradient(180deg, rgba(239,68,68,0.15), rgba(245,158,11,0.08));
    border-bottom: 1px solid rgba(239,68,68,0.3);
    padding: 12px 16px;
    text-align: center;
    animation: slideDown 0.3s ease;
}
.migration-text {
    color: var(--accent-red);
    font-weight: 600;
    font-size: 14px;
}
.migration-icon { margin-right: 6px; }
.migration-sub {
    color: var(--accent-amber);
    font-size: 12px;
    margin-top: 4px;
}
.migration-progress {
    height: 3px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    margin-top: 8px;
    overflow: hidden;
}
.migration-progress-fill {
    height: 100%;
    background: var(--accent-amber);
    border-radius: 2px;
    width: 100%;
    transition: width 1s linear;
}
.migration-actions {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Guess modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 900;
}
.modal-card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 340px;
    width: 90%;
}
.modal-card h3 { margin: 0 0 4px; color: var(--accent-amber); }
.modal-desc { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }
.guess-player-list { display: flex; flex-direction: column; gap: 6px; }
.guess-player-btn { text-align: left; font-size: 15px; padding: 8px 12px; border-radius: var(--radius-xs); }
.guess-input-area { display: flex; gap: 8px; margin-top: 10px; }
.guess-input-area .word-input { flex: 1; }

/* Achievement progress items */
.ach-progress-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.ach-progress-item:last-child { border-bottom: none; }
.ach-progress-icon { font-size: 24px; }
.ach-progress-info { flex: 1; }
.ach-progress-name { font-size: 13px; font-weight: 600; }
.ach-progress-desc { font-size: 11px; color: var(--text-muted); }
.ach-progress-remaining {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-amber);
    white-space: nowrap;
}

/* Highlights */
.highlight-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.highlight-item:last-child { border-bottom: none; }
.highlight-icon { font-size: 20px; }
.highlight-text { font-size: 13px; color: var(--text-secondary); }
.highlight-value {
    font-weight: 700;
    color: var(--accent-indigo);
    margin-left: auto;
    white-space: nowrap;
}

/* Challenge friends */
.result-challenge-section {
    margin-top: 20px;
}

/* Auth prompt on results screen */
.result-auth-prompt {
    margin-top: 20px;
}
.auth-prompt-card {
    background: var(--bg-card);
    border: 1px solid rgba(124,111,232,0.3);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}
.auth-prompt-icon {
    font-size: 28px;
}
.auth-prompt-text {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 24px;
}
.result-buttons .btn-large {
    height: 52px;
}

/* Utilities */
.text-center { text-align: center; }
.mt-12 { margin-top: 12px; }

/* Player colors (matching Android) */
.color-0 { color: #FF6B6B; }
.color-1 { color: #4ECDC4; }
.color-2 { color: #45B7D1; }
.color-3 { color: #96CEB4; }
.color-4 { color: #FFEAA7; }
.color-5 { color: #DDA0DD; }
.color-6 { color: #98D8C8; }
.color-7 { color: #F7DC6F; }

/* Score bar colors */
.score-coherence { background: #7C6FE8; }
.score-creativity { background: #9A87F2; }
.score-entertainment { background: #F59E0B; }
.score-vocabulary { background: #10B981; }
.score-flow { background: #3B82F6; }

/* Player Card score-breakdown toggle */
.report-impact.clickable {
    cursor: pointer;
    user-select: none;
    transition: transform 0.1s;
}
.report-impact.clickable:hover { opacity: 0.85; }
.report-impact.clickable:active { transform: scale(0.95); }
.report-breakdown {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease;
    margin-top: 0;
}
.report-breakdown.open {
    max-height: 600px;
    margin-top: 8px;
}
.report-breakdown .bd-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted, #888898);
    margin: 6px 0 6px;
}
.report-breakdown .bd-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.report-breakdown .bd-label {
    font-size: 12px;
    color: var(--text-secondary, #B0B0C8);
    width: 90px;
    flex-shrink: 0;
}
.report-breakdown .bd-bar-track {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}
.report-breakdown .bd-bar-fill {
    height: 100%;
    background: #7C6FE8;
    border-radius: 3px;
    transition: width 0.4s ease;
}
.report-breakdown .bd-pts {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-green, #10B981);
    min-width: 32px;
    text-align: right;
}
.report-breakdown .bd-types {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.report-breakdown .bd-type {
    font-size: 11px;
    background: rgba(124,111,232,0.12);
    color: var(--accent-indigo, #7C6FE8);
    padding: 2px 8px;
    border-radius: 8px;
}

/* Word Level Guide (above player cards) */
.word-level-guide {
    background: rgba(124,111,232,0.06);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
}
.word-level-guide .wlg-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}
.word-level-guide .wlg-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-indigo, #7C6FE8);
}
.word-level-guide .wlg-toggle {
    font-size: 11px;
    color: var(--text-muted, #888898);
}
.word-level-guide .wlg-body {
    margin-top: 10px;
    overflow: hidden;
    transition: max-height 0.25s ease;
}
.word-level-guide.collapsed .wlg-body {
    max-height: 0;
    margin-top: 0;
}
.word-level-guide:not(.collapsed) .wlg-body {
    max-height: 400px;
}
.word-level-guide .wlg-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}
.word-level-guide .wlg-code {
    font-size: 13px;
    font-weight: 700;
    width: 28px;
}
.word-level-guide .wlg-name {
    font-size: 12px;
    font-weight: 600;
    width: 90px;
}
.word-level-guide .wlg-desc {
    font-size: 11px;
    color: var(--text-secondary, #A0A0B8);
    flex: 1;
}

/* Profile Screen */
.profile-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 24px 16px;
}
.profile-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
}
/* Settings avatar (design: circular tinted well with halo ring). */
.profile-avatar-ring {
    width: 84px;
    height: 84px;
    margin: 0 auto 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 25%,
        rgba(124,111,232,0.35), rgba(124,111,232,0.12) 70%);
    border: 2px solid var(--accent-indigo);
    box-shadow: 0 0 0 3px rgba(124,111,232,0.18);
}
.profile-avatar {
    font-size: 50px;
    line-height: 1;
}
.profile-name {
    font-size: 22px;
    font-weight: bold;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
/* Tap-to-edit username: input renders as static display text at rest;
   only shows the edit affordance when focused. */
.profile-name-edit {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    font-size: 22px;
    font-weight: bold;
    text-align: center;
    padding: 4px 8px;
    width: 180px;
    border-radius: 6px;
    cursor: text;
    transition: background 0.15s, border-color 0.15s;
}
.profile-name-edit:hover:not(:focus) {
    background: rgba(124,111,232,0.08);
}
.profile-name-edit:focus {
    outline: none;
    background: rgba(124,111,232,0.12);
    border-color: var(--accent-indigo);
}
.profile-auth-section {
    text-align: center;
    padding: 12px 0;
}
.profile-rank {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: 0.02em;
}
.profile-xp-bar {
    height: 5px;
    background: rgba(255,255,255,0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 0 40px 6px;
}
.profile-xp-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-indigo), #818cf8);
    border-radius: 4px;
    transition: width 0.5s;
}
.profile-xp-text {
    font-size: 12px;
    color: var(--text-secondary);
}
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 16px 8px;
    text-align: center;
}
.stat-value {
    font-size: 24px;
    font-weight: bold;
    color: var(--accent-indigo);
}
.stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.profile-settings {
    margin-top: 20px;
}
.profile-settings h4 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-indigo);
    margin: 16px 0 8px;
}
.settings-auto-save {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 20px;
    font-style: italic;
}
.blocked-users-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.blocked-users-list .row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
    color: #e6e6f0;
}
.blocked-users-list .row button {
    background: transparent;
    border: none;
    color: var(--accent-red);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 8px;
}
.blocked-users-list .row button:hover { text-decoration: underline; }
.settings-legal {
    text-align: center;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}
.settings-legal-link {
    color: var(--text-muted);
    text-decoration: underline;
    text-decoration-color: rgba(255, 255, 255, 0.2);
}
.settings-legal-link:hover { color: var(--accent-indigo); }
.settings-legal-sep { margin: 0 6px; opacity: 0.5; }

/* Leaderboard Screen */
.leaderboard-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 24px 16px;
}
.leaderboard-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}
.btn-tab {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-md);
    border: 2px solid var(--accent-indigo);
    background: transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}
.btn-tab.active {
    background: var(--accent-indigo);
    color: white;
}
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.leaderboard-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 40px 16px;
}
.lb-entry {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    gap: 12px;
}
.lb-rank {
    font-size: 18px;
    font-weight: bold;
    color: var(--text-secondary);
    width: 30px;
    text-align: center;
}
.lb-rank.gold { color: #F59E0B; }
.lb-rank.silver { color: #9CA3AF; }
.lb-rank.bronze { color: #CD7F32; }
.lb-avatar {
    font-size: 28px;
}
.lb-info {
    flex: 1;
}
.lb-name {
    font-weight: bold;
    color: var(--text-primary);
    font-size: 15px;
}
.lb-level {
    font-size: 12px;
    color: var(--text-secondary);
}
.lb-stats {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}
.lb-xp {
    font-weight: bold;
    color: var(--accent-indigo);
    font-size: 15px;
    text-align: right;
}
.lb-xp-label {
    font-size: 10px;
    font-weight: 400;
    color: var(--text-muted);
}
.lb-entry.top3 {
    background: var(--bg-card);
}
.lb-entry.me {
    border: 2px solid var(--accent-indigo);
}
.lb-favorite-title {
    font-size: 11px;
    color: var(--accent-amber);
    font-style: italic;
}

/* ─── Achievements Screen ────────────────────────────── */
.achievements-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 24px 16px;
}
.achievements-progress {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
    text-align: center;
}
.ach-progress-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.ach-progress-bar {
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
}
.ach-progress-fill {
    height: 100%;
    background: var(--accent-green);
    border-radius: 4px;
    transition: width 0.5s;
}
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
.achievement-card {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    transition: opacity 0.3s;
}
.achievement-card.locked {
    background: #151528;
    opacity: 1;
}
.achievement-card.locked .ach-name,
.achievement-card.locked .ach-desc {
    color: var(--text-muted);
}
.achievement-card .ach-icon {
    font-size: 32px;
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(124,111,232,0.15);
    border-radius: var(--radius-xs);
    margin-bottom: 6px;
}
.achievement-card.locked .ach-icon {
    background: rgba(255,255,255,0.05);
}
.achievement-card .ach-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.achievement-card .ach-desc {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}
.achievement-card .ach-date {
    font-size: 10px;
    color: var(--accent-green);
    margin-top: 6px;
}
.achievement-card .ach-check {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 14px;
    color: var(--accent-green);
}

/* Achievement toast */
.achievement-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, var(--accent-indigo), var(--accent-purple));
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    z-index: 200;
    animation: toastSlideIn 0.4s ease, toastSlideOut 0.4s ease 2.6s forwards;
    box-shadow: 0 4px 20px rgba(124,111,232,0.4);
    white-space: nowrap;
}
@keyframes toastSlideIn {
    from { transform: translateX(-50%) translateY(-60px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(-60px); opacity: 0; }
}

/* ─── Story History Screen ───────────────────────────── */
.history-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 24px 16px;
}
.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.history-entry {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
}
.history-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}
.history-illustration {
    font-size: 24px;
}
.history-grade-badge {
    font-size: 20px;
    font-weight: 800;
    min-width: 36px;
}
.history-meta {
    flex: 1;
    font-size: 12px;
    color: var(--text-muted);
}
.history-preview {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 8px;
}
.history-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}
.history-tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    background: rgba(124,111,232,0.15);
    color: var(--accent-indigo);
}
.history-actions {
    display: flex;
    gap: 8px;
}
.history-actions .btn {
    font-size: 12px;
    height: 30px;
    padding: 0 12px;
}

/* ─── Friends Screen ─────────────────────────────────── */
.friends-container {
    max-width: 500px;
    margin: 0 auto;
    padding: 24px 16px;
}
.my-level-card {
    background: linear-gradient(135deg, #2D1F5E, #3D2B7E);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    text-align: center;
    border: 1px solid rgba(154,135,242,0.25);
}
.my-level-avatar { font-size: 32px; }
.my-level-name { font-weight: 700; font-size: 16px; margin: 4px 0 2px; }
.my-level-rank { font-size: 13px; color: var(--accent-indigo); }
.friends-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.friend-entry {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
}
.friend-avatar { font-size: 24px; }
.friend-info { flex: 1; }
.friend-name { font-weight: 600; font-size: 15px; }
.friend-level { font-size: 12px; color: var(--text-secondary); }
.friend-games { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.friend-record {
    text-align: right;
}
.friend-wl { font-weight: 700; font-size: 15px; }
.friend-wins { color: var(--accent-green); }
.friend-losses { color: var(--accent-red); }
.friend-wl-label { font-size: 10px; color: var(--text-muted); }

/* ─── Tutorial Screen ────────────────────────────────── */
.tutorial-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(180deg, var(--bg-primary), var(--bg-secondary));
}
.tutorial-slides { width: 100%; max-width: 360px; }
.tutorial-slide {
    text-align: center;
    padding: 20px;
}
.tutorial-slide.hidden { display: none; }
.tutorial-icon { font-size: 64px; margin-bottom: 16px; }
.tutorial-slide h2 { font-size: 22px; margin-bottom: 12px; }
.tutorial-slide p { color: var(--text-secondary); font-size: 15px; line-height: 1.6; }
.tutorial-dots {
    display: flex;
    gap: 8px;
    margin: 24px 0;
}
.tutorial-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: background 0.2s;
}
.tutorial-dot.active { background: var(--accent-indigo); }
.tutorial-buttons {
    display: flex;
    gap: 12px;
    width: 100%;
    max-width: 360px;
}
.tutorial-buttons .btn { flex: 1; }

/* ─── Toggle Rows ──────────────────────────────────── */
.theme-toggle-row,
.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    gap: 12px;
}
.theme-label,
.toggle-row-label {
    font-size: 14px;
    color: var(--text-secondary);
}
.toggle-row .setting-desc {
    margin: 2px 0 0;
    font-size: 12px;
}
.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
}
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}
.toggle-switch .toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--text-muted);
    border-radius: 26px;
    transition: background 0.3s;
    width: auto;
    height: auto;
    border: none;
}
.toggle-switch .toggle-slider::after {
    display: none;
}
.toggle-switch .toggle-slider:before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
    background: var(--accent-indigo);
}
.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* ─── Font Size Slider ───────────────────────────────── */
.font-size-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.font-size-label {
    color: var(--text-secondary);
    font-size: 14px;
}
.font-size-label.font-size-large { font-size: 22px; }
.font-slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    border-radius: 3px;
    background: var(--text-dim);
    outline: none;
}
.font-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent-indigo);
    cursor: pointer;
}
/* The slider drops the native outline (above); give keyboard users a visible
   focus ring back. ww2-polish.css only restored focus rings for text inputs. */
.font-slider:focus-visible {
    box-shadow: 0 0 0 3px var(--bg-primary), 0 0 0 5px var(--accent-indigo);
}
.font-slider:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px var(--bg-primary), 0 0 0 5px var(--accent-indigo);
}
.font-slider:focus-visible::-moz-range-thumb {
    box-shadow: 0 0 0 3px var(--bg-primary), 0 0 0 5px var(--accent-indigo);
}
.font-size-value {
    font-size: 13px;
    color: var(--text-secondary);
    min-width: 40px;
    text-align: right;
}

/* ─── Confetti ───────────────────────────────────────── */
.confetti-container {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 150;
    overflow: hidden;
}
.confetti-particle {
    position: absolute;
    top: -10px;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    animation: confettiFall 2s ease-out forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0deg) translateX(0); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg) translateX(var(--sway, 0px)); opacity: 0; }
}
@keyframes slideDown {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.replay-cursor {
    animation: blink 0.8s step-end infinite;
}

/* ─── Public lobbies discovery screen ─────────────────────────── */
.dialog-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 8px 4px 0;
    text-align: center;
}
.public-rooms-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 16px;
}
.public-room-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.1s ease;
}
.public-room-card:hover { background: #25254a; }
.public-room-card:active { transform: scale(0.99); }
.public-room-card.is-full { cursor: not-allowed; opacity: 0.6; }
.public-room-card.is-full:hover { background: var(--bg-card); }
.public-room-avatar {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: #333355;
    font-size: 22px;
    flex-shrink: 0;
}
.public-room-info { flex: 1; min-width: 0; }
.public-room-host {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.public-room-meta {
    margin-top: 2px;
    font-size: 12px;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.public-room-objectives {
    margin-top: 2px;
    font-size: 11px;
    font-style: italic;
    color: var(--accent-amber);
}
.public-room-count { text-align: right; }
.public-room-count-num {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent-green);
}
.public-room-card.is-full .public-room-count-num { color: var(--accent-red); }
.public-room-count-label {
    font-size: 10px;
    color: var(--text-muted);
}
.public-empty {
    text-align: center;
    padding: 40px 16px;
    color: var(--text-secondary);
}
.public-empty-emoji { font-size: 48px; }
.public-empty-title {
    margin-top: 12px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.public-empty-sub {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-muted);
}
