/* ============================================
   Chess Arena — AI vs AI
   Elegant Dark Wood Theme — Mobile First
   ============================================ */

/* === CSS Variables (Design System) === */
:root {
    /* Color Palette — Elegant Dark Wood */
    --color-bg-primary: #1a120b;
    --color-bg-secondary: #2c1e12;
    --color-bg-card: #3c2a1a;
    --color-bg-card-hover: #4a3522;
    --color-surface: #2a1d10;

    --color-text-primary: #f5e6d3;
    --color-text-secondary: #c4a882;
    --color-text-muted: #8a7460;

    --color-accent-gold: #d4a843;
    --color-accent-gold-glow: rgba(212, 168, 67, 0.3);
    --color-accent-amber: #e8a435;

    --color-board-light: #d4a05a;
    --color-board-dark: #8b5e3c;
    --color-board-highlight: rgba(212, 168, 67, 0.45);
    --color-board-check: rgba(220, 38, 38, 0.55);

    --color-white-piece: #fff8e7;
    --color-black-piece: #2c1810;

    --color-success: #4ade80;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;

    --color-border: rgba(212, 168, 67, 0.15);
    --color-border-active: rgba(212, 168, 67, 0.4);

    /* Typography */
    --font-heading: 'Playfair Display', Georgia, serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;

    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;

    /* Board — mobile first */
    --board-size: min(88vw, 420px);
    --square-size: calc(var(--board-size) / 8);

    /* Borders & Radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Shadows */
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-elevated: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow-gold: 0 0 20px rgba(212, 168, 67, 0.2);
    --shadow-board: 0 8px 40px rgba(0, 0, 0, 0.7), inset 0 0 60px rgba(212, 168, 67, 0.05);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 300ms ease;
    --transition-slow: 500ms ease;
}

/* === Reset & Base === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Ensure HTML hidden attribute always works */
[hidden] {
    display: none !important;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-body);
    background: var(--color-bg-primary);
    color: var(--color-text-primary);
    min-height: 100vh;
    line-height: 1.5;
    overflow-x: hidden;
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(60, 42, 26, 0.5) 0%, transparent 70%),
        radial-gradient(ellipse at 80% 50%, rgba(60, 42, 26, 0.3) 0%, transparent 70%);
}

/* === Screen Management === */
.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.5s ease;
}

/* ============================================
   SETUP SCREEN
   ============================================ */
.setup-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding: var(--space-lg);
    gap: var(--space-lg);
    min-height: 100vh;
}

/* Header / Logo */
.setup-header {
    text-align: center;
    margin-bottom: var(--space-md);
}

.setup-header h1 {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-accent-gold) 0%, var(--color-accent-amber) 50%, var(--color-accent-gold) 100%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 3s ease-in-out infinite;
    text-shadow: none;
    letter-spacing: 0.02em;
}

.subtitle {
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--color-text-muted);
    margin-top: var(--space-sm);
    font-weight: 300;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* Cards */
.setup-card {
    width: 100%;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    box-shadow: var(--shadow-card);
    transition: border-color var(--transition-normal);
}

.setup-card:focus-within {
    border-color: var(--color-border-active);
    box-shadow: var(--shadow-card), var(--shadow-glow-gold);
}

/* Input Labels */
.input-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.03em;
}

/* Input Group (input + button) */
.input-group {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
}

.input-group input {
    flex: 1;
}

/* Text Inputs */
input[type="text"],
input[type="password"],
input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 0.95rem;
    color: var(--color-text-primary);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    border-color: var(--color-accent-gold);
    box-shadow: 0 0 0 3px var(--color-accent-gold-glow);
}

input::placeholder {
    color: var(--color-text-muted);
    font-weight: 300;
}

/* Input Hint */
.input-hint {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-sm);
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

/* Icon Button */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 1.1rem;
    transition: background var(--transition-fast), border-color var(--transition-fast);
    flex-shrink: 0;
}

.icon-btn:hover {
    background: var(--color-bg-card-hover);
    border-color: var(--color-border-active);
}

