/* Hexpell Web - Dark theme matching iOS app */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
    /* Brand colors */
    --forge-blue: #3380ff;
    --forge-orange: #ff8c1a;
    --forge-green: #33cc66;
    --forge-purple: #9933e6;

    /* Backgrounds */
    --bg-primary: #14141e;
    --bg-secondary: #1e1e2d;
    --bg-card: #1e1e2e;
    --bg-surface: #1a1a28;
    --bg-hover: #262640;

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: #9999bb;
    --text-muted: #666688;

    /* Tile states */
    --tile-neutral: #33334a;
    --tile-selected: #4d99ff;
    --tile-invalid: #802626;

    /* Status */
    --valid-green: #33cc66;
    --invalid-red: #cc3333;
    --warning-yellow: #ccaa33;

    /* Sizing */
    --header-height: 56px;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.screen.active {
    display: flex;
}

/* ===== HOME SCREEN ===== */
#home-screen {
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 40px 24px;
    background: var(--bg-primary);
    overflow-y: auto;
}

.home-title {
    font-size: 52px;
    font-weight: 900;
    letter-spacing: 4px;
    text-transform: uppercase;
    background: linear-gradient(135deg, var(--forge-blue), var(--forge-purple), var(--forge-orange));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-align: center;
    line-height: 1.1;
}

.home-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-top: -8px;
}

.home-hex-icon {
    width: 100px;
    height: 100px;
    margin: 8px 0;
}

.home-hex-icon svg {
    width: 100%;
    height: 100%;
}

.mode-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 380px;
    margin-top: 12px;
}

.mode-card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.mode-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.12);
}

.mode-card:active {
    transform: scale(0.98);
}

.mode-card-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mode-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.mode-card-icon {
    font-size: 24px;
}

.mode-card.quick-match { border-left: 3px solid var(--forge-blue); }
.mode-card.quick-match .mode-card-title { color: var(--forge-blue); }

.difficulty-selector {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

.diff-btn {
    flex: 1;
    padding: 8px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.2s;
}

.diff-btn:hover {
    background: var(--bg-hover);
}

.diff-btn.active {
    background: var(--forge-blue);
    color: white;
    border-color: var(--forge-blue);
}

.home-footer {
    display: flex;
    gap: 16px;
    margin-top: 20px;
}

.footer-btn {
    padding: 10px 20px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.06);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.footer-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===== GAME SCREEN ===== */
#game-screen {
    background: var(--bg-primary);
}

/* Top bar */
.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-surface);
    border: none;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.back-btn:hover {
    background: var(--bg-hover);
}

.turn-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
}

.turn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.timer-display {
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 42px;
    text-align: center;
}

.timer-display.warning {
    color: var(--warning-yellow);
}

.timer-display.critical {
    color: var(--invalid-red);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.header-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--bg-surface);
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Territory bar */
.territory-bar-container {
    padding: 0 16px;
    padding-top: 8px;
    flex-shrink: 0;
}

.territory-bar {
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    background: var(--tile-neutral);
    transition: all 0.4s ease;
}

.territory-segment {
    height: 100%;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Player seats */
.player-seats {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.player-seat {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.04);
    min-width: 100px;
    flex: 1;
    max-width: 180px;
}

.player-seat.current {
    border-color: rgba(255,255,255,0.15);
}

.seat-color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.seat-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.seat-name {
    font-size: 12px;
    font-weight: 600;
}

.seat-stats {
    font-size: 11px;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Board area */
.board-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    min-height: 0;
    padding: 4px;
}

.hex-board {
    display: block;
}

/* AI thinking overlay */
.ai-thinking-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--forge-orange);
    display: none;
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s ease;
}

.ai-thinking-overlay.visible {
    display: flex;
    align-items: center;
    gap: 10px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.9); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--forge-orange);
    animation: dotBounce 1.2s infinite ease-in-out;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Bottom HUD */
.bottom-hud {
    background: var(--bg-secondary);
    border-top: 1px solid rgba(255,255,255,0.04);
    padding: 10px 16px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    flex-shrink: 0;
}

/* Word preview */
.word-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    margin-bottom: 10px;
}

.word-text {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    transition: color 0.2s;
}

.word-text.valid {
    color: var(--valid-green);
}

.word-text.invalid {
    color: var(--text-muted);
}

.word-text.used {
    color: var(--warning-yellow);
    text-decoration: line-through;
}

.word-text.prefix {
    color: var(--text-secondary);
}

.word-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.word-status-dot.valid { background: var(--valid-green); }
.word-status-dot.invalid { background: var(--invalid-red); }
.word-status-dot.used { background: var(--warning-yellow); }
.word-status-dot.prefix { background: var(--text-secondary); }

.preview-score {
    font-size: 14px;
    font-weight: 600;
    color: var(--valid-green);
    background: rgba(51,204,102,0.1);
    padding: 2px 10px;
    border-radius: 8px;
}

.word-placeholder {
    font-size: 15px;
    color: var(--text-muted);
    font-style: italic;
}

