:root {
    --bg-color: #0f172a;
    --text-color: #f8fafc;
    --border-color: #334155;
    
    --key-bg: #475569;
    --key-text: #f8fafc;
    
    --color-correct: #10b981;
    --color-present: #f59e0b;
    --color-absent: #1e293b;
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

#game-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -1px;
}

.logo span {
    color: var(--color-correct);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-color);
    cursor: pointer;
    padding: 5px;
}

/* Toast */
#toast-container {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
    pointer-events: none;
}

.toast {
    background: var(--text-color);
    color: var(--bg-color);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 14px;
    opacity: 1;
    transition: opacity 0.3s ease;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
}

/* Board */
#board-container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-grow: 1;
    overflow: hidden;
    padding: 10px;
}

#board {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-gap: 5px;
    width: 100%;
    max-width: 350px;
    aspect-ratio: 5/6;
}

.board-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-gap: 5px;
}

.tile {
    width: 100%;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
}

.tile.filled {
    border-color: #64748b;
    animation: popIn 0.1s;
}

@keyframes popIn {
    0% { transform: scale(0.8); }
    40% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.tile.correct {
    background-color: var(--color-correct);
    border-color: var(--color-correct);
    color: white;
}

.tile.present {
    background-color: var(--color-present);
    border-color: var(--color-present);
    color: white;
}

.tile.absent {
    background-color: var(--color-absent);
    border-color: var(--color-absent);
    color: white;
}

/* animations */
.tile.flip {
    animation: flipIn 0.5s ease-in forwards;
}

@keyframes flipIn {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(-90deg); }
    100% { transform: rotateX(0); }
}

.tile.bounce {
    animation: bounce 0.5s;
}

@keyframes bounce {
    0%, 20% { transform: translateY(0); }
    40% { transform: translateY(-20px); }
    50% { transform: translateY(5px); }
    60% { transform: translateY(-10px); }
    80% { transform: translateY(2px); }
    100% { transform: translateY(0); }
}

.tile.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    10%, 90% { transform: translateX(-1px); }
    20%, 80% { transform: translateX(2px); }
    30%, 50%, 70% { transform: translateX(-4px); }
    40%, 60% { transform: translateX(4px); }
}

/* Keyboard */
#keyboard-container {
    height: 200px;
    padding: 0 8px 8px;
    user-select: none;
}

.keyboard-row {
    display: flex;
    width: 100%;
    margin-bottom: 8px;
    justify-content: center;
}

.keyboard-row:last-child {
    margin-bottom: 0;
}

.key {
    font-family: inherit;
    font-weight: 600;
    font-size: 1.25rem;
    border: 0;
    padding: 0;
    margin: 0 3px;
    height: 58px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background-color: var(--key-bg);
    color: var(--key-text);
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    text-transform: uppercase;
}

.key.big-key {
    flex: 1.5;
    font-size: 0.9rem;
}

.spacer {
    flex: 0.5;
}

.key.correct {
    background-color: var(--color-correct);
    color: white;
}

.key.present {
    background-color: var(--color-present);
    color: white;
}

.key.absent {
    background-color: var(--color-absent);
    color: white;
}

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

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-color);
    padding: 30px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
}

.modal-content h2 {
    margin-bottom: 20px;
}

.stats-grid {
    display: flex;
    justify-content: space-around;
    margin-bottom: 20px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-box span {
    font-size: 2rem;
    font-weight: 800;
}

.stat-box div {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.guess-distribution {
    margin-bottom: 20px;
    text-align: left;
}

.guess-distribution h3 {
    text-align: center;
    margin-bottom: 10px;
}

.dist-row {
    display: flex;
    align-items: center;
    margin-bottom: 5px;
}

.dist-num {
    width: 20px;
    text-align: right;
    margin-right: 10px;
}

.dist-bar {
    background: var(--border-color);
    min-width: 20px;
    text-align: right;
    padding-right: 5px;
    color: white;
    font-weight: bold;
    font-size: 14px;
}

.dist-bar.highlight {
    background: var(--color-correct);
}

.next-word {
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
    margin-bottom: 15px;
    font-weight: bold;
}

.primary-btn {
    background-color: var(--color-correct);
    color: white;
    border: none;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: var(--radius-full);
    cursor: pointer;
    width: 100%;
}

.primary-btn.hidden {
    display: none;
}