/* Link Button */
.link-btn {
    background: none;
    border: none;
    color: var(--color-accent-gold);
    cursor: pointer;
    font-size: 0.78rem;
    font-family: var(--font-body);
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition-fast);
}

.link-btn:hover {
    color: var(--color-accent-amber);
}

/* Model Selection Row */
.model-input-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    align-items: center;
}

.model-input-group {
    width: 100%;
}

.versus-divider {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent-gold);
    text-shadow: 0 0 20px var(--color-accent-gold-glow);
    letter-spacing: 0.15em;
}

/* Primary Button */
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 14px 28px;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-bg-primary);
    background: linear-gradient(135deg, var(--color-accent-gold), var(--color-accent-amber));
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-normal), opacity var(--transition-fast);
    box-shadow: 0 4px 16px rgba(212, 168, 67, 0.3);
    letter-spacing: 0.03em;
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(212, 168, 67, 0.45);
}

.primary-btn:active:not(:disabled) {
    transform: translateY(0);
}

.primary-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--color-text-muted);
    box-shadow: none;
}

/* Secondary Button */
.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    width: 100%;
    padding: 12px 24px;
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 500;
    color: var(--color-accent-gold);
    background: transparent;
    border: 1px solid var(--color-accent-gold);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.secondary-btn:hover {
    background: rgba(212, 168, 67, 0.1);
    transform: translateY(-1px);
}

/* Error Text */
.error-text {
    color: var(--color-danger);
    font-size: 0.85rem;
    text-align: center;
    animation: shake 0.4s ease;
}

/* ============================================
   GAME SCREEN
   ============================================ */
#screen-game {
    flex-direction: column;
    align-items: center;
    padding: var(--space-md);
    padding-bottom: var(--space-2xl);
    min-height: 100vh;
}

/* Game Layout — mobile: stacked column */
.game-layout {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    max-width: 1200px;
}

/* AI Panels */
.ai-panel {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-md);
    width: 100%;
    max-width: 500px;
    padding: var(--space-md);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    flex-wrap: wrap;
}

.ai-panel-black {
    order: 1;
    border-top: 3px solid #555;
}

.board-container {
    order: 2;
}

.ai-panel-white {
    order: 3;
    border-top: 3px solid var(--color-accent-gold);
}