/* Action buttons */
.action-buttons {
    display: flex;
    gap: 10px;
}

.action-btn {
    flex: 1;
    padding: 12px;
    border-radius: 14px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.action-btn:active {
    transform: scale(0.96);
}

.action-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: none;
}

.action-btn.clear {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    flex: 0 0 48px;
}

.action-btn.clear:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
}

.action-btn.forge {
    background: linear-gradient(135deg, var(--forge-blue), #2266dd);
    color: white;
    box-shadow: 0 4px 16px rgba(51,128,255,0.3);
}

.action-btn.forge:hover:not(:disabled) {
    box-shadow: 0 6px 24px rgba(51,128,255,0.4);
    transform: translateY(-1px);
}

.action-btn.forge:disabled {
    background: rgba(255,255,255,0.06);
    color: var(--text-muted);
    box-shadow: none;
}

.action-btn.hint {
    background: rgba(51,204,102,0.12);
    color: var(--valid-green);
    flex: 0 0 48px;
}

.action-btn.hint:hover:not(:disabled) {
    background: rgba(51,204,102,0.2);
}

.action-btn.pass {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    flex: 0 0 64px;
}

.action-btn.pass:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
}

/* ===== GAME OVER OVERLAY ===== */
.game-over-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
    animation: fadeIn 0.4s ease;
}

.game-over-overlay.visible {
    display: flex;
}

.game-over-card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 40px 32px;
    max-width: 360px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.08);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-over-title {
    font-size: 32px;
    font-weight: 900;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.game-over-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.game-over-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
}

.stat-box {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 14px;
}

.stat-value {
    font-size: 24px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
}

.game-over-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.game-over-btn {
    padding: 14px;
    border-radius: 14px;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.game-over-btn:active {
    transform: scale(0.97);
}

.game-over-btn.primary {
    background: linear-gradient(135deg, var(--forge-blue), #2266dd);
    color: white;
}

.game-over-btn.secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
}

/* ===== HOW TO PLAY ===== */
#howto-screen {
    background: var(--bg-primary);
    padding: 0;
}

.howto-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
}

.howto-title {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

.howto-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    padding-bottom: 40px;
}

.howto-section {
    margin-bottom: 28px;
}

.howto-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.howto-section p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 8px;
}

.howto-section .highlight {
    color: var(--forge-blue);
    font-weight: 600;
}

.howto-key {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.08);
    margin: 2px;
}

/* ===== PAUSE OVERLAY ===== */
.pause-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 90;
    backdrop-filter: blur(4px);
}

.pause-overlay.visible {
    display: flex;
}

.pause-text {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 8px;
    text-transform: uppercase;
    color: var(--text-primary);
    cursor: pointer;
}

.pause-hint {
    position: absolute;
    bottom: 30%;
    font-size: 14px;
    color: var(--text-muted);
}

