:root {
    --bg-primary: #12151c;
    --bg-secondary: #1a1e28;
    --bg-card: rgba(26, 30, 42, 0.75);
    --bg-glass: rgba(30, 36, 52, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-highlight: rgba(212, 175, 55, 0.3);
    
    --gold: #d4af37;
    --gold-glow: rgba(212, 175, 55, 0.4);
    --gold-light: #f3e5ab;
    --wood-amber: #c88a38;
    
    --text-primary: #f0f3f8;
    --text-secondary: #9aa2b4;
    --text-muted: #5e6677;
    
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --accent-red: #ef4444;
    
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    
    --shadow-main: 0 16px 36px rgba(0, 0, 0, 0.4);
    --shadow-wood: 0 25px 60px -15px rgba(0, 0, 0, 0.7), 0 0 40px rgba(184, 115, 51, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Noto Serif SC', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 50% 0%, rgba(45, 55, 75, 0.35) 0%, transparent 60%),
        radial-gradient(circle at 10% 90%, rgba(212, 175, 55, 0.04) 0%, transparent 40%),
        radial-gradient(circle at 90% 90%, rgba(59, 130, 246, 0.04) 0%, transparent 40%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* Header Navigation */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 28px;
    background: rgba(18, 21, 28, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2c2518 0%, #15120c 100%);
    border: 1px solid var(--gold);
    color: var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
    font-family: 'Noto Serif SC', serif;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.2);
}

.logo-text h1 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 1px;
    background: linear-gradient(90deg, #ffffff, var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text .sub-text {
    font-size: 0.65rem;
    letter-spacing: 2px;
    color: var(--text-muted);
    font-family: 'Cinzel', serif;
    display: block;
}

/* Room Pill */
.room-pill {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-glass);
    border: 1px solid var(--border-highlight);
    padding: 6px 14px;
    border-radius: 40px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.room-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.room-code {
    font-family: 'Cinzel', monospace;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 2px;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.35);
    color: var(--gold-light);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
    background: rgba(212, 175, 55, 0.28);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.25);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.icon-circle-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.icon-circle-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 290px 1fr 320px;
    gap: 24px;
    padding: 24px;
    max-width: 1620px;
    margin: 0 auto;
    width: 100%;
    align-items: start;
}

/* Player Sidebars */
.player-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.player-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
}

.player-card.active-turn {
    border-color: var(--gold);
    box-shadow: 0 0 25px rgba(212, 175, 55, 0.3), inset 0 0 15px rgba(212, 175, 55, 0.08);
}

.player-card.active-turn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    animation: scanline 2s infinite linear;
}

@keyframes scanline {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.stone-indicator {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    position: absolute;
    top: 14px;
    left: 14px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.black-stone-icon {
    background: radial-gradient(circle at 35% 30%, #4a4a4a 0%, #151515 70%, #000000 100%);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.white-stone-icon {
    background: radial-gradient(circle at 35% 30%, #ffffff 0%, #e0e5ea 60%, #b8c1ca 100%);
    border: 1px solid rgba(0, 0, 0, 0.15);
}

.player-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    position: relative;
    margin-top: 6px;
}

.online-indicator {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #64748b;
    border: 2px solid var(--bg-primary);
    position: absolute;
    bottom: 2px;
    right: 2px;
    transition: background 0.3s;
}

.online-indicator.online {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
}

.player-meta {
    width: 100%;
}

.player-name-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.player-name {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.role-badge {
    font-size: 0.72rem;
    padding: 2px 10px;
    border-radius: 12px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.black-badge {
    background: rgba(0, 0, 0, 0.5);
    color: #e2e8f0;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.white-badge {
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.ready-badge {
    margin-top: 8px;
    display: inline-block;
    font-size: 0.8rem;
    padding: 3px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    transition: all 0.3s;
}

.ready-badge.is-ready {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.4);
}

/* Timer Display */
.timer-box {
    margin-top: 4px;
}

.timer-circle-wrapper {
    position: relative;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.timer-svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.timer-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.06);
    stroke-width: 3.5;
}

.timer-progress {
    fill: none;
    stroke: var(--accent-green);
    stroke-width: 3.5;
    stroke-linecap: round;
    stroke-dasharray: 100.53;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 0.8s linear, stroke 0.3s;
}

.timer-progress.warning {
    stroke: #f59e0b;
}

.timer-progress.danger {
    stroke: var(--accent-red);
}

.timer-val {
    position: absolute;
    font-family: 'Cinzel', monospace;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-primary);
}

/* Game Meta Panel */
.game-meta-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meta-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
}

.meta-label {
    color: var(--text-secondary);
}

.meta-val {
    font-weight: 600;
    color: var(--text-primary);
}

.meta-val.highlight {
    color: var(--gold);
}

/* Center Board Area */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 100%;
}

.board-table-shadow {
    position: relative;
    padding: 10px;
    border-radius: 18px;
    background: radial-gradient(circle, rgba(193, 140, 68, 0.15) 0%, rgba(0, 0, 0, 0.4) 100%);
    box-shadow: var(--shadow-wood);
}

/* The Board Frame (Rosewood Chamfer Border) */
.board-frame {
    position: relative;
    width: 720px;
    height: 720px;
    border-radius: 14px;
    overflow: hidden;
    background: #683818;
    box-shadow: 
        inset 0 0 12px rgba(0,0,0,0.6),
        0 6px 20px rgba(0,0,0,0.5);
    border: 7px solid #4a250e;
}

#board-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: pointer;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Countdown Overlay */
.countdown-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 12, 18, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 50;
    animation: fadeIn 0.3s ease;
}