.ai-avatar {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.ai-panel-white .ai-avatar {
    background: linear-gradient(135deg, #f5e6c8, #e8d4a2);
    color: #5a3e1b;
    box-shadow: 0 0 0 2px #d4a843, 0 2px 8px rgba(212, 168, 67, 0.25);
}

.ai-panel-black .ai-avatar {
    background: linear-gradient(135deg, #3a3a3a, #1a1a1a);
    color: #c0c0c0;
    box-shadow: 0 0 0 2px #555, 0 2px 8px rgba(0, 0, 0, 0.4);
}

.ai-name {
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
}

.ai-model-slug {
    font-family: var(--font-body);
    font-size: 0.65rem;
    font-weight: 400;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 160px;
    opacity: 0.7;
}

.ai-status {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.ai-status.thinking {
    color: var(--color-accent-gold);
    animation: pulse 1.5s ease-in-out infinite;
}

.ai-status.error {
    color: var(--color-danger);
}

/* Captured Pieces */
.captured-pieces {
    width: 100%;
    min-height: 24px;
    font-size: 1.1rem;
    letter-spacing: 2px;
    color: var(--color-text-secondary);
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    order: 10;
}

/* Chat Bubbles */
.chat-bubbles {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 150px;
    overflow-y: auto;
    order: 11;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.chat-bubble {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    line-height: 1.4;
    animation: slideInBubble 0.3s ease;
    max-width: 100%;
    word-wrap: break-word;
}

.chat-bubble.white-bubble {
    background: rgba(255, 248, 231, 0.1);
    border: 1px solid rgba(255, 248, 231, 0.15);
    color: var(--color-text-primary);
    align-self: flex-end;
}

.chat-bubble.black-bubble {
    background: rgba(44, 24, 16, 0.6);
    border: 1px solid rgba(139, 94, 60, 0.2);
    color: var(--color-text-primary);
    align-self: flex-start;
}

.chat-bubble.event {
    font-weight: 600;
    color: var(--color-accent-gold);
    background: rgba(212, 168, 67, 0.12);
    border-color: rgba(212, 168, 67, 0.3);
    text-align: center;
    align-self: center;
}

.chat-bubble .bubble-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--color-text-muted);
    display: block;
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.chat-bubble .bubble-move {
    font-weight: 600;
    color: var(--color-accent-amber);
}

/* ============================================
   CHESS BOARD
   ============================================ */
.board-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.board-with-ranks {
    display: flex;
    align-items: center;
    gap: 0;
}

/* File/Rank Labels */
.board-label-top,
.board-label-bottom {
    display: grid;
    grid-template-columns: repeat(8, var(--square-size));
    width: var(--board-size);
    margin-left: 20px;
}

.board-label-top span,
.board-label-bottom span {
    text-align: center;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-weight: 500;
    user-select: none;
}

.board-label-left,
.board-label-right {
    display: flex;
    flex-direction: column;
    width: 20px;
}

.board-label-left span,
.board-label-right span {
    height: var(--square-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-weight: 500;
    user-select: none;
}

/* The Board */
.chess-board {
    display: grid;
    grid-template-columns: repeat(8, var(--square-size));
    grid-template-rows: repeat(8, var(--square-size));
    border: 3px solid var(--color-bg-card);
    border-radius: 4px;
    box-shadow: var(--shadow-board);
    overflow: hidden;
    position: relative;
}

/* Squares */
.square {
    width: var(--square-size);
    height: var(--square-size);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
    transition: background-color var(--transition-fast);
}

.square.light {
    background-color: var(--color-board-light);
}

.square.dark {
    background-color: var(--color-board-dark);
}

.square.highlight {
    background-color: var(--color-board-highlight) !important;
}

.square.highlight.light {
    background-color: rgba(212, 178, 80, 0.7) !important;
}

.square.highlight.dark {
    background-color: rgba(170, 140, 50, 0.7) !important;
}

.square.check {
    animation: checkPulse 1s ease-in-out infinite;
}

.square.check::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-board-check);
    border-radius: 50%;
    animation: checkGlow 1s ease-in-out infinite;
    pointer-events: none;
}

/* Chess Pieces */
.piece {
    font-size: calc(var(--square-size) * 0.72);
    line-height: 1;
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    z-index: 1;
    pointer-events: none;
    filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.4));
}

.piece.white-piece {
    color: var(--color-white-piece);
    filter: drop-shadow(1px 2px 3px rgba(0, 0, 0, 0.5));
}

.piece.black-piece {
    color: var(--color-black-piece);
    filter: drop-shadow(1px 1px 2px rgba(0, 0, 0, 0.3));
    -webkit-text-stroke: 0.5px rgba(139, 94, 60, 0.3);
}

.piece.moving {
    z-index: 10;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Turn Indicator */
.turn-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    margin-top: var(--space-md);
    padding: 8px 20px;
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--color-text-secondary);
    box-shadow: var(--shadow-card);
}

.turn-indicator.active-white {
    border-color: rgba(255, 248, 231, 0.3);
    box-shadow: var(--shadow-card), 0 0 15px rgba(255, 248, 231, 0.1);
}

.turn-indicator.active-black {
    border-color: rgba(139, 94, 60, 0.4);
    box-shadow: var(--shadow-card), 0 0 15px rgba(139, 94, 60, 0.15);
}

/* Thinking Dots */
.thinking-dots {
    display: inline-flex;
    gap: 3px;
}

.thinking-dots span {
    display: inline-block;
    animation: dotBounce 1.4s ease-in-out infinite;
    color: var(--color-accent-gold);
    font-weight: 700;
    font-size: 1.2em;
}

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

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

