:root {
    --bg-color: #0f172a;
    --canvas-bg: #1e293b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    overflow: hidden; /* Evita barras de rolagem */
}

.topbar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 15px;
    transform: translateY(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.topbar::after {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 0;
    width: 100%;
    height: 40px;
}

.topbar:hover, .topbar:focus-within {
    transform: translateY(0);
}

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

.header h1 {
    margin: 0 0 10px 0;
    font-weight: 800;
    font-size: 2.5rem;
    background: linear-gradient(to right, #3b82f6, #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header p {
    margin: 0;
    color: var(--text-muted);
}

.ui-container {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
    background: rgba(30, 41, 59, 0.5);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

input {
    padding: 12px 20px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: #0f172a;
    color: var(--text-main);
    font-family: monospace;
    font-size: 1.1rem;
    text-transform: uppercase;
    outline: none;
    transition: all 0.3s ease;
    width: 250px;
    text-align: center;
    letter-spacing: 2px;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

button {
    padding: 12px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px -1px rgba(59, 130, 246, 0.3);
}

button:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(59, 130, 246, 0.4);
}

button:active {
    transform: translateY(1px);
}

.btn-random {
    background: #8b5cf6;
    box-shadow: 0 4px 6px -1px rgba(139, 92, 246, 0.3);
}

.btn-random:hover {
    background: #7c3aed;
    box-shadow: 0 6px 8px -1px rgba(139, 92, 246, 0.4);
}

.game-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    z-index: 1;
}

body.windowed {
    justify-content: center;
}

body.windowed .game-container {
    position: relative;
    width: 800px;
    height: 600px;
    margin-top: 20px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border);
}

body.windowed .topbar {
    position: relative;
    transform: translateY(0);
    background: transparent;
    border: none;
    backdrop-filter: none;
    padding-top: 0;
    padding-bottom: 10px;
}

body.windowed .topbar::after {
    display: none;
}

canvas {
    display: block;
    background-color: var(--canvas-bg);
    width: 100%;
    height: 100%;
}

.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(4px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.overlay.show {
    opacity: 1;
    pointer-events: auto;
}

.scoreboard {
    background: rgba(15, 23, 42, 0.9);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 10px;
}

#scoreboardList li {
    padding: 5px 0;
    border-bottom: 1px dashed #334155;
    display: flex;
    justify-content: space-between;
}

#scoreboardList li:last-child {
    border-bottom: none;
}

.overlay-msg {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.overlay-sub {
    font-size: 1.2rem;
    color: var(--text-muted);
}

.msg-win {
    color: var(--success);
    text-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
}

.msg-lose {
    color: var(--danger);
    text-shadow: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* Modificações do Modo História */
.difficulty-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
    width: 100%;
}

.diff-tab {
    flex: 1;
    padding: 8px 2px;
    font-size: 0.85rem;
    background: #334155 !important;
    color: var(--text-muted) !important;
    border: 1px solid var(--border);
    border-radius: 6px;
    opacity: 0.6;
    box-shadow: none;
}

.diff-tab.active {
    opacity: 1;
    background: var(--tab-color) !important;
    color: white !important;
    border-color: white;
    transform: scale(1.05);
    z-index: 2;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

.diff-tab.active[data-diff="3"] {
    color: #000 !important;
}

.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    width: 100%;
}

.level-btn {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    background: #1e293b;
    border: 2px solid var(--border);
    border-radius: 8px;
    color: white;
    transition: all 0.2s;
    padding: 0;
}

.level-btn:not(:disabled):hover {
    background: var(--primary);
    border-color: var(--primary-hover);
    transform: scale(1.1);
}

.level-btn:disabled {
    background: #0f172a;
    color: #475569;
    border-color: #1e293b;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.level-btn.completed {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.2);
}

/* === NOVO: UI HUD === */
.how-to-play {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid #334155;
    border-radius: 8px;
    padding: 15px;
    font-size: 0.85rem;
    color: #cbd5e1;
    text-align: left;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}
.how-to-play h3 {
    margin: 0 0 10px 0;
    color: #e2e8f0;
    font-size: 1rem;
    text-align: center;
    border-bottom: 1px solid #334155;
    padding-bottom: 5px;
}
.how-to-play ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.how-to-play li {
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}
.how-to-play span {
    background: #1e293b;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #475569;
    font-family: monospace;
    color: #3b82f6;
    font-weight: bold;
}

.pause-ingame-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    background: rgba(15, 23, 42, 0.7);
    color: #cbd5e1;
    border: 1px solid #334155;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 8px;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}
.pause-ingame-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: #3b82f6;
    color: #3b82f6;
    transform: scale(1.08);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}
.pause-ingame-btn svg {
    transition: transform 0.2s ease;
}
.pause-ingame-btn:hover svg {
    transform: scale(1.1);
}


