/* Lanterns — The Harvest Festival */
/* Dark theme with lantern glow accents */

:root {
    --bg-dark: #0a0e1a;
    --bg-card: #141929;
    --bg-panel: #1a2035;
    --text-primary: #e8e6e3;
    --text-secondary: #8b8fa3;
    --accent: #f0a030;
    --accent-glow: rgba(240, 160, 48, 0.3);
    --border: #2a2f45;

    /* Lantern colors */
    --lantern-red: #dc3545;
    --lantern-orange: #fd7e14;
    --lantern-green: #28a745;
    --lantern-blue: #007bff;
    --lantern-purple: #9b59b6;
    --lantern-white: #f0f0f0;
    --lantern-black: #2c2c2c;

    --tile-size: 80px;
}

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

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
    15% { opacity: 1; transform: translateX(-50%) translateY(0); }
    85% { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Screen Management */
.screen { display: none; }
.screen.active { display: flex; }

/* ===== Lobby ===== */
#lobby-screen {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(rgba(10, 14, 26, 0.55), rgba(10, 14, 26, 0.7)),
                url('../assets/bg-lake.png') center/cover no-repeat;
}

.lobby-container {
    text-align: center;
    max-width: 400px;
    padding: 40px;
    background: rgba(20, 25, 41, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    border: 1px solid rgba(240, 160, 48, 0.15);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.lobby-logo {
    width: 100%;
    max-width: 320px;
    margin-bottom: 24px;
}

.lobby-container h1 {
    font-size: 3rem;
    margin-bottom: 4px;
    background: linear-gradient(135deg, var(--accent), #e8732a);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 32px;
}

.name-input {
    margin-bottom: 24px;
}

.name-input label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

input[type="text"] {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 1rem;
    width: 100%;
    outline: none;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    border-color: var(--accent);
}

.btn {
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #e8732a);
    color: #fff;
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px var(--accent-glow); }

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover { border-color: var(--accent); }

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

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

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

.join-row input { flex: 1; }

/* AI / Difficulty */
.vs-ai-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 4px;
}

.difficulty-selector {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.diff-btn {
    flex: 1;
    padding: 8px 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-dark);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.diff-btn:hover { border-color: var(--accent); color: var(--text-primary); }

.diff-btn.selected {
    border-color: var(--accent);
    background: rgba(240, 160, 48, 0.15);
    color: var(--accent);
    font-weight: 600;
}

.ai-count-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ai-count-row select {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    cursor: pointer;
}

.ai-count-row select:focus { border-color: var(--accent); }

/* ===== Waiting Room ===== */
#waiting-screen {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.waiting-container {
    text-align: center;
    max-width: 500px;
    padding: 40px;
}

.game-code {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--accent);
    background: var(--bg-card);
    padding: 16px 32px;
    border-radius: 12px;
    border: 2px dashed var(--border);
    margin: 16px 0 24px;
    cursor: pointer;
    user-select: all;
}

#wait-players {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.player-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.status-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* ===== Game Screen ===== */
#game-screen {
    flex-direction: column;
    height: 100vh;
}

#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

#turn-indicator {
    font-weight: 600;
    font-size: 0.95rem;
}

#turn-indicator .active-turn {
    color: var(--accent);
}

#supply-display {
    display: flex;
    gap: 6px;
    align-items: center;
}

.supply-pip {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.2);
}

#dedication-stacks {
    display: flex;
    gap: 8px;
    font-size: 0.8rem;
}

.ded-stack {
    background: var(--bg-card);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.ded-stack .ded-value {
    color: var(--accent);
    font-weight: 700;
}

/* Game Area */
#game-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#opponents-bar {
    display: flex;
    justify-content: center;
    gap: 16px;
    padding: 8px 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.opponent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 14px;
    min-width: 140px;
    text-align: center;
}

.opponent-card.active-player {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
}

.opponent-name {
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.opponent-cards {
    display: flex;
    gap: 3px;
    justify-content: center;
    flex-wrap: wrap;
}

.mini-card {
    width: 14px;
    height: 18px;
    border-radius: 2px;
    border: 1px solid rgba(255,255,255,0.15);
}

.opponent-vp {
    font-size: 0.75rem;
    color: var(--accent);
    margin-top: 4px;
}

/* Board */
#board-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
    background: url('../assets/board-texture.png') center/cover no-repeat;
    border-radius: 4px;
    padding: 4%;
}

#board-svg {
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 600px;
}

/* SVG Tile styles */
.tile-group { cursor: default; }