/* Countdown */
.countdown-text {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: var(--space-xs);
}

/* ============================================
   MOVE HISTORY PANEL
   ============================================ */
.move-history-panel {
    width: 100%;
    max-width: 600px;
    margin-top: var(--space-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-md);
    box-shadow: var(--shadow-card);
}

.panel-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-accent-gold);
    margin-bottom: var(--space-sm);
    letter-spacing: 0.03em;
}

.move-history-scroll {
    max-height: 180px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border) transparent;
}

.move-row {
    display: flex;
    gap: var(--space-md);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    font-family: 'Courier New', monospace;
    transition: background var(--transition-fast);
}

.move-row:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.move-row:hover {
    background: rgba(212, 168, 67, 0.08);
}

.move-number {
    color: var(--color-text-muted);
    min-width: 30px;
    font-weight: 500;
}

.move-white {
    color: var(--color-white-piece);
    min-width: 65px;
    font-weight: 500;
}

.move-black {
    color: var(--color-text-secondary);
    min-width: 65px;
    font-weight: 500;
}

/* ============================================
   RULES PANEL
   ============================================ */
.rules-toggle-btn {
    padding: 8px 16px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: background var(--transition-fast), transform var(--transition-fast);
}

.rules-toggle-btn:hover {
    background: var(--color-bg-card-hover);
    transform: translateY(-2px);
}

.rules-panel {
    position: fixed;
    bottom: 60px;
    right: var(--space-md);
    width: 280px;
    padding: var(--space-lg);
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elevated);
    z-index: 50;
    animation: slideUp 0.3s ease;
}

.rules-panel h3 {
    font-family: var(--font-heading);
    font-size: 1rem;
    color: var(--color-accent-gold);
    margin-bottom: var(--space-md);
}

.rules-panel ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.rules-panel li {
    font-size: 0.8rem;
    color: var(--color-text-secondary);
    line-height: 1.4;
}

/* ============================================
   MODAL OVERLAY
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.3s ease;
    padding: var(--space-md);
}

.modal-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border-active);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl) var(--space-xl);
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: var(--shadow-elevated), var(--shadow-glow-gold);
    animation: slideUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-icon {
    font-size: 3.5rem;
    margin-bottom: var(--space-md);
    line-height: 1;
}

.modal-card h2 {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--color-accent-gold);
    margin-bottom: var(--space-sm);
}

.modal-card p {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    margin-bottom: var(--space-lg);
    line-height: 1.5;
}

.modal-stats {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--color-surface);
    border-radius: var(--radius-md);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-accent-gold);
}

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

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

/* ============================================
   GAME STATUS BAR (retry/error/countdown)
   ============================================ */
.game-status-bar {
    width: 100%;
    max-width: 600px;
    padding: 10px var(--space-md);
    margin-top: var(--space-sm);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    text-align: center;
    font-size: 0.82rem;
    color: var(--color-text-secondary);
    animation: fadeIn 0.3s ease;
}

.game-status-bar.error {
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--color-danger);
}

.game-status-bar.warning {
    border-color: rgba(245, 158, 11, 0.3);
    color: var(--color-warning);
}

.retry-btn {
    display: inline-block;
    margin-top: var(--space-sm);
    padding: 6px 16px;
    font-size: 0.8rem;
    color: var(--color-accent-gold);
    background: transparent;
    border: 1px solid var(--color-accent-gold);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--font-body);
    transition: background var(--transition-fast);
}

.retry-btn:hover {
    background: rgba(212, 168, 67, 0.15);
}

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

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

@keyframes slideInBubble {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes shimmer {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

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

@keyframes dotBounce {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-6px); }
}

@keyframes checkPulse {
    0%, 100% { box-shadow: inset 0 0 10px rgba(220, 38, 38, 0.3); }
    50% { box-shadow: inset 0 0 20px rgba(220, 38, 38, 0.5); }
}

@keyframes checkGlow {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 0.7; }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ============================================
   RESPONSIVE — TABLET (768px+)
   ============================================ */
