/* ===== Theme Variables ===== */
:root {
    --bg: #f8f9fa;
    --bg-surface: #ffffff;
    --bg-raised: #f1f3f5;
    --text: #333;
    --text-muted: #6c757d;
    --border: #dee2e6;
    --border-hover: #adb5bd;
    --accent: #339af0;
    --btn-bg: #495057;
    --btn-bg-hover: #343a40;
    --shadow-sm: rgba(0, 0, 0, 0.1);
    --shadow-md: rgba(0, 0, 0, 0.15);
    --shadow-lg: rgba(0, 0, 0, 0.2);
    --kbd-bg: #e9ecef;
    --kbd-border: #dee2e6;
    --none-bg: #adb5bd;
    --none-border: #868e96;
}

[data-theme="dark"] {
    --bg: #1a1a2e;
    --bg-surface: #16213e;
    --bg-raised: #1e2a4a;
    --text: #eee;
    --text-muted: #aaa;
    --border: #2a3a5e;
    --border-hover: #3a4a6e;
    --accent: #4dabf7;
    --btn-bg: #2a3a5e;
    --btn-bg-hover: #3a4a6e;
    --shadow-sm: rgba(0, 0, 0, 0.3);
    --shadow-md: rgba(0, 0, 0, 0.4);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --kbd-bg: #2a3a5e;
    --kbd-border: #3a4a6e;
    --none-bg: #4a5568;
    --none-border: #636e7e;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ===== Theme Toggle ===== */
.theme-toggle {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 10000;
    background: var(--bg-surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px;
    line-height: 0;
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--text);
    border-color: var(--border-hover);
}

.theme-toggle .icon {
    width: 18px;
    height: 18px;
}

.theme-toggle .icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-sun {
    display: none;
}

[data-theme="dark"] .theme-toggle .icon-moon {
    display: block;
}

/* ===== Index (index.html) ===== */
body.index-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

body.index-page h1 {
    font-size: 2.4rem;
    margin-bottom: 4px;
}

.tagline {
    font-size: 1.1rem;
    color: var(--text-muted);
    margin-bottom: 36px;
}

.how-to-play {
    max-width: 640px;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 32px;
    margin-bottom: 32px;
}

.how-to-play h2 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.how-to-play ol {
    padding-left: 20px;
    line-height: 1.7;
}

.how-to-play ol > li {
    margin-bottom: 12px;
}

.how-to-play ul {
    padding-left: 18px;
    margin-top: 6px;
}

.how-to-play a {
    color: var(--accent);
    text-decoration: none;
}

.how-to-play a:hover {
    text-decoration: underline;
}

.ring-label {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 8px;
    border-radius: 4px;
    color: #333;
}

.ring-label.attribute { background: #ff6b6b; }
.ring-label.context   { background: #4dabf7; }
.ring-label.word      { background: #69db7c; }

.nav-links {
    display: flex;
    gap: 20px;
    margin-bottom: 32px;
    flex-wrap: wrap;
    justify-content: center;
}

.nav-card {
    display: block;
    width: 260px;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.2s, transform 0.2s;
}

.nav-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
}

.nav-card h3 {
    font-size: 1.2rem;
    margin-bottom: 8px;
}

.nav-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.tips {
    max-width: 640px;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 28px 32px;
}

.tips h2 {
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
    color: var(--text-muted);
}

.tips ul {
    padding-left: 20px;
    line-height: 1.7;
}

.tips li {
    margin-bottom: 8px;
}

.tips kbd {
    background: var(--kbd-bg);
    border: 1px solid var(--kbd-border);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: inherit;
    font-size: 0.9em;
}

.tips em {
    color: var(--accent);
}

/* ===== Board (board.html) ===== */
body.board-page {
    overflow: hidden;
    user-select: none;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.board-area {
    height: 85vh;
    position: relative;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
}

.venn-circle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.3;
    width: 40vw;
    height: 40vw;
}

.venn-circle:hover {
    opacity: 0.4;
}

.circle1 {
    background: #ff6b6b;
    border: 2px solid #ff5252;
    top: 2vh;
    left: calc(40% - 40vw + 10vw);
}

.circle2 {
    background: #4dabf7;
    border: 2px solid #339af0;
    top: 2vh;
    left: calc(40% - 10vw);
}

.circle3 {
    background: #69db7c;
    border: 2px solid #51cf66;
    top: calc(85vh - 40vw - 1vh);
    left: calc(40% - 20vw);
}

.region-label {
    position: absolute;
    font-weight: bold;
    font-size: 18px;
    color: #333;
    z-index: 100;
    padding: 8px 12px;
    border-radius: 6px;
    border: 2px solid;
    text-transform: uppercase;
    opacity: 0.8;
}

.label-1 {
    background: #ff6b6b;
    border-color: #ff5252;
    top: calc(2vh + 5vh);
    left: calc((40% - 40vw + 10vw) - 6vw);
}

.label-2 {
    background: #4dabf7;
    border-color: #339af0;
    top: calc(2vh + 5vh);
    left: calc((40% - 10vw) + 40vw + 6vw - 8vw);
}

.label-3 {
    background: #69db7c;
    border-color: #51cf66;
    top: 52vw;
    left: calc((40% - 20vw) + 3vw);
}

.label-none {
    background: var(--none-bg);
    border-color: var(--none-border);
    color: var(--text);
    top: 50%;
    left: 80vw;
}

.bottom-area {
    height: 15vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg-raised);
}

.hand-area {
    display: flex;
    gap: 15px;
    align-items: center;
    min-height: 60px;
}

.word-card {
    width: 120px;
    height: 60px;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-transform: uppercase;
    box-shadow: 0 2px 4px var(--shadow-sm);
    position: relative;
    z-index: 1000;
}

.word-card:hover {
    box-shadow: 0 4px 8px var(--shadow-md);
    border-color: var(--border-hover);
}

.word-card:active {
    cursor: grabbing;
}

.word-card.dragging {
    position: fixed;
    z-index: 9999;
    transform: scale(1.05);
    box-shadow: 0 8px 16px var(--shadow-lg);
}

.draw-button {
    width: 100px;
    height: 60px;
    background: var(--btn-bg);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    margin-left: 20px;
    box-shadow: 0 2px 4px var(--shadow-sm);
}

.draw-button:hover {
    background: var(--btn-bg-hover);
    box-shadow: 0 4px 8px var(--shadow-md);
}

.draw-button:active {
    transform: translateY(1px);
}

.floating-card {
    position: absolute;
    z-index: 1001;
}

.empty-slot {
    width: 120px;
    height: 60px;
    border: 2px dashed var(--border-hover);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ===== Board Tablet ===== */
@media (max-width: 1024px) and (min-width: 601px) {
    .circle3 {
        top: calc(2vh + 20vw);
        left: calc(40% - 20vw);
        max-height: calc(85vh - 2vh - 20vw - 2vh);
    }

    .label-3 {
        top: min(calc(2vh + 20vw + 41vw), calc(85vh - 5vh));
    }
}

/* ===== Board Mobile ===== */
@media (max-width: 600px) {
    .board-area {
        height: 70vh;
    }

    .venn-circle {
        width: 48vw;
        height: 48vw;
    }

    .circle1 {
        left: calc(50% - 40vw);
    }

    .circle2 {
        left: calc(50% - 8vw);
    }

    .circle3 {
        top: calc(2vh + 28vw);
        left: calc(50% - 24vw);
    }

    .region-label {
        font-size: 11px;
        padding: 4px 6px;
    }

    .label-1 {
        top: 2vw;
        left: 2vw;
    }

    .label-2 {
        top: 46px;
        left: auto;
        right: 2vw;
    }

    .label-3 {
        top: min(calc(2vh + 28vw + 49vw), calc(70vh - 5vh));
        left: calc(50% - 24vw + 2vw);
    }

    .label-none {
        left: auto;
        right: 3vw;
        top: calc(70vh - 8vh);
    }

    .bottom-area {
        height: 30vh;
        flex-direction: column;
        padding: 10px;
        gap: 8px;
        overflow-y: auto;
    }

    .hand-area {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    .word-card {
        width: 85px;
        height: 42px;
        font-size: 11px;
    }

    .draw-button {
        width: 80px;
        height: 38px;
        font-size: 14px;
        margin-left: 0;
    }
}

/* ===== Clues (clues.html) ===== */
body.clues-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 20px;
}

body.clues-page h1 {
    font-size: 2rem;
    margin-bottom: 30px;
}

.controls {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 40px;
}

.controls select {
    padding: 10px 20px;
    font-size: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-surface);
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
}

.controls button {
    padding: 10px 28px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    background: #e94560;
    color: #fff;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
}

.controls button:hover {
    background: #c73650;
}

.clues {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 900px;
    width: 100%;
}

.clue-card {
    flex: 1 1 250px;
    max-width: 300px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    text-align: center;
}

.clue-card h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.clue-card.word h2 {
    color: #333;
    background: #69db7c;
    border-radius: 6px;
    padding: 6px;
}

.clue-card.attribute h2 {
    color: #333;
    background: #ff6b6b;
    border-radius: 6px;
    padding: 6px;
}

.clue-card.context h2 {
    color: #333;
    background: #4dabf7;
    border-radius: 6px;
    padding: 6px;
}

.clue-text {
    font-size: 1.15rem;
    line-height: 1.5;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}