.countdown-num {
    font-family: 'Cinzel', serif;
    font-size: 6rem;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 30px var(--gold-glow);
    animation: popBounce 1s infinite;
}

.countdown-tip {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-top: 10px;
    letter-spacing: 1px;
}

@keyframes popBounce {
    0% { transform: scale(0.6); opacity: 0; }
    50% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Result Banner */
.result-banner {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 22, 0.88);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 60;
    animation: fadeIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.banner-content {
    background: linear-gradient(135deg, rgba(30, 36, 52, 0.95), rgba(20, 24, 36, 0.95));
    border: 1px solid var(--gold);
    box-shadow: 0 20px 50px rgba(0,0,0,0.7), 0 0 30px rgba(212, 175, 55, 0.3);
    border-radius: var(--radius-lg);
    padding: 36px 48px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.result-title {
    font-size: 2.2rem;
    font-weight: 900;
    font-family: 'Noto Serif SC', serif;
    background: linear-gradient(90deg, #fff, var(--gold-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.result-desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 24px;
}

/* Board Controls */
.board-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    width: 100%;
}

.action-btn {
    border: none;
    outline: none;
    padding: 12px 28px;
    border-radius: 40px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
    overflow: hidden;
}

.ready-btn {
    background: linear-gradient(135deg, #d4af37 0%, #aa820a 100%);
    color: #121008;
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.35);
    min-width: 180px;
}

.ready-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(212, 175, 55, 0.5);
}

.ready-btn.ready-active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #ffffff;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transform: skewX(-20deg);
    animation: shineEffect 4s infinite ease-in-out;
}

@keyframes shineEffect {
    0% { left: -100%; }
    20% { left: 200%; }
    100% { left: 200%; }
}

.playing-actions {
    display: flex;
    gap: 12px;
}

