/* ── Reversi — Deep Sea Sapphire ── */
:root {
    --rev-accent: #1E3A5F;
    --rev-accent-light: #60A5FA;
    --rev-accent-dark: #0B1F38;
    --rev-glow: rgba(96, 165, 250, 0.5);
    --rev-bg: #050E1A;
    --rev-felt: #053E2B;
    --rev-felt-light: #0A5C42;
    --rev-surface: #0E1F38;
    --rev-surface-light: #1A2F52;
    --rev-text: #DBEAFE;
    --rev-text-dim: #7DA0CA;
    --rev-line: rgba(0,0,0,0.5);
    --rev-black: #0F0F0F;
    --rev-white: #F8FAFC;
    --rev-gold: #FACC15;
    --rev-success: #4ADE80;
    --rev-danger: #F87171;
}

/* ── Layout ── */
.rev-layout {
    display: flex;
    justify-content: center;
    gap: 20px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    min-height: calc(100vh - 80px);
}
.ad-slot { width: 160px; flex-shrink: 0; }
.ad-slot--left, .ad-slot--right { display: flex; align-items: flex-start; }
.ad-placeholder--vertical {
    width: 160px; height: 600px;
    background: var(--rev-surface);
    border: 1px dashed var(--rev-text-dim);
    display: flex; align-items: center; justify-content: center;
    color: var(--rev-text-dim); font-size: 12px; border-radius: 8px;
}

#reversi-app {
    flex: 1;
    max-width: 700px;
    min-width: 320px;
    color: var(--rev-text);
}

