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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    overscroll-behavior: none; /* Prevent bounce-back on mobile */
}

/* Top Bar */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: rgba(26, 26, 46, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.top-bar-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
}

.beta-tag {
    font-size: 0.65rem;
    font-weight: bold;
    letter-spacing: 0.1em;
    color: #e74c3c;
    background: rgba(231, 76, 60, 0.15);
    padding: 4px 8px;
    border-radius: 4px;
    border: 1px solid rgba(231, 76, 60, 0.3);
}

.top-bar-buttons {
    display: flex;
    gap: 10px;
}

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    padding-top: 60px; /* Account for top bar */
    max-width: 500px;
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 20px;
}

.game-logo {
    max-width: 280px;
    width: 100%;
    height: auto;
}

.subtitle {
    font-size: 0.9rem;
    color: #888;
    margin-top: 8px;
}

.lie-text {
    color: #e74c3c;
    font-weight: bold;
    text-transform: uppercase;
}

/* Debug mode styles */
.debug-link {
    font-size: 0.75rem;
    color: #555;
    margin-top: 8px;
    cursor: pointer;
    text-decoration: underline;
}

.debug-link:hover {
    color: #888;
}

.debug-word {
    font-size: 1.2rem;
    color: #feb236;
    font-weight: bold;
    letter-spacing: 0.2em;
    margin-top: 5px;
    min-height: 1.5em;
}

/* Game Board */
.game-board {
    display: grid;
    grid-template-rows: repeat(10, 1fr);
    gap: 5px;
    margin-bottom: 20px;
}

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

.tile {
    width: 52px;
    height: 52px;
    border: 2px solid #3a3a5c;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.8rem;
    font-weight: bold;
    text-transform: uppercase;
    background: transparent;
    color: #fff;
    transition: transform 0.1s ease;
}

.tile.filled {
    border-color: #565676;
    animation: pop 0.1s ease;
}

.tile.correct {
    background: #538d4e;
    border-color: #538d4e;
    animation: flip 0.5s ease;
}

.tile.present {
    background: #b59f3b;
    border-color: #b59f3b;
    animation: flip 0.5s ease;
}

.tile.absent {
    background: #3a3a3c;
    border-color: #3a3a3c;
    animation: flip 0.5s ease;
}

.tile.lie {
    position: relative;
}

.tile.lie::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 8px;
    height: 8px;
    background: #e74c3c;
    border-radius: 50%;
    opacity: 0;
}

@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

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

.row.shake {
    animation: shake 0.5s ease;
}

/* Keyboard */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 500px;
    padding-bottom: 50px; /* Extra space at bottom for footer */
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
}

.key {
    padding: 15px 12px;
    min-width: 32px;
    height: 50px;
    border: none;
    border-radius: 4px;
    background: #818384;
    color: #fff;
    font-size: 0.85rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.2s ease, transform 0.1s ease;
    user-select: none;
    touch-action: manipulation; /* Prevent double-tap zoom on mobile */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
}

.key:hover {
    opacity: 0.9;
}

.key:active {
    transform: scale(0.95);
}

.key.wide {
    min-width: 60px;
    font-size: 0.75rem;
}

.key.correct {
    background: #538d4e;
}

.key.present {
    background: #b59f3b;
}

.key.absent {
    background: #3a3a3c;
}

/* Message */
.message {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #000;
    padding: 12px 20px;
    border-radius: 4px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 100;
}

.message.show {
    opacity: 1;
}

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

.modal.show {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border: 1px solid #3a3a5c;
    border-radius: 8px;
    padding: 30px;
    max-width: 400px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #fff;
}

.modal-content h3 {
    margin: 15px 0 10px;
    color: #feb236;
}

.modal-content p {
    margin-bottom: 10px;
    line-height: 1.5;
    color: #ccc;
}

.modal-content ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.modal-content li {
    margin-bottom: 8px;
    color: #ccc;
}

.modal-content hr {
    border: none;
    border-top: 1px solid #3a3a5c;
    margin: 20px 0;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #888;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: #fff;
}

.example {
    display: flex;
    gap: 5px;
    margin: 10px 0;
}

.example .tile {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
}

.green-text { color: #538d4e; }
.yellow-text { color: #b59f3b; }
.gray-text { color: #818384; }

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.results-btn {
    background: #538d4e;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease;
}

.results-btn:hover {
    background: #4a7c43;
}

.practice-btn {
    background: #6b5b95;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s ease;
}

.practice-btn:hover {
    background: #5a4a84;
}

#next-word-timer {
    color: #888;
    font-size: 0.9rem;
}

/* Top Bar Buttons */
.stats-btn,
.results-header-btn,
.help-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    background: transparent;
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stats-btn:hover,
.help-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: #fff;
}

.results-header-btn {
    border-color: #538d4e;
}

.results-header-btn:hover {
    background: rgba(83, 141, 78, 0.3);
}

/* Statistics Styles */
.stats-summary,
.mini-stats {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 20px 0;
}

.stat-item {
    text-align: center;
    min-width: 60px;
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
}

.stat-label {
    font-size: 0.75rem;
    color: #888;
    text-transform: uppercase;
}

.mini-stats .stat-item {
    min-width: 50px;
}

.mini-stats .stat-value {
    font-size: 1.5rem;
}

.mini-stats .stat-label {
    font-size: 0.65rem;
}

/* Histogram */
.histogram {
    margin-top: 15px;
}

.histogram-row {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
}

.histogram-label {
    width: 20px;
    text-align: right;
    font-size: 0.85rem;
    color: #888;
    margin-right: 8px;
}

.histogram-bar-container {
    flex: 1;
}

.histogram-bar {
    background: #538d4e;
    min-width: 24px;
    padding: 2px 8px;
    border-radius: 2px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}

.histogram-count {
    font-size: 0.8rem;
    font-weight: bold;
    color: #fff;
}

#stats-content h3 {
    color: #fff;
    margin-top: 20px;
    margin-bottom: 10px;
    font-size: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Footer */
.site-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #666;
    background: rgba(26, 26, 46, 0.9);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.footer-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.site-footer a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s ease;
}

.site-footer a:hover {
    color: #fff;
}

.footer-divider {
    margin: 0 8px;
    color: #444;
}

/* Discord Link in Modal */
.discord-text {
    display: block;
    margin-top: 15px;
    font-size: 0.85rem;
    color: #888;
}

.discord-link {
    color: #7289da;
    text-decoration: none;
    transition: color 0.2s ease;
}

.discord-link:hover {
    color: #99aab5;
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 400px) {
    .tile {
        width: 45px;
        height: 45px;
        font-size: 1.5rem;
    }

    .key {
        padding: 12px 8px;
        min-width: 26px;
        height: 45px;
        font-size: 0.75rem;
    }

    .key.wide {
        min-width: 50px;
    }

    .game-logo {
        max-width: 220px;
    }

    .keyboard {
        padding-bottom: 70px; /* Extra padding on small screens for footer */
    }
}

/* Larger mobile devices */
@media (max-width: 600px) and (min-width: 401px) {
    .keyboard {
        padding-bottom: 60px;
    }
}