.secondary-btn {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.primary-btn {
    background: linear-gradient(135deg, var(--gold) 0%, #b8860b 100%);
    border: none;
    color: #121008;
    padding: 12px 24px;
    border-radius: 30px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
    transition: all 0.2s;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(212, 175, 55, 0.45);
}

.danger-btn {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.danger-btn:hover {
    background: rgba(239, 68, 68, 0.25);
    border-color: rgba(239, 68, 68, 0.6);
}

.spectator-msg {
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 8px 20px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

/* Chat & Interactive Panel */
.chat-container {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 480px;
    overflow: hidden;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 0.95rem;
}

.chat-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.chat-item {
    font-size: 0.85rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-item.system-msg {
    color: var(--text-muted);
    font-size: 0.78rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 10px;
    border-radius: 8px;
}

.chat-sender {
    font-weight: 600;
    margin-right: 6px;
}

.chat-sender.black {
    color: #93c5fd;
}

.chat-sender.white {
    color: #fde047;
}

.chat-sender.spectator {
    color: #a78bfa;
}

.quick-phrases {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    background: rgba(0, 0, 0, 0.15);
    border-top: 1px solid var(--border-color);
}

.quick-chip {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.quick-chip:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text-primary);
}

.chat-input-form {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-top: 1px solid var(--border-color);
}

.chat-input-form input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 8px 14px;
    color: var(--text-primary);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input-form input:focus {
    border-color: var(--gold);
}

.send-btn {
    background: var(--gold);
    color: #121008;
    border: none;
    border-radius: 20px;
    padding: 0 16px;
    font-weight: 700;
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s;
}

.send-btn:hover {
    background: var(--gold-light);
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(8, 10, 16, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
    animation: fadeIn 0.25s ease;
}

.modal-card {
    background: linear-gradient(135deg, rgba(28, 34, 48, 0.98), rgba(18, 22, 32, 0.98));
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-xl);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-main), 0 0 40px rgba(212, 175, 55, 0.15);
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header h2, .modal-header h3 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    margin-bottom: 6px;
    font-family: 'Noto Serif SC', serif;
}

.modal-subtitle {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.lobby-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: left;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.input-group input {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.input-group input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.2);
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.78rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.divider span {
    padding: 0 10px;
}

.join-row {
    display: flex;
    gap: 10px;
}

.join-row input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 10px 14px;
    color: var(--gold);
    font-family: 'Cinzel', monospace;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-align: center;
    text-transform: uppercase;
    outline: none;
}

.join-row input:focus {
    border-color: var(--gold);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.rules-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin: 20px 0;
}

.rules-body strong {
    color: var(--text-primary);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 300;
    pointer-events: none;
}

.toast {
    background: rgba(22, 27, 38, 0.95);
    border: 1px solid var(--border-highlight);
    color: var(--text-primary);
    padding: 10px 22px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 600;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    gap: 8px;
    animation: toastPop 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes toastPop {
    0% { transform: translateY(20px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
}

.pulse-glow {
    animation: pulseButton 2s infinite ease-in-out;
}

@keyframes pulseButton {
    0%, 100% { box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3); }
    50% { box-shadow: 0 6px 28px rgba(212, 175, 55, 0.65); }
}

/* Hidden Utility */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Invite Banner in Modal */
.invite-banner {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: rgba(212, 175, 55, 0.08);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.invite-tip {
    font-size: 0.95rem;
    color: var(--text-primary);
}

.highlight-code {
    font-family: 'Cinzel', monospace;
    font-size: 1.25rem;
    color: var(--gold);
    letter-spacing: 2px;
}

.full-width {
    width: 100%;
    justify-content: center;
}

/* Responsive Breakpoints */
@media (max-width: 1440px) {
    .board-frame {
        width: 640px;
        height: 640px;
    }
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 250px 1fr 270px;
        gap: 16px;
        padding: 16px;
    }
    .board-frame {
        width: 560px;
        height: 560px;
    }
}

@media (max-width: 900px) {
    .top-nav {
        padding: 8px 14px;
    }
    .logo-text h1 {
        font-size: 1rem;
    }
    .logo-text .sub-text {
        display: none;
    }
    .room-pill {
        padding: 4px 10px;
        gap: 6px;
    }
    .room-code {
        font-size: 0.95rem;
    }
    .icon-btn .btn-text {
        display: none;
    }
    .icon-btn {
        padding: 4px 8px;
    }

    .main-content {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 8px;
        gap: 8px;
        width: 100%;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .player-sidebar {
        width: 100%;
        max-width: min(96vw, 520px);
        gap: 6px;
    }

    .player-black-side {
        order: 1;
    }

    .board-wrapper {
        order: 2;
        width: 100%;
        gap: 10px;
    }

    .board-table-shadow {
        padding: 4px;
        border-radius: 12px;
    }

    .board-frame {
        width: min(96vw, calc(100vh - 240px), 520px);
        height: min(96vw, calc(100vh - 240px), 520px);
        border-width: 4px;
        border-radius: 8px;
    }

    .player-white-side {
        order: 3;
    }

    .player-card {
        flex-direction: row;
        padding: 6px 12px;
        gap: 10px;
        border-radius: 12px;
        width: 100%;
    }

    .stone-indicator {
        position: static;
        width: 22px;
        height: 22px;
        flex-shrink: 0;
    }

    .player-avatar {
        width: 36px;
        height: 36px;
        font-size: 18px;
        margin-top: 0;
        flex-shrink: 0;
    }

    .online-indicator {
        width: 10px;
        height: 10px;
    }

    .player-meta {
        flex: 1;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }

    .player-name-row {
        align-items: flex-start;
        gap: 2px;
    }

    .player-name {
        font-size: 0.9rem;
        max-width: 110px;
    }

    .role-badge {
        font-size: 0.65rem;
        padding: 1px 6px;
    }

    .ready-badge {
        margin-top: 0;
        font-size: 0.72rem;
        padding: 2px 8px;
    }

    .timer-box {
        margin-top: 0;
    }

    .timer-circle-wrapper {
        width: 36px;
        height: 36px;
    }

    .timer-val {
        font-size: 0.85rem;
    }

    .board-controls {
        gap: 8px;
        flex-wrap: wrap;
    }

    .action-btn {
        padding: 8px 16px;
        font-size: 0.88rem;
    }

    .ready-btn {
        min-width: 140px;
        padding: 9px 20px;
    }

    .game-meta-panel {
        display: none;
    }

    .chat-container {
        order: 4;
        width: 100%;
        max-width: min(96vw, 520px);
        height: 140px;
        border-radius: var(--radius-md);
    }

    .chat-header {
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .chat-messages {
        padding: 8px 12px;
        gap: 6px;
    }

    .quick-phrases {
        padding: 6px 10px;
        gap: 4px;
    }

    .quick-chip {
        padding: 2px 8px;
        font-size: 0.7rem;
    }

    .chat-input-form {
        padding: 6px 10px;
    }

    .chat-input-form input {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .modal-card {
        padding: 22px 18px;
    }

    .modal-header h2 {
        font-size: 1.25rem;
    }

    .modal-subtitle {
        font-size: 0.8rem;
        margin-bottom: 16px;
    }
}

/* ==========================================================
   BGM, Scoreboard, Rematch & Share QR Code Enhancements
   ========================================================== */

/* BGM Nav Button */
#bgm-btn.active {
    background: rgba(212, 175, 55, 0.25);
    border-color: var(--gold);
    box-shadow: 0 0 12px rgba(212, 175, 55, 0.4);
}

#bgm-btn.active #bgm-icon {
    display: inline-block;
    animation: pulseBgm 2s infinite ease-in-out;
}

@keyframes pulseBgm {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.18); filter: drop-shadow(0 0 6px var(--gold)); }
}

/* Player Card Score Badges */
.badge-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    flex-wrap: wrap;
    justify-content: center;
}

.player-score-tag {
    font-size: 0.72rem;
    padding: 1px 8px;
    border-radius: 12px;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid rgba(212, 175, 55, 0.4);
    color: var(--gold-light);
    font-weight: 700;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Result Scoreboard Box */
.result-score-box {
    background: rgba(18, 22, 32, 0.8);
    border: 1px solid var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 14px 18px;
    margin: 14px 0 18px;
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.4);
}

.score-box-title {
    font-size: 0.78rem;
    color: var(--gold);
    letter-spacing: 2px;
    font-weight: 700;
}

.score-box-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 22px;
    margin: 8px 0;
}

.score-side {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-side-label {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.score-side-num {
    font-family: 'Cinzel', monospace;
    font-size: 2rem;
    font-weight: 900;
    color: var(--gold-light);
    text-shadow: 0 2px 10px rgba(212, 175, 55, 0.4);
    line-height: 1.1;
}

.score-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.score-vs-divider {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-muted);
}

.banner-round-info {
    font-size: 0.76rem;
    color: var(--text-secondary);
}

.banner-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.rematch-status-tip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 0.84rem;
    color: var(--gold-light);
    background: rgba(212, 175, 55, 0.12);
    border: 1px solid rgba(212, 175, 55, 0.35);
    border-radius: 20px;
    padding: 6px 14px;
    animation: fadeIn 0.3s;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: blink 1.2s infinite ease-in-out;
}

@keyframes blink {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* Share & QR Code Modal */
.share-card {
    max-width: 440px;
}

.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    margin-bottom: 16px;
}

.qrcode-wrapper {
    width: 170px;
    height: 170px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qrcode-wrapper svg {
    width: 100%;
    height: 100%;
    display: block;
}

.qr-hint {
    font-size: 0.76rem;
    color: #4b5563;
    margin-top: 8px;
    font-weight: 600;
}

.share-code-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: var(--bg-glass);
    border: 1px solid var(--border-highlight);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
}

.code-box {
    display: flex;
    flex-direction: column;
}

.code-label {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.code-val {
    font-family: 'Cinzel', monospace;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--gold);
    letter-spacing: 3px;
}

.share-link-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.share-link-row input {
    flex: 1;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    outline: none;
    font-family: monospace;
}

.copy-link-btn {
    white-space: nowrap;
    font-size: 0.8rem;
    padding: 8px 14px;
    border-radius: var(--radius-sm);
}

.native-btn {
    background: linear-gradient(135deg, #07c160 0%, #059648 100%);
    color: #ffffff;
    font-size: 0.9rem;
    padding: 10px 18px;
    box-shadow: 0 4px 15px rgba(7, 193, 96, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.native-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(7, 193, 96, 0.5);
}