/* ===== LOADING ===== */
#loading-screen {
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.loading-title {
    font-size: 36px;
    font-weight: 900;
    letter-spacing: 4px;
    background: linear-gradient(135deg, var(--forge-blue), var(--forge-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.loading-bar-track {
    width: 200px;
    height: 4px;
    background: var(--bg-card);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar-fill {
    height: 100%;
    background: var(--forge-blue);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
    animation: loadingPulse 1.5s ease-in-out infinite;
}

@keyframes loadingPulse {
    0% { width: 10%; }
    50% { width: 80%; }
    100% { width: 10%; }
}

.loading-text {
    font-size: 13px;
    color: var(--text-muted);
}

/* ===== FLOATING PARTICLES BACKGROUND ===== */
.bg-particles {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(51,128,255,0.08);
    animation: floatParticle linear infinite;
}

@keyframes floatParticle {
    0% { transform: translateY(100vh) translateX(0); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateY(-20vh) translateX(30px); opacity: 0; }
}

/* ===== INTRO ANIMATION ===== */
.intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
    z-index: 80;
    backdrop-filter: blur(4px);
}

.intro-overlay.visible {
    display: flex;
}

.intro-title {
    font-size: 42px;
    font-weight: 900;
    letter-spacing: 4px;
    opacity: 0;
    transform: scale(0.8);
    animation: introFade 0.5s 0.2s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

.intro-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    opacity: 0;
    animation: introFade 0.4s 0.6s forwards;
}

.intro-go {
    font-size: 64px;
    font-weight: 900;
    opacity: 0;
    transform: scale(2);
    animation: introGo 0.3s 1.2s forwards cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes introFade {
    to { opacity: 1; transform: scale(1); }
}

@keyframes introGo {
    to { opacity: 1; transform: scale(1); }
}

/* ===== FORGE FLASH ===== */
.forge-flash {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 70;
    background: radial-gradient(circle at center, rgba(255,255,255,0.15), transparent 70%);
    opacity: 0;
    transition: opacity 0.15s ease-out;
}

.forge-flash.active {
    opacity: 1;
}

/* ===== ONLINE MATCH ===== */
.mode-card.online-match { border-left: 3px solid var(--forge-purple); }
.mode-card.online-match .mode-card-title { color: var(--forge-purple); }

#online-screen {
    background: var(--bg-primary);
    padding: 0;
}

.online-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid rgba(255,255,255,0.04);
    flex-shrink: 0;
}

.online-title {
    font-size: 18px;
    font-weight: 700;
    flex: 1;
    text-align: center;
}

.online-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.online-phase {
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    max-width: 400px;
}

.online-phase.active {
    display: flex;
}

.online-subtitle {
    font-size: 22px;
    font-weight: 700;
    margin-top: 20px;
}

.online-desc {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.5;
}

.online-role-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-top: 16px;
}

.online-role-card {
    background: var(--bg-card);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    padding: 20px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.online-role-card:hover {
    background: var(--bg-hover);
    transform: translateY(-2px);
    border-color: rgba(255,255,255,0.12);
}

.online-role-card:active {
    transform: scale(0.98);
}

.role-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.role-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.role-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

.online-step {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
}

.room-code-display {
    font-size: 48px;
    font-weight: 900;
    letter-spacing: 12px;
    color: var(--forge-purple);
    background: var(--bg-surface);
    padding: 20px 32px;
    border-radius: 16px;
    border: 2px solid rgba(153,51,230,0.3);
    text-align: center;
    font-family: monospace;
    user-select: all;
    -webkit-user-select: all;
}

.room-code-input {
    width: 100%;
    max-width: 280px;
    padding: 16px 24px;
    border-radius: 16px;
    border: 2px solid rgba(255,255,255,0.1);
    background: var(--bg-surface);
    color: var(--text-primary);
    font-family: monospace;
    font-size: 36px;
    font-weight: 800;
    text-align: center;
    letter-spacing: 8px;
    text-transform: uppercase;
}

.room-code-input:focus {
    outline: none;
    border-color: var(--forge-purple);
}

.room-code-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
    letter-spacing: 4px;
    font-size: 24px;
}

.online-error {
    font-size: 13px;
    color: var(--invalid-red);
    min-height: 20px;
    text-align: center;
}

.online-btn {
    padding: 12px 24px;
    border-radius: 14px;
    border: none;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    width: 100%;
}

.online-btn:active {
    transform: scale(0.97);
}

.online-btn.primary {
    background: linear-gradient(135deg, var(--forge-purple), #7722bb);
    color: white;
    box-shadow: 0 4px 16px rgba(153,51,230,0.3);
}

.online-btn.primary:hover {
    box-shadow: 0 6px 24px rgba(153,51,230,0.4);
    transform: translateY(-1px);
}

.online-divider {
    width: 100%;
    height: 1px;
    background: rgba(255,255,255,0.06);
    margin: 8px 0;
}

.online-status {
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

.online-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--forge-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 20px 0;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Opponent waiting overlay */
.opponent-waiting-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,0,0,0.7);
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--forge-purple);
    display: none;
    backdrop-filter: blur(4px);
    z-index: 50;
    align-items: center;
    gap: 10px;
}

.opponent-waiting-overlay.visible {
    display: flex;
}

.opponent-waiting-overlay .thinking-dots span {
    background: var(--forge-purple);
}

/* Opponent disconnected overlay */
.opponent-disconnected-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.opponent-disconnected-overlay.visible {
    display: flex;
}

.disconnect-card {
    background: var(--bg-card);
    border-radius: 24px;
    padding: 40px 32px;
    max-width: 340px;
    width: 90%;
    text-align: center;
    border: 1px solid rgba(255,255,255,0.08);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.disconnect-title {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--invalid-red);
}

.disconnect-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ===== LOBBY ===== */

.lobby-title {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 24px;
}

.lobby-player-list {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 24px;
}

.lobby-player-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 14px;
    border: 1px solid rgba(255,255,255,0.06);
}

.lobby-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.lobby-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.lobby-slot {
    font-size: 12px;
    color: var(--text-secondary);
}

.lobby-wait-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.lobby-wait-text .online-spinner {
    width: 24px;
    height: 24px;
    margin: 0;
}

.online-spinner.small {
    width: 24px;
    height: 24px;
    border-width: 2px;
    margin: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .home-title { font-size: 40px; letter-spacing: 2px; }
    .mode-card { padding: 16px 18px; }
    .mode-card-title { font-size: 18px; }
    .action-btn { padding: 10px; font-size: 12px; }
    .word-text { font-size: 18px; }
}

@media (min-width: 768px) {
    .board-container {
        padding: 16px;
    }
    .hex-board {
        max-width: 520px;
    }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar {
    width: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
}

/* ===== SCORE FLYOUT ===== */
.score-flyout {
    position: absolute;
    pointer-events: none;
    font-size: 18px;
    font-weight: 800;
    color: var(--valid-green);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    animation: scoreFly 1.5s ease-out forwards;
    z-index: 60;
}

@keyframes scoreFly {
    0% { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(-60px) scale(1.2); }
}