.tile-bg {
    fill: #1a2840;
    stroke: #2a3a5a;
    stroke-width: 1;
}

.tile-quadrant { opacity: 0.85; }
.tile-quadrant:hover { opacity: 1; }

.platform-marker {
    fill: gold;
    stroke: #b8860b;
    stroke-width: 1;
}

.valid-spot {
    fill: rgba(240, 160, 48, 0.1);
    stroke: var(--accent);
    stroke-width: 1;
    stroke-dasharray: 4 4;
    cursor: pointer;
    transition: fill 0.2s;
}

.valid-spot:hover {
    fill: rgba(240, 160, 48, 0.25);
}

/* Player Panel */
#player-panel {
    background: var(--bg-panel);
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
    flex-wrap: wrap;
}

#my-cards {
    display: flex;
    gap: 6px;
    align-items: flex-end;
}

.card-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.card-pip {
    width: 44px;
    height: 56px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    border: 2px solid rgba(255,255,255,0.2);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Lantern sprite backgrounds for card pips (3×2 grid) */
.card-pip.bg-orange  { background: url('../assets/lanterns-strip.png') 0% 0%     / 300% 200%; }
.card-pip.bg-green   { background: url('../assets/lanterns-strip.png') 50% 0%    / 300% 200%; }
.card-pip.bg-blue    { background: url('../assets/lanterns-strip.png') 100% 0%   / 300% 200%; }
.card-pip.bg-purple  { background: url('../assets/lanterns-strip.png') 0% 100%   / 300% 200%; }
.card-pip.bg-red     { background: url('../assets/lanterns-strip.png') 50% 100%  / 300% 200%; }
.card-pip.bg-white   { background: url('../assets/lanterns-strip.png') 100% 100% / 300% 200%; color: #fff !important; }

.card-pip:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.4);
}

.card-pip.selected {
    transform: translateY(-6px);
    box-shadow: 0 0 12px var(--accent-glow);
    border-color: var(--accent);
}

.card-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    text-transform: capitalize;
}

#my-tiles {
    display: flex;
    gap: 8px;
    align-items: center;
}

.hand-tile {
    width: 64px;
    height: 64px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid var(--border);
    transition: all 0.15s;
    overflow: hidden;
}

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

.hand-tile.selected {
    border-color: var(--accent);
    box-shadow: 0 0 12px var(--accent-glow);
    transform: translateY(-4px);
}

.hand-tile svg { width: 100%; height: 100%; }

#action-buttons {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex-wrap: wrap;
}

.btn-action {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-action:hover {
    border-color: var(--accent);
    background: rgba(240, 160, 48, 0.1);
}

.btn-action.primary {
    background: linear-gradient(135deg, var(--accent), #e8732a);
    color: #fff;
    border: none;
}

/* Favor Tokens */
.favor-display {
    display: flex;
    gap: 3px;
    align-items: center;
    color: var(--lantern-red);
    font-size: 0.85rem;
    font-weight: 600;
}

.favor-token {
    width: 20px;
    height: 20px;
    background: var(--lantern-red);
    border-radius: 50%;
    border: 2px solid #b8262f;
}

/* Player VP Display */
.my-vp-display {
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(240, 160, 48, 0.15);
    border: 1px solid var(--accent);
    border-radius: 8px;
    padding: 6px 12px;
    margin-right: 8px;
}

.my-vp-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--accent);
}

.my-vp-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Game Log */
#game-log {
    position: fixed;
    bottom: 100px;
    right: 12px;
    width: 260px;
    max-height: 200px;
    overflow-y: auto;
    background: rgba(10, 14, 26, 0.9);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    pointer-events: none;
}

.log-entry {
    padding: 3px 0;
    border-bottom: 1px solid rgba(42, 47, 69, 0.5);
}

.log-entry:last-child { border-bottom: none; }

/* Game Over Overlay */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.overlay-content {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 24px;
}

#final-scores {
    margin-bottom: 24px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 16px;
    margin: 4px 0;
    background: var(--bg-card);
    border-radius: 6px;
}

.score-row.winner {
    border: 1px solid var(--accent);
    background: rgba(240, 160, 48, 0.1);
}

.score-rank { color: var(--text-secondary); width: 30px; }
.score-name { flex: 1; text-align: left; font-weight: 600; }
.score-vp { color: var(--accent); font-weight: 700; }