@media (min-width: 768px) {
    :root {
        --board-size: min(50vw, 480px);
    }

    .game-layout {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        gap: var(--space-lg);
        align-items: start;
    }

    .ai-panel {
        flex-direction: column;
        align-items: flex-start;
        max-width: 220px;
        min-width: 180px;
    }

    .ai-panel-black {
        order: 1;
    }

    .board-container {
        order: 2;
    }

    .ai-panel-white {
        order: 3;
    }

    .chat-bubbles {
        max-height: 250px;
    }

    .model-input-row {
        flex-direction: row;
        align-items: flex-end;
    }

    .modal-actions {
        flex-direction: row;
    }

    .modal-actions .primary-btn,
    .modal-actions .secondary-btn {
        flex: 1;
    }
}

/* ============================================
   RESPONSIVE — DESKTOP (1024px+)
   ============================================ */
@media (min-width: 1024px) {
    :root {
        --board-size: min(45vw, 560px);
    }

    .ai-panel {
        max-width: 260px;
        min-width: 220px;
        padding: var(--space-lg);
    }

    .chat-bubbles {
        max-height: 350px;
    }

    .move-history-panel {
        max-width: 800px;
    }
}

/* ============================================
   SCROLLBAR STYLING
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-border-active);
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    width: 100%;
    margin-top: auto;
    padding: var(--space-2xl) var(--space-lg) var(--space-lg);
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.25) 100%);
    position: relative;
}

.footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
}

.footer-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.footer-logo {
    font-size: 1.3rem;
    line-height: 1;
    opacity: 0.6;
}

.footer-title {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--color-accent-gold), var(--color-accent-amber));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    opacity: 0.7;
}

.footer-divider {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--color-accent-gold), transparent);
    opacity: 0.3;
    margin: var(--space-xs) 0;
}

.footer-credit {
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--color-text-muted);
    letter-spacing: 0.02em;
}

.footer-credit strong {
    color: var(--color-text-secondary);
    font-weight: 600;
}

.footer-powered {
    font-family: var(--font-body);
    font-size: 0.72rem;
    color: var(--color-text-muted);
    opacity: 0.6;
    letter-spacing: 0.03em;
}

.footer-powered a {
    color: var(--color-accent-gold);
    text-decoration: none;
    transition: color var(--transition-fast), opacity var(--transition-fast);
    opacity: 0.8;
}

.footer-powered a:hover {
    color: var(--color-accent-amber);
    opacity: 1;
}

/* ============================================
   GAME CONTROLS & NEW MODALS
   ============================================ */

.floating-controls {
    position: fixed;
    bottom: var(--space-md);
    right: var(--space-md);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: var(--space-sm);
    z-index: 50;
}

.danger-btn {
    background: var(--color-bg-card);
    color: #ff6b6b;
    border: 1px solid rgba(220, 53, 69, 0.3);
    padding: 6px 14px;
    border-radius: var(--radius-xl);
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: var(--shadow-card);
    transition: all var(--transition-fast);
}

.danger-btn:hover {
    background: rgba(220, 53, 69, 0.25);
    border-color: rgba(220, 53, 69, 0.5);
    transform: translateY(-1px);
}

.trashtalk-container {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    margin-top: var(--space-md);
    text-align: left;
}

.trashtalk-box {
    background: var(--color-surface-light);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    position: relative;
    opacity: 0;
    transform: translateY(10px);
    transition: all var(--transition-normal);
}

.trashtalk-box.visible {
    opacity: 1;
    transform: translateY(0);
}

.loser-box {
    border-left: 3px solid #ff6b6b;
}

.winner-box {
    border-left: 3px solid var(--color-accent-gold);
}

.trashtalk-box h3 {
    font-family: var(--font-heading);
    font-size: 0.9rem;
    margin-bottom: var(--space-xs);
}

.loser-name { color: #ff6b6b; }
.winner-name { color: var(--color-accent-gold); }

.trashtalk-text {
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    line-height: 1.5;
    font-style: italic;
}
