/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    justify-content: center;
    padding: clamp(5px, 1vh, 15px);
    color: #333;
    overflow: hidden;
}

/* Desktop: center vertically */
@media (min-width: 768px) {
    body {
        align-items: center;
    }
}

.container {
    background: white;
    border-radius: clamp(8px, 2vw, 16px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: clamp(8px, 2vw, 30px);
    max-width: 900px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

/* Desktop: fill viewport height */
@media (min-width: 768px) {
    .container {
        height: 100%;
        max-height: 100%;
        overflow: hidden;
    }
}

/* Header */
header {
    margin-bottom: clamp(6px, 1vh, 12px);
    position: relative;
    display: flex;
    align-items: center;
    gap: clamp(6px, 1vw, 10px);
    flex-shrink: 0;
}

h1 {
    font-size: clamp(0.8em, 2vw, 1.2em);
    color: #667eea;
    font-weight: 700;
    margin: 0;
    flex-shrink: 0;
}

/* Menu Button */
.menu-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: clamp(4px, 1vh, 8px);
    background: transparent;
    border: 1px solid #ddd;
    border-radius: clamp(4px, 0.8vw, 6px);
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.menu-btn svg {
    width: clamp(14px, 3vw, 20px);
    height: clamp(14px, 3vw, 20px);
}

.menu-btn:hover {
    background: #f0f0f0;
    border-color: #667eea;
    color: #667eea;
}

/* Board Selector - Small and subtle */
.board-selector {
    display: flex;
    gap: clamp(3px, 0.5vw, 5px);
    align-items: center;
    margin-right: clamp(30px, 5vw, 45px);
}

.board-btn {
    padding: clamp(2px, 0.5vh, 4px) clamp(5px, 1vw, 10px);
    border: 1px solid #ddd;
    background: white;
    color: #999;
    border-radius: clamp(3px, 0.5vw, 5px);
    cursor: pointer;
    font-weight: 400;
    font-size: clamp(0.55em, 1.2vw, 0.75em);
    transition: all 0.2s ease;
    opacity: 0.6;
}

.board-btn:hover {
    opacity: 0.9;
    border-color: #bbb;
}

.board-btn.active {
    background: #f0f0f0;
    color: #667eea;
    border-color: #667eea;
    opacity: 1;
}

/* Main content area */
main {
    display: flex;
    flex-direction: column;
}

/* Desktop: fill available space */
@media (min-width: 768px) {
    main {
        flex: 1;
        min-height: 0;
        overflow: hidden;
    }
}

/* Compact Stats Bar */
.stats-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: clamp(4px, 0.8vh, 10px);
    padding: clamp(4px, 1vh, 8px) clamp(8px, 2vw, 12px);
    background: #f7f7f7;
    border-radius: clamp(4px, 1vw, 8px);
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.stats-bar.turn-change {
    animation: statsHighlight 0.6s ease;
}

@keyframes statsHighlight {
    0% {
        background: #f7f7f7;
    }
    50% {
        background: #fef3c7;
        box-shadow: 0 0 0 2px #fbbf24;
    }
    100% {
        background: #f7f7f7;
    }
}

.stats-inline {
    display: flex;
    align-items: center;
    gap: clamp(6px, 1vw, 10px);
    font-size: clamp(0.7em, 1.5vw, 0.95em);
}

.stat-item {
    color: #666;
    font-weight: 500;
}

.stat-item span {
    color: #667eea;
    font-weight: 700;
    margin-left: 4px;
}

.stat-divider {
    color: #ccc;
    font-weight: 300;
}

.btn-next {
    padding: clamp(3px, 0.8vh, 6px) clamp(6px, 1.5vw, 12px);
    background: #667eea;
    color: white;
    border: none;
    border-radius: clamp(4px, 0.8vw, 6px);
    font-size: clamp(0.65em, 1.4vw, 0.85em);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-next:hover {
    background: #5568d3;
    transform: translateY(-1px);
}

/* Compact Clue Container */
.clue-container {
    margin-bottom: clamp(4px, 0.8vh, 8px);
    padding: clamp(4px, 1vh, 8px) clamp(8px, 2vw, 12px);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: clamp(4px, 1vw, 8px);
    color: white;
    display: flex;
    align-items: center;
    gap: clamp(4px, 1vw, 8px);
    transition: background 0.5s ease;
    flex-shrink: 0;
}

.clue-container.turn-change {
    animation: turnTransition 0.6s ease;
}

@keyframes turnTransition {
    0% {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        transform: scale(1);
    }
    25% {
        background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
        transform: scale(1.03);
    }
    50% {
        background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
        transform: scale(1.03);
    }
    75% {
        background: linear-gradient(135deg, #7c8ef0 0%, #8c5bb8 100%);
        transform: scale(1.01);
    }
    100% {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        transform: scale(1);
    }
}

.clue-label {
    font-size: clamp(0.6em, 1.5vw, 0.8em);
    font-weight: 700;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.clue-text {
    font-size: clamp(0.75em, 1.8vw, 1em);
    font-weight: 600;
    flex: 1;
}

.guess-counter {
    padding: clamp(2px, 0.5vh, 4px) clamp(6px, 1vw, 10px);
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    font-weight: 600;
    font-size: clamp(0.7em, 1.5vw, 0.9em);
}

/* Grid - Mobile: natural sizing */
.grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: clamp(2px, 0.5vw, 8px);
    padding: clamp(4px, 1.5vw, 15px);
    background: #f7f7f7;
    border-radius: clamp(6px, 1vw, 12px);
    margin: 0 0 clamp(10px, 2vh, 20px) 0;
}

/* Grid - Desktop: fill space */
@media (min-width: 768px) {
    .grid {
        grid-template-rows: repeat(6, 1fr);
        flex: 1;
        min-height: 0;
        margin: 0;
    }
}

.tile {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid #ddd;
    border-radius: clamp(3px, 0.5vw, 8px);
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 600;
    font-size: clamp(0.6em, 1.8vw, 1em);
    text-align: center;
    padding: clamp(2px, 0.5vw, 5px);
    word-wrap: break-word;
    user-select: none;
    overflow: hidden;
    line-height: 1.1;
    box-sizing: border-box;
}

/* Tiles - Desktop: fill grid cells */
@media (min-width: 768px) {
    .tile {
        height: 100%;
        aspect-ratio: auto;
    }
}

.tile:hover:not(.revealed) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #667eea;
}

.tile.revealed {
    cursor: not-allowed;
    opacity: 1;
}

.tile.revealed.correct {
    background: #4ade80;
    color: white;
    border-color: #22c55e;
}

.tile.revealed.wrong {
    background: #f87171;
    color: white;
    border-color: #ef4444;
}

.tile.revealed.neutral {
    background: #94a3b8;
    color: white;
    border-color: #64748b;
}

.tile.revealed.game-over {
    background: #000;
    color: white;
    border-color: #000;
}

.tile.game-over-shake {
    animation: shake 0.5s;
}

.tile.unpicked {
    opacity: 0.35;
    filter: grayscale(20%);
}

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

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.btn {
    padding: 12px 30px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #e2e8f0;
    color: #475569;
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    color: #667eea;
    margin-bottom: 15px;
    font-size: 2em;
}

.modal-content p {
    color: #666;
    margin-bottom: 20px;
    font-size: 1.1em;
}

.final-score {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 25px 0;
    padding: 20px;
    background: #f7f7f7;
    border-radius: 12px;
}

.final-score .stat-value {
    font-size: 3em;
}

/* Footer */
footer {
    margin-top: clamp(10px, 2vh, 20px);
    text-align: center;
    color: #666;
    font-size: clamp(0.7em, 1.5vw, 0.85em);
    padding-top: clamp(8px, 1.5vh, 15px);
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

/* Mobile: ensure footer is visible with extra padding */
@media (max-width: 767px) {
    footer {
        display: block;
        padding-bottom: clamp(20px, 4vh, 35px);
    }
}
