/* Kokomo Design System - Shared across all pages */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@600;700;800;900&display=swap');

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

:root {
    --ocean: #0A3D62; --ocean-dark: #072C47;
    --teal: #00C5A5; --teal-dark: #00A88D; --teal-light: #E0F7F2;
    --coral: #FF6B6B; --coral-dark: #E05555;
    --gold: #FFD166; --gold-dark: #E8B84A;
    --sand: #FFF5E1;
    --white: #FFFFFF; --bg: #F0FAFA; --fg: #1A1A2E;
    --muted: #6B8A8A; --border: #D1E0E0;
    --correct: #22c55e; --incorrect: #ef4444; --present: #eab308;
    --cell-size: 38px;
}

body {
    font-family: 'Nunito', -apple-system, sans-serif;
    background: var(--bg);
    color: var(--fg);
    min-height: 100vh;
}

/* ─── Game Header ─── */
.game-header {
    background: linear-gradient(180deg, var(--ocean) 0%, #0D4E7A 100%);
    color: var(--white);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.game-header .back {
    color: var(--teal);
    text-decoration: none;
    font-weight: 800;
    font-size: 14px;
}
.game-header h1 {
    font-size: 20px;
    font-weight: 900;
}
.game-header-right {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ─── Toolbar ─── */
.game-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--white);
    border-bottom: 2px solid var(--border);
    flex-wrap: wrap;
    gap: 6px;
}
.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Timer ─── */
.timer {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    font-weight: 800;
    color: var(--ocean);
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 10px;
    background: var(--teal-light);
}
.timer svg { color: var(--teal); width: 16px; height: 16px; }

/* ─── Buttons ─── */
.btn {
    padding: 8px 16px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--white);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    color: var(--ocean);
    transition: all 0.15s;
}
.btn:hover { border-color: var(--teal); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--ocean);
    color: var(--white);
    border-color: var(--ocean);
    border-bottom: 3px solid var(--ocean-dark);
}
.btn-primary:active { border-bottom-width: 1px; transform: translateY(2px); }
.btn-teal { background: var(--teal); color: var(--white); border-color: var(--teal-dark); border-bottom: 3px solid var(--teal-dark); }
.btn-coral { background: var(--coral); color: var(--white); border-color: var(--coral-dark); border-bottom: 3px solid var(--coral-dark); }
.btn-gold { background: var(--gold); color: var(--ocean); border-color: var(--gold-dark); border-bottom: 3px solid var(--gold-dark); }

/* ─── Dropdown ─── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: 12px;
    min-width: 170px;
    z-index: 50;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: none;
    background: none;
    text-align: left;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    color: var(--fg);
    cursor: pointer;
}
.dropdown-item:hover { background: var(--teal-light); }

/* ─── Current Clue Bar ─── */
.clue-bar {
    background: var(--white);
    padding: 10px 14px;
    border-radius: 12px;
    margin: 12px 0;
    font-size: 14px;
    font-weight: 700;
    min-height: 42px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 2px solid var(--border);
}
.clue-bar .clue-number { color: var(--teal); font-weight: 900; }
.clue-bar .clue-text { color: var(--muted); }

/* ─── Grid ─── */
.grid-wrapper {
    display: inline-block;
    border: 3px solid var(--ocean);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
}
.grid-wrapper.paused { filter: blur(20px); pointer-events: none; }

#hidden-input {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    opacity: 0;
    border: none; outline: none;
    padding: 0; margin: 0;
    z-index: 10;
    font-size: 16px;
    caret-color: transparent;
}

.grid { display: grid; gap: 0; touch-action: manipulation; }

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    border: 1px solid var(--border);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
    background: var(--white);
    transition: background 0.1s;
}
.cell.black { background: var(--ocean); cursor: default; }
.cell .cell-number {
    position: absolute;
    top: 1px; left: 2px;
    font-size: 9px;
    font-weight: 800;
    color: var(--ocean);
}
.cell .cell-letter {
    font-size: 18px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--fg);
}
.cell.selected { background: var(--gold); }
.cell.highlighted { background: var(--teal-light); }
.cell.correct .cell-letter { color: var(--correct); }
.cell.incorrect .cell-letter { color: var(--incorrect); }
.cell.revealed .cell-letter { color: var(--muted); }

/* ─── Clues Panel ─── */
.clues-panel {
    display: flex;
    flex-direction: row;
    gap: 20px;
    max-height: calc(var(--cell-size) * 15 + 80px);
    overflow-y: auto;
}
.clues-column { flex: 1; min-width: 0; }
.clues-column h3 {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--ocean);
    padding-bottom: 6px;
    border-bottom: 3px solid var(--ocean);
    margin-bottom: 6px;
}
.clue-list { list-style: none; }
.clue-item {
    padding: 5px 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    gap: 6px;
    transition: background 0.1s;
}
.clue-item:hover { background: var(--teal-light); }
.clue-item.active { background: var(--teal-light); border-left: 3px solid var(--teal); }
.clue-item .clue-num { font-weight: 800; color: var(--ocean); min-width: 20px; }

/* ─── Game Layout ─── */
.game-container {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px;
}
.grid-section { flex-shrink: 0; }
.clues-section { flex: 1; min-width: 0; }