/* Color backgrounds */
.bg-red { background: var(--lantern-red); }
.bg-orange { background: var(--lantern-orange); }
.bg-green { background: var(--lantern-green); }
.bg-blue { background: var(--lantern-blue); }
.bg-purple { background: var(--lantern-purple); }
.bg-white { background: var(--lantern-white); color: #333 !important; }
.bg-black { background: var(--lantern-black); border-color: #555 !important; }

/* Responsive */
@media (max-width: 768px) {
    #player-panel {
        flex-direction: column;
        align-items: stretch;
    }
    #action-buttons {
        margin-left: 0;
        justify-content: center;
    }
    #game-log { display: none; }
    :root { --tile-size: 60px; }
}

/* ===== Coach Bar (contextual help during game) ===== */
#coach-bar {
    background: linear-gradient(135deg, rgba(240, 160, 48, 0.12), rgba(232, 115, 42, 0.08));
    border-bottom: 1px solid rgba(240, 160, 48, 0.2);
    padding: 8px 16px;
    font-size: 0.82rem;
    color: var(--text-primary);
    display: none;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    line-height: 1.4;
}

#coach-bar.visible { display: flex; }

#coach-bar .coach-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

#coach-bar .coach-text {
    flex: 1;
}

#coach-bar .coach-text strong {
    color: var(--accent);
}

#coach-bar .coach-dismiss {
    background: none;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
    flex-shrink: 0;
}

#coach-bar .coach-dismiss:hover { border-color: var(--accent); color: var(--text-primary); }

/* Help button in top bar */
.btn-help {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-help:hover {
    border-color: var(--accent);
    background: rgba(240, 160, 48, 0.15);
}

.btn-quit {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(220, 53, 69, 0.3);
    background: rgba(220, 53, 69, 0.1);
    color: #e8756e;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-quit:hover {
    border-color: var(--lantern-red);
    background: rgba(220, 53, 69, 0.2);
    color: #fff;
}

/* ===== Tutorial Modal ===== */
.tutorial-modal {
    max-width: 620px;
    max-height: 85vh;
    overflow-y: auto;
    text-align: left;
    padding: 32px;
    position: relative;
}

.tutorial-modal h2 {
    text-align: center;
    margin-bottom: 20px;
}

.btn-close-modal {
    position: absolute;
    top: 12px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
}

.btn-close-modal:hover { color: var(--text-primary); }

.tutorial-sections {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tut-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

.tut-section h3 {
    font-size: 0.95rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.tut-section p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
    line-height: 1.5;
}

.tut-section strong { color: var(--text-primary); }

.tut-key {
    border-color: rgba(240, 160, 48, 0.3);
    background: rgba(240, 160, 48, 0.05);
}

.tut-highlight {
    color: var(--accent) !important;
    font-weight: 600;
    font-size: 0.85rem !important;
}

.tut-visual {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.tut-tile-demo {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 64px;
    height: 64px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.1);
}

.tut-tile-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    flex-shrink: 0;
}

.tut-quad {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 700;
    color: rgba(255,255,255,0.7);
}

.tut-arrow {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Turn phases */
.tut-phases {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 4px;
}

.tut-phase {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.tut-phase-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 800;
    flex-shrink: 0;
    margin-top: 2px;
}

.tut-phase p {
    font-size: 0.78rem;
    margin-bottom: 4px;
}

.tut-opt {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-style: italic;
}

.tut-req {
    font-size: 0.7rem;
    color: var(--lantern-red);
    font-weight: 600;
}

.tut-ded-types {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 6px 0;
}

.tut-ded {
    font-size: 0.78rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tut-ded-vp {
    background: var(--accent);
    color: #000;
    font-weight: 800;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 24px;
    text-align: center;
}

.tut-warn {
    color: var(--lantern-red) !important;
    font-weight: 600;
    font-size: 0.78rem !important;
}

.tut-controls p, .tut-tips p {
    font-size: 0.78rem;
    margin-bottom: 4px;
}

/* ===== Game List (Lobby) ===== */
.game-list {
    margin-top: 16px;
    text-align: left;
}

.game-list h3 {
    font-size: 0.9rem;
    color: var(--accent);
    margin-bottom: 8px;
    text-align: center;
}

.no-games {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
    padding: 12px;
}

.game-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    margin-bottom: 6px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
}

.game-row.joinable {
    border-color: var(--accent);
    border-color: rgba(240, 160, 48, 0.3);
}

.game-row.in-progress {
    opacity: 0.6;
}

.game-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.game-code-small {
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: bold;
}

.game-players {
    font-size: 0.8rem;
    color: var(--text-primary);
}

.game-spots {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.game-row.joinable .game-spots {
    color: #28a745;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.75rem;
}
