@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

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

:root {
    --bg: #0a0a0f;
    --bg-card: rgba(255, 255, 255, 0.04);
    --border: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.15);
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --success-glow: rgba(34, 197, 94, 0.25);
    --error: #ef4444;
    --error-glow: rgba(239, 68, 68, 0.25);
    --warning: #f59e0b;
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 80% 100%, rgba(139, 92, 246, 0.05) 0%, transparent 50%);
}

.game-container {
    width: 100%;
    max-width: 780px;
    position: relative;
}

/* Screens */
.screen {
    display: none;
}

.screen.active {
    display: block;
}

/* ================================
   CARD BASE
   ================================ */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
}

/* ================================
   MENU SCREEN
   ================================ */
#menuScreen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 550px;
}

.menu-card {
    text-align: center;
    width: 100%;
    max-width: 460px;
    animation: fadeUp 0.5s ease-out;
}

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.menu-icon {
    font-size: 56px;
    margin-bottom: 12px;
    display: block;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

.menu-card h1 {
    font-size: 36px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-light), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.menu-subtitle {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 36px;
    font-weight: 400;
}

/* Difficulty selection */
.difficulty-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 12px;
}

.difficulty-select {
    display: flex;
    gap: 8px;
    margin-bottom: 28px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 5px;
}

.diff-btn {
    flex: 1;
    padding: 10px 8px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.diff-btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);
}

.diff-btn.selected {
    color: white;
    background: var(--accent);
    box-shadow: 0 4px 12px var(--accent-glow);
}

/* Menu buttons */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-play {
    padding: 14px;
    font-family: var(--font);
    font-size: 15px;
    font-weight: 700;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 20px var(--accent-glow);
}

.btn-play:hover {
    background: #4f46e5;
    box-shadow: 0 6px 28px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-play:active {
    transform: translateY(0);
}

.btn-secondary {
    padding: 12px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    border-color: var(--border-hover);
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

/* ================================
   GAME SCREEN
   ================================ */
#gameScreen.active {
    display: flex;
    flex-direction: column;
    min-height: 600px;
    background: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.header-stats {
    display: flex;
    gap: 28px;
}

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

.stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.stat-value.combo {
    color: var(--accent-light);
    font-size: 18px;
    transition: all 0.2s;
}

.stat-value.combo.pulse {
    animation: comboPulse 0.4s ease-out;
}

@keyframes comboPulse {
    0% { transform: scale(1.4); }
    100% { transform: scale(1); }
}

.header-lives {
    font-size: 16px;
    letter-spacing: 2px;
    transition: all 0.3s;
}

.btn-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-size: 16px;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: var(--error);
    border-color: var(--error);
}

/* Game area */
.game-area {
    flex: 1;
    position: relative;
    min-height: 400px;
    background: #0d0d18;
    overflow: hidden;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Input area */
.input-area {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    position: relative;
}

#typingInput {
    width: 100%;
    padding: 14px 18px;
    font-family: var(--font);
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: all 0.2s;
    letter-spacing: 0.5px;
}

#typingInput::placeholder {
    color: rgba(148, 163, 184, 0.4);
    font-weight: 400;
}

#typingInput:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

#typingInput.error {
    border-color: var(--error);
    box-shadow: 0 0 0 3px var(--error-glow);
    animation: shake 0.4s ease-out;
}

#typingInput.success {
    border-color: var(--success);
    box-shadow: 0 0 0 3px var(--success-glow);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

.input-hint {
    position: absolute;
    right: 36px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    color: var(--text-dim);
    pointer-events: none;
}

/* ================================
   GAME OVER SCREEN
   ================================ */
#gameoverScreen.active {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 500px;
}

.gameover-card {
    text-align: center;
    width: 100%;
    max-width: 420px;
    animation: fadeUp 0.4s ease-out;
}

.gameover-card h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 24px;
    background: linear-gradient(135deg, var(--error), #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.final-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.final-stat {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 12px;
    text-align: center;
}

.final-stat span {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
}

.final-stat b {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.new-records {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    padding: 14px;
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-light);
}

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

.gameover-buttons .btn-play {
    flex: 1;
}

.gameover-buttons .btn-secondary {
    flex: 1;
}

/* ================================
   MODALS
   ================================ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
}

.overlay.active {
    display: block;
}

.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 460px;
    background: #14141f;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    animation: fadeUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-size: 18px;
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.modal-body {
    padding: 24px;
}

/* Records */
.records-table {
    width: 100%;
    border-collapse: collapse;
}

.records-table th {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 10px 8px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.records-table th:first-child {
    text-align: left;
}

.records-table td {
    padding: 12px 8px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.records-table td:first-child {
    text-align: left;
    font-weight: 600;
    color: var(--accent-light);
}

.records-table .record-zero {
    color: rgba(148, 163, 184, 0.3);
}

.reset-records {
    width: 100%;
    margin-top: 20px;
    padding: 12px;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    color: var(--error);
    background: transparent;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.reset-records:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* Help */
.help-step {
    display: flex;
    gap: 14px;
    padding: 12px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.02);
    border-radius: var(--radius-sm);
}

.step-number {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: white;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

.step-content h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 3px;
}

.step-content p {
    font-size: 12px;
    color: var(--text-dim);
    line-height: 1.6;
}

.dica-box {
    margin-top: 16px;
    padding: 14px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.15);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--accent-light);
    line-height: 1.6;
}

.dica-box strong {
    color: white;
}

kbd, .kbd {
    display: inline-block;
    padding: 3px 7px;
    font-family: var(--font);
    font-size: 11px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    color: var(--text);
}

/* ================================
   RESPONSIVE
   ================================ */
@media (max-width: 600px) {
    body { padding: 8px; }

    .card { padding: 24px; }

    .menu-card h1 { font-size: 28px; }
    .menu-icon { font-size: 40px; }

    .game-header { padding: 12px 14px; }
    .header-stats { gap: 16px; }
    .stat-value { font-size: 16px; }

    .game-area { min-height: 300px; }

    .input-area { padding: 12px 14px; }
    #typingInput { font-size: 16px; padding: 12px 14px; }

    .final-stats { grid-template-columns: 1fr 1fr; }
    .final-stat b { font-size: 18px; }

    .difficulty-select { flex-direction: column; gap: 4px; }
}