/* ─── Modals ─── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 61, 98, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--white);
    border-radius: 20px;
    padding: 32px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}
.modal h2 {
    font-size: 24px;
    font-weight: 900;
    color: var(--ocean);
    margin-bottom: 8px;
}
.modal p {
    font-size: 15px;
    color: var(--muted);
    margin-bottom: 20px;
    font-weight: 600;
}
.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ─── Stats Grid ─── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin: 16px 0;
}
.stat-box { text-align: center; }
.stat-value { font-size: 26px; font-weight: 900; color: var(--ocean); }
.stat-label { font-size: 10px; color: var(--muted); font-weight: 700; margin-top: 2px; }

/* ─── Toast ─── */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-80px);
    background: var(--ocean);
    color: var(--white);
    padding: 10px 24px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 800;
    z-index: 200;
    transition: transform 0.3s;
    pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); }

/* ─── Pause Overlay ─── */
.pause-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 20;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 12px;
    cursor: pointer;
}
.pause-overlay.visible { display: flex; }
.pause-overlay svg { color: var(--ocean); opacity: 0.8; }
.pause-overlay span { font-size: 14px; font-weight: 800; color: var(--ocean); }

/* ─── Challenge Modal ─── */
.challenge-modal {
    max-width: 420px;
    padding: 24px 24px 28px;
    position: relative;
    overflow: hidden;
    animation: challengeSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes challengeSlideIn {
    from { opacity: 0; transform: scale(0.85) translateY(30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}
.challenge-close {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--muted);
    cursor: pointer;
    line-height: 1;
    padding: 4px;
}
.challenge-close:hover { color: var(--ocean); }
.challenge-header {
    margin-bottom: 16px;
}
.challenge-sword {
    font-size: 40px;
    margin-bottom: 4px;
    animation: swordPulse 2s ease-in-out infinite;
}
@keyframes swordPulse {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(1.1) rotate(-5deg); }
}
.challenge-header h2 {
    margin-bottom: 0;
    font-size: 22px;
}
.challenge-card {
    background: linear-gradient(135deg, var(--ocean) 0%, #0D4E7A 50%, #155d8a 100%);
    border-radius: 16px;
    padding: 3px;
    margin: 0 auto 12px;
    max-width: 320px;
    box-shadow: 0 8px 32px rgba(10, 61, 98, 0.3), 0 0 0 1px rgba(255,255,255,0.1) inset;
}
.challenge-card-inner {
    background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.02) 100%);
    border-radius: 14px;
    padding: 20px 16px;
}
.challenge-brand {
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 3px;
    color: rgba(255,255,255,0.5);
    margin-bottom: 14px;
    text-transform: uppercase;
}
.challenge-brand span { letter-spacing: 0; }
.challenge-grid-emoji {
    font-size: 16px;
    line-height: 1.3;
    margin-bottom: 16px;
    letter-spacing: 1px;
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
}
.challenge-stats-row {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 12px;
}
.challenge-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.challenge-stat-icon { font-size: 18px; }
.challenge-stat-value {
    font-size: 20px;
    font-weight: 900;
    color: var(--white);
}
.challenge-stat-label {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.5);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.challenge-taunt {
    font-size: 15px;
    font-weight: 800;
    color: var(--gold);
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.challenge-share-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.challenge-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    color: var(--white);
    cursor: pointer;
    transition: all 0.15s;
}
.challenge-share-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.challenge-share-btn:active { transform: translateY(1px); }
.challenge-share-btn.messenger { background: #0084FF; }
.challenge-share-btn.facebook { background: #1877F2; }
.challenge-share-btn.instagram { background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888); }
.challenge-share-btn.copy { background: var(--ocean); }
.challenge-share-btn svg { flex-shrink: 0; }

/* ─── Confetti ─── */
#confetti-canvas {
    position: fixed;
    inset: 0;
    z-index: 150;
    pointer-events: none;
}

/* ─── Loading Spinner ─── */
.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 40px auto;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ─── Responsive ─── */
@media (max-width: 800px) {
    :root { --cell-size: 32px; }
    .game-container { flex-direction: column; gap: 16px; }
    .grid-section {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .clue-bar { width: 100%; }
    .clues-panel { flex-direction: row; gap: 16px; }
    .clues-column { flex: 1; }
}

/* ─── Mobile Clue Panel ─── */
.mobile-clue-panel {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    padding: 12px 16px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 50;
    font-size: 14px;
    font-weight: 700;
    border-top: 3px solid var(--teal);
}
.mobile-clue-panel .mobile-clue-number { color: var(--teal); font-weight: 900; margin-right: 8px; }
.mobile-clue-panel .mobile-clue-text { color: var(--muted); }
@media (max-width: 768px) {
    .mobile-clue-panel { display: flex; align-items: center; }
    body { padding-bottom: 60px; }
    .clues-section {
        max-height: 200px;
        overflow-y: auto;
        margin-bottom: 70px;
    }
}

/* ─── Hint Button Short/Full ─── */
.hint-short { display: none; }
@media (max-width: 768px) {
    .hint-full { display: none; }
    .hint-short { display: inline; }
}

@media (max-width: 500px) {
    :root { --cell-size: 28px; }
    .cell .cell-number { font-size: 7px; }
    .cell .cell-letter { font-size: 14px; }
    .game-header h1 { font-size: 17px; }
    .game-toolbar { flex-direction: column; align-items: stretch; }
}