/* Screens */
.screen { display: none; }
.screen.active { display: block; animation: revFade 0.3s ease; }
@keyframes revFade {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.rev-header { text-align: center; padding: 36px 0 24px; }
.rev-logo { margin-bottom: 14px; }
.rev-logo-board {
    display: inline-grid;
    grid-template-columns: repeat(2, 36px);
    gap: 0;
    background: var(--rev-felt);
    padding: 6px;
    border-radius: 8px;
    border: 1px solid var(--rev-accent-dark);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.rev-mini-cell {
    width: 36px; height: 36px;
    border: 1px solid var(--rev-line);
    display: flex; align-items: center; justify-content: center;
}
.rev-mini-stone {
    width: 24px; height: 24px;
    border-radius: 50%;
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.4);
}
.rev-mini-stone.black { background: radial-gradient(circle at 30% 30%, #555, #0a0a0a); }
.rev-mini-stone.white { background: radial-gradient(circle at 30% 30%, #fff, #ccc); }
.rev-header h1 {
    font-family: 'Syne', sans-serif;
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--rev-accent-light);
    letter-spacing: 4px;
    margin: 12px 0 0;
    text-shadow: 0 0 24px var(--rev-glow);
}
.subtitle { color: var(--rev-text-dim); font-size: 1rem; margin-top: 8px; }

/* Cards */
.card {
    background: var(--rev-surface);
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--rev-surface-light);
}
.card__title {
    font-family: 'Syne', sans-serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--rev-accent-light);
    margin-bottom: 14px;
}

/* Difficulty */
.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.diff-btn {
    background: var(--rev-surface-light);
    border: 1.5px solid transparent;
    color: var(--rev-text);
    padding: 14px 8px;
    border-radius: 10px;
    cursor: pointer;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    transition: transform 0.15s ease, border-color 0.15s ease;
    font-family: 'DM Sans', sans-serif;
    font-size: 0.9rem;
}
.diff-btn:hover { transform: translateY(-2px); border-color: var(--rev-accent-light); }
.diff-btn.selected {
    background: linear-gradient(135deg, var(--rev-accent-dark), var(--rev-accent));
    border-color: var(--rev-accent-light);
    box-shadow: 0 0 16px rgba(96,165,250,0.3);
}
.diff-icon { font-family: 'JetBrains Mono', monospace; font-size: 1.2rem; color: var(--rev-gold); }
.diff-desc { font-size: 0.72rem; color: var(--rev-text-dim); }
.diff-btn.selected .diff-desc { color: rgba(255,255,255,0.85); }

/* Color picker */
.rev-color-pick {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.rev-color-btn {
    background: var(--rev-surface-light);
    border: 1.5px solid transparent;
    color: var(--rev-text);
    padding: 14px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-family: 'DM Sans', sans-serif;
    transition: transform 0.15s ease, border-color 0.15s ease;
}
.rev-color-btn:hover { transform: translateY(-2px); border-color: var(--rev-accent-light); }
.rev-color-btn.selected {
    border-color: var(--rev-accent-light);
    background: linear-gradient(135deg, var(--rev-accent-dark), var(--rev-accent));
}
.rev-cb-stone {
    width: 28px; height: 28px;
    border-radius: 50%;
    box-shadow: inset -2px -2px 4px rgba(0,0,0,0.5), 0 2px 6px rgba(0,0,0,0.3);
}
.rev-cb-stone.black { background: radial-gradient(circle at 30% 30%, #555, #0a0a0a); }
.rev-cb-stone.white { background: radial-gradient(circle at 30% 30%, #fff, #ccc); }

/* Rules */
.rev-rules {
    margin: 0; padding-left: 1.1rem;
    color: var(--rev-text-dim);
    font-size: 0.92rem; line-height: 1.7;
}
.rev-rules li + li { margin-top: 6px; }

/* Buttons */
.btn {
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    padding: 12px 22px;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    font-size: 0.95rem;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary {
    background: linear-gradient(135deg, var(--rev-accent), var(--rev-accent-light));
    color: #fff;
    box-shadow: 0 6px 18px rgba(30, 58, 95, 0.5);
}
.btn--outline {
    background: transparent;
    border: 1.5px solid var(--rev-accent-light);
    color: var(--rev-accent-light);
}
.btn--outline:hover { background: rgba(96,165,250,0.12); }
.btn--ghost { background: transparent; color: var(--rev-text-dim); }
.btn--ghost:hover { color: var(--rev-accent-light); }
.btn--lg { padding: 16px 36px; font-size: 1.05rem; }
.btn--sm { padding: 8px 14px; font-size: 0.85rem; }

.menu-actions {
    display: flex; flex-direction: column;
    align-items: center; gap: 8px;
    margin-top: 18px;
}

/* HUD */
#game-hud {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    background: var(--rev-surface);
    padding: 14px;
    border-radius: 12px;
    border: 1px solid var(--rev-surface-light);
    margin-bottom: 18px;
}
.hud__cell { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.hud__label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 1.5px; color: var(--rev-text-dim); }
.hud__value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.4rem; font-weight: 700;
    color: var(--rev-accent-light);
}

/* Board */
.rev-board-wrap {
    position: relative;
    display: flex; justify-content: center;
    padding: 14px 0;
}
.rev-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 1;
    background: var(--rev-felt);
    background-image: radial-gradient(ellipse at top, var(--rev-felt-light), var(--rev-felt) 75%);
    border-radius: 12px;
    padding: 8px;
    box-sizing: border-box;
    border: 2px solid var(--rev-accent-dark);
    box-shadow: 0 14px 36px rgba(0,0,0,0.55);
}
.rev-cell {
    background: rgba(0,0,0,0.2);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    position: relative;
    transition: background 0.1s;
}
.rev-cell.valid::before {
    content: "";
    position: absolute;
    width: 28%; height: 28%;
    border-radius: 50%;
    background: rgba(255,255,255,0.16);
    border: 1.5px solid rgba(255,255,255,0.4);
    transition: transform 0.15s ease, background 0.15s ease;
}
.rev-cell.valid:hover::before {
    background: var(--rev-gold);
    transform: scale(1.4);
}
.rev-cell.last-move::after {
    content: "";
    position: absolute;
    inset: 4px;
    border: 2px solid var(--rev-gold);
    border-radius: 4px;
    pointer-events: none;
}
.rev-stone {
    width: 78%; height: 78%;
    border-radius: 50%;
    box-shadow: inset -3px -3px 6px rgba(0,0,0,0.5), 0 4px 8px rgba(0,0,0,0.4);
    transition: transform 0.4s ease;
}
.rev-stone.black { background: radial-gradient(circle at 30% 30%, #555, #0a0a0a); }
.rev-stone.white { background: radial-gradient(circle at 30% 30%, #fff, #ccc); }
.rev-stone.flip-in { animation: revFlip 0.4s ease; }
@keyframes revFlip {
    0% { transform: rotateY(180deg) scale(0.7); }
    100% { transform: rotateY(0) scale(1); }
}

.rev-status {
    position: absolute;
    top: 20px; right: 20px;
    padding: 8px 14px;
    background: rgba(0,0,0,0.6);
    color: var(--rev-gold);
    border-radius: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s;
}
.rev-status.show { opacity: 1; }

.rev-actions {
    display: flex; justify-content: center;
    flex-wrap: wrap; gap: 10px;
    margin-top: 18px;
}

/* Result */
.result-card, .lb-card {
    background: var(--rev-surface);
    border-radius: 16px;
    padding: 36px 28px;
    border: 1px solid var(--rev-surface-light);
    text-align: center;
    max-width: 480px;
    margin: 40px auto;
    box-shadow: 0 18px 36px rgba(0,0,0,0.4);
}
.result-card h2 {
    font-family: 'Syne', sans-serif;
    font-size: 2rem;
    color: var(--rev-accent-light);
    letter-spacing: 4px;
    margin: 0 0 12px;
}
.result-score {
    font-family: 'JetBrains Mono', monospace;
    font-size: 3rem; font-weight: 700;
    color: var(--rev-gold);
    margin: 8px 0;
}
.result-detail { color: var(--rev-text-dim); font-size: 0.95rem; margin-bottom: 18px; line-height: 1.6; }
#nickname {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--rev-bg);
    color: var(--rev-text);
    border: 1.5px solid var(--rev-surface-light);
    font-family: 'DM Sans', sans-serif;
    font-size: 0.95rem;
    margin-bottom: 12px;
    box-sizing: border-box;
}
#nickname:focus { outline: none; border-color: var(--rev-accent-light); }
.result-actions { display: flex; gap: 10px; justify-content: center; margin-bottom: 10px; }

.lb-card h2 {
    font-family: 'Syne', sans-serif;
    color: var(--rev-accent-light);
    letter-spacing: 4px;
    margin-bottom: 18px;
}
#leaderboard-list { list-style: none; padding: 0; margin: 0 0 16px; text-align: left; counter-reset: lb; }
#leaderboard-list li {
    counter-increment: lb;
    display: flex; justify-content: space-between;
    padding: 10px 14px;
    background: var(--rev-bg);
    margin-bottom: 6px;
    border-radius: 8px;
    border: 1px solid var(--rev-surface-light);
    font-family: 'DM Sans', sans-serif;
}
#leaderboard-list li::before {
    content: counter(lb);
    color: var(--rev-accent-light);
    font-weight: 700;
    margin-right: 10px;
    min-width: 24px;
}
#leaderboard-list li:nth-child(1) { border-color: var(--rev-gold); }
#leaderboard-list li:nth-child(1)::before { color: var(--rev-gold); }
.lb-score { font-family: 'JetBrains Mono', monospace; color: var(--rev-accent-light); font-weight: 600; }

@media (max-width: 900px) {
    .rev-layout { flex-direction: column; padding: 12px; }
    .ad-slot { width: 100%; }
    .ad-placeholder--vertical { width: 100%; height: 90px; }
    .rev-header h1 { font-size: 1.8rem; letter-spacing: 2px; }
    .difficulty-grid { grid-template-columns: repeat(3, 1fr); }
    #game-hud { grid-template-columns: repeat(2, 1fr); }
}
