:root {
    --bg-color: #0a0a0c;
    --text-color: #f0f0f0;
    --primary-color: #00f2ff;
    --secondary-color: #ff007a;
    --accent-color: #7000ff;
    --overlay-bg: rgba(10, 10, 12, 0.95);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow-x: hidden;
    line-height: 1.6;
}

#main-header {
    background: rgba(18, 18, 22, 0.8);
    backdrop-filter: blur(10px);
    padding: 0.8rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

#main-header h1 {
    margin: 0;
    font-size: 1.2rem;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
}

.lang-switcher {
    display: flex;
    gap: 5px;
}

.lang-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #666;
    padding: 4px 8px;
    font-size: 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 700;
    box-shadow: none;
}

.lang-btn.active {
    background: var(--primary-color);
    color: #000;
    border-color: var(--primary-color);
}

main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 800px;
    aspect-ratio: 16 / 9;
    margin: 0 auto 2rem;
    background-color: #000;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 242, 255, 0.05);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

#ui-layer {
    position: absolute;
    top: 20px;
    left: 20px;
    pointer-events: none;
    z-index: 10;
}

#score-display {
    font-size: 2.2rem;
    font-weight: 800;
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}

#high-score-display {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

#overlay, #start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay-bg);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    backdrop-filter: blur(15px);
}

.hidden {
    display: none !important;
}

/* Fix: Make Modals Responsive and fit content */
.modal, #game-over-modal {
    text-align: center;
    padding: 25px;
    border-radius: 28px;
    background: rgba(20, 20, 25, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.6);
    width: 95%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    max-height: 95%; /* Increase to fit more */
    overflow: hidden;
}

.main-start-modal {
    padding: 35px;
}

.game-logo h1 {
    font-size: 3rem;
    margin-bottom: 5px;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #fff 30%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 25px;
}

.quick-guide {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 30px;
    text-align: left;
    background: rgba(0, 0, 0, 0.3);
    padding: 18px;
    border-radius: 20px;
}

.guide-item {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.95rem;
    color: #bbb;
}

.glow-button {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    border-radius: 16px;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
    transition: all 0.3s;
    color: white;
    font-weight: 800;
}

#ranking-container {
    margin: 10px 0 15px 0;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1; /* Allow to expand */
    min-height: 200px;
}

.tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.tab-btn {
    flex: 1;
    padding: 10px 2px;
    background: none;
    font-size: 0.7rem;
    font-weight: 800;
    color: #555;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.tab-btn.active {
    color: var(--primary-color);
    background: rgba(0, 242, 255, 0.08);
}

.scrollable {
    overflow-y: auto;
    padding: 15px;
    flex: 1;
}

.scrollable::-webkit-scrollbar {
    width: 6px;
}

.scrollable::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

#ranking-list li {
    font-size: 0.9rem;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
}

#ranking-list li .rank {
    width: 30px;
    font-weight: 800;
    color: var(--primary-color);
}

#ranking-list li .name {
    flex: 1;
    text-align: left;
    color: #ccc;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#result-text {
    margin-bottom: 15px;
}

#result-text p {
    font-size: 1.1rem;
    margin-bottom: 5px;
}

.highlight {
    color: var(--primary-color);
    font-weight: 800;
}

#name-entry-container {
    margin-bottom: 10px;
    display: flex;
    gap: 8px;
}

#player-name {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 10px 15px;
    color: white;
    font-size: 0.9rem;
    outline: none;
}

#player-name:focus {
    border-color: var(--primary-color);
}

#save-score-btn {
    padding: 10px 15px;
    font-size: 0.85rem;
}

#restart-btn {
    width: 100%;
}

#main-footer {
    background: #050507;
    padding: 3rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 3rem;
    text-align: center;
}

.footer-nav {
    margin-top: 1.2rem;
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.footer-nav a {
    color: #444;
    text-decoration: none;
    font-size: 0.8rem;
    transition: color 0.2s;
}

.footer-nav a:hover {
    color: var(--primary-color);
}

#policy-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#policy-modal {
    background: #121216;
    width: 90%;
    max-width: 600px;
    padding: 2.5rem 1.5rem;
    border-radius: 24px;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

#close-policy-btn {
    position: absolute;
    top: 1rem; right: 1rem;
    background: none; border: none;
    color: #666; font-size: 1.8rem;
    cursor: pointer;
}

@keyframes pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.2; }
    50% { transform: translate(-50%, -50%) scale(1.15); opacity: 0.3; }
}

.logo-circle {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 140px; height: 140px;
    background: radial-gradient(circle, var(--primary-color) 0%, transparent 70%);
    opacity: 0.2;
    border-radius: 50%;
    animation: pulse 2.5s infinite ease-in-out;
}
