@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ============================================
   GLOBAL STYLES & VARIABLES
   ============================================ */

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

:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #1a1f3a;
    --neon-cyan: #00f0ff;
    --neon-pink: #ff00ea;
    --neon-yellow: #ffff00;
    --neon-green: #00ff41;
    --text-primary: #fff;
    --text-secondary: #a0a0ff;
    --border-color: #4a4fff;
}

body {
    font-family: 'Press Start 2P', cursive;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, var(--bg-primary) 100%) fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    background: repeating-linear-gradient(0deg, rgba(0,0,0,.15) 0, transparent 1px, transparent 2px, rgba(0,0,0,.15) 3px);
    pointer-events: none;
    z-index: 1000;
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
    background: rgba(26, 31, 58, 0.95);
    border-bottom: 3px solid var(--neon-cyan);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-logo {
    font-size: 1.5rem;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan), 0 0 30px var(--neon-cyan);
    letter-spacing: 0.2em;
    order: 1;
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    order: 2;
    flex: 1;
    justify-content: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.7rem;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border: 2px solid transparent;
}

.nav-link:hover {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
}

.nav-link.active {
    color: var(--neon-yellow);
    border-color: var(--neon-yellow);
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.4);
    text-shadow: 0 0 10px var(--neon-yellow);
}

.user-info {
    color: var(--neon-green);
    font-size: 0.6rem;
    text-shadow: 0 0 10px var(--neon-green);
    order: 3;
}

/* ============================================
   BUTTONS
   ============================================ */

.arcade-button {
    font-family: 'Press Start 2P', cursive;
    font-size: 0.8rem;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    color: var(--neon-cyan);
    border: 3px solid var(--neon-cyan);
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3), inset 0 0 10px rgba(0, 240, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.arcade-button::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(0, 240, 255, 0.1), transparent);
    transform: rotate(45deg);
    transition: all 0.6s ease;
}

.arcade-button:hover {
    background: var(--neon-cyan);
    color: var(--bg-primary);
    box-shadow: 0 0 20px rgba(0, 240, 255, 0.6), inset 0 0 20px rgba(0, 240, 255, 0.2);
    transform: translateY(-2px);
}

.arcade-button:hover::before {
    left: 100%;
}

.arcade-button:active {
    transform: translateY(0);
    box-shadow: 0 0 10px rgba(0, 240, 255, 0.3), inset 0 0 10px rgba(0, 240, 255, 0.2);
}

.how-to-play-btn {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 99;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.65rem;
    padding: 0.8rem 1.4rem;
    background: var(--bg-secondary);
    color: var(--neon-pink);
    border: 2px solid var(--neon-pink);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    box-shadow: 0 0 10px rgba(255, 0, 234, 0.3), inset 0 0 10px rgba(255, 0, 234, 0.1);
    display: inline-block;
    text-align: center;
}

.how-to-play-btn:hover {
    background: var(--neon-pink);
    color: var(--bg-primary);
    box-shadow: 0 0 20px rgba(255, 0, 234, 0.6), inset 0 0 20px rgba(255, 0, 234, 0.2);
    transform: translateY(-2px);
}

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

/* ============================================
   FORMS
   ============================================ */

.form-container {
    max-width: 600px;
    margin: 3rem auto;
    padding: 2rem;
}

.form-panel, .rankings-panel {
    background: rgba(26, 31, 58, 0.95);
    border: 3px solid var(--border-color);
    border-radius: 15px;
    padding: 3rem;
    box-shadow: 0 0 30px rgba(74, 79, 255, 0.4), inset 0 0 30px rgba(74, 79, 255, 0.1);
    backdrop-filter: blur(10px);
}

.login-panel {
    max-width: 500px;
    margin: 0 auto;
}

.form-title, .rankings-title {
    font-size: 2rem;
    text-align: center;
    margin-bottom: 1rem;
    letter-spacing: 0.2em;
}

.form-title {
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan), 0 0 20px var(--neon-cyan);
}

.rankings-title {
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow), 0 0 20px var(--neon-yellow);
}

.form-subtitle, .rankings-subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    font-size: 0.7rem;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: 0.1em;
}

.form-input, .form-select {
    width: 100%;
    padding: 1rem;
    font-family: 'Press Start 2P', cursive;
    font-size: 0.7rem;
    background: rgba(10, 14, 39, 0.8);
    border: 2px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    box-shadow: inset 0 0 10px rgba(74, 79, 255, 0.1);
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4), inset 0 0 15px rgba(0, 240, 255, 0.1);
}

.form-input.error {
    border-color: var(--neon-pink);
    box-shadow: 0 0 10px rgba(255, 0, 234, 0.4);
}

.error-message {
    display: block;
    font-size: 0.5rem;
    color: #fff;
    background: rgba(255, 0, 234, 0.8);
    padding: 0.3rem 0.5rem;
    border-radius: 3px;
    margin-top: 0.5rem;
    min-height: 0.6rem;
    text-shadow: none;
    border: 1px solid var(--neon-pink);
    box-shadow: 0 0 10px rgba(255, 0, 234, 0.5);
}

.error-message:empty {
    display: none;
}

.form-hint {
    display: block;
    font-size: 0.5rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
    opacity: 0.7;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.avatar-option {
    cursor: pointer;
}

.avatar-option input[type="radio"] {
    display: none;
}

.avatar-box {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background: rgba(10, 14, 39, 0.8);
    transition: all 0.3s ease;
    cursor: pointer;
}

.avatar-option input[type="radio"]:checked + .avatar-box {
    border-color: var(--neon-yellow);
    box-shadow: 0 0 15px rgba(255, 255, 0, 0.6);
    transform: scale(1.1);
}

.avatar-box:hover {
    transform: scale(1.05);
}

.avatar-i { color: #00f0ff; text-shadow: 0 0 10px #00f0ff; }
.avatar-o { color: #ffff00; text-shadow: 0 0 10px #ffff00; }
.avatar-t { color: #ff00ea; text-shadow: 0 0 10px #ff00ea; }
.avatar-s { color: #00ff41; text-shadow: 0 0 10px #00ff41; }
.avatar-z { color: #f00; text-shadow: 0 0 10px #f00; }
.avatar-j { color: #06f; text-shadow: 0 0 10px #06f; }
.avatar-l { color: #ff6b00; text-shadow: 0 0 10px #ff6b00; }

.submit-button {
    width: 100%;
    margin-top: 2rem;
}

.message-box {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: 5px;
    font-size: 0.6rem;
    text-align: center;
    line-height: 1.5;
}

.success-message {
    background: rgba(0, 255, 65, 0.1);
    border: 2px solid var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 15px rgba(0, 255, 65, 0.3);
}

.error-message-box {
    background: rgba(255, 0, 234, 0.8);
    border: 2px solid var(--neon-pink);
    color: #fff;
    box-shadow: 0 0 15px rgba(255, 0, 234, 0.5);
    text-shadow: none;
}

.hidden {
    display: none;
}

.form-footer {
    margin-top: 2rem;
    text-align: center;
    font-size: 0.6rem;
    color: var(--text-secondary);
}

.form-link {
    color: var(--neon-cyan);
    text-decoration: none;
    transition: all 0.3s ease;
}

.form-link:hover {
    text-shadow: 0 0 10px var(--neon-cyan);
}

/* ============================================
   GAME CONTAINER & PANELS
   ============================================ */

.game-container {
    max-width: 1400px;
    height: calc(100vh - 100px);
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 1.5rem;
    flex-wrap: nowrap;
    overflow: hidden;
}

.side-panel {
    background: rgba(26, 31, 58, 0.9);
    border: 3px solid var(--border-color);
    border-radius: 10px;
    padding: 1rem;
    box-shadow: 0 0 20px rgba(74, 79, 255, 0.3), inset 0 0 20px rgba(74, 79, 255, 0.1);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    height: fit-content;
    max-height: calc(100vh - 120px);
}

.left-panel, .right-panel {
    min-width: 200px;
    max-width: 220px;
}

.user-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    background: rgba(10, 14, 39, 0.8);
    border: 2px solid var(--neon-cyan);
    border-radius: 8px;
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4), inset 0 0 15px rgba(0, 240, 255, 0.1);
}

.user-initial {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--neon-pink);
    background: rgba(26, 31, 58, 0.9);
    border: 3px solid var(--neon-pink);
    border-radius: 50%;
    text-shadow: 0 0 20px var(--neon-pink);
    box-shadow: 0 0 20px rgba(255, 0, 234, 0.4), inset 0 0 10px rgba(255, 0, 234, 0.2);
    margin-bottom: 0.6rem;
}

.user-name {
    font-size: 0.8rem;
    color: var(--neon-cyan);
    text-align: center;
    text-shadow: 0 0 10px var(--neon-cyan);
    letter-spacing: 0.05em;
    word-break: break-word;
    max-width: 100%;
}

.panel-header {
    font-size: 1rem;
    color: var(--neon-yellow);
    text-align: center;
    margin-bottom: 1rem;
    text-shadow: 0 0 10px var(--neon-yellow);
    letter-spacing: 0.2em;
}

canvas {
    display: block;
    margin: 0 auto;
    background: rgba(10, 14, 39, 0.8);
    border: 2px solid var(--neon-cyan);
    box-shadow: 0 0 15px rgba(0, 240, 255, 0.4), inset 0 0 15px rgba(0, 240, 255, 0.1);
    border-radius: 5px;
}

#holdCanvas, #nextCanvas {
    width: 100px;
    height: 100px;
}

#gameCanvas {
    width: 280px;
    height: 560px;
}

.center-panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
}

.game-wrapper {
    position: relative;
}

.game-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10, 14, 39, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 5px;
    z-index: 10;
}

.game-overlay.hidden {
    display: none;
}

.overlay-content {
    text-align: center;
    padding: 2rem;
}

#overlayTitle {
    font-size: 1.5rem;
    color: var(--neon-pink);
    text-shadow: 0 0 20px var(--neon-pink);
    margin-bottom: 1rem;
}

#overlayMessage {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

#finalScore {
    color: var(--neon-yellow);
    text-shadow: 0 0 10px var(--neon-yellow);
}

.overlay-content .arcade-button {
    margin: 0.5rem;
    font-size: 0.7rem;
    padding: 0.8rem 1.5rem;
}

.timer-display {
    background: rgba(26, 31, 58, 0.9);
    border: 3px solid var(--neon-green);
    border-radius: 10px;
    padding: 0.8rem;
    text-align: center;
    margin-top: 1rem;
    box-shadow: 0 0 20px rgba(0, 255, 65, 0.3), inset 0 0 20px rgba(0, 255, 65, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.timer-label, .score-label {
    font-size: 0.7rem;
    text-align: center;
    letter-spacing: 0.1em;
}

.timer-label {
    color: var(--neon-green);
    margin: 0 0 0.5rem 0;
}

.score-label {
    color: var(--text-secondary);
}

.timer-value, .score-value {
    font-size: 1rem;
    text-align: center;
    margin: 0;
}

.timer-value {
    color: var(--neon-green);
    text-shadow: 0 0 15px var(--neon-green);
    font-variant-numeric: tabular-nums;
}

.score-value {
    color: var(--neon-cyan);
    text-shadow: 0 0 15px var(--neon-cyan);
    margin-bottom: 0.5rem;
}

#highScore {
    color: var(--neon-pink);
    text-shadow: 0 0 15px var(--neon-pink);
}

.controls-section {
    margin-top: 0.8rem;
}

.controls-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.controls-list .control-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.controls-list .key-icon {
    font-size: 0.7rem;
    color: var(--neon-yellow);
    background: rgba(10, 14, 39, 0.8);
    padding: 0.4rem 0.6rem;
    border: 2px solid var(--neon-yellow);
    border-radius: 5px;
    box-shadow: 0 0 10px rgba(255, 255, 0, 0.3);
    min-width: 50px;
    text-align: center;
}

.controls-list .control-item span:last-child {
    font-size: 0.6rem;
    color: var(--text-secondary);
    flex: 1;
}

.score-section {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

/* ============================================
   RANKINGS
   ============================================ */

.rankings-container {
    max-width: 1200px;
    margin: 3rem auto;
    padding: 2rem;
}

.table-wrapper {
    overflow-x: auto;
    margin-bottom: 2rem;
}

.rankings-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}

.rankings-table thead {
    background: rgba(74, 79, 255, 0.2);
    border-bottom: 2px solid var(--neon-cyan);
}

.rankings-table th {
    padding: 1rem;
    text-align: left;
    color: var(--neon-cyan);
    text-shadow: 0 0 10px var(--neon-cyan);
    letter-spacing: 0.1em;
}

.rankings-table tbody tr {
    border-bottom: 1px solid rgba(74, 79, 255, 0.3);
    transition: all 0.3s ease;
}

.rankings-table tbody tr:hover {
    background: rgba(0, 240, 255, 0.1);
    box-shadow: inset 0 0 20px rgba(0, 240, 255, 0.2);
}

.rankings-table tbody tr.current-user {
    background: rgba(0, 255, 65, 0.1);
    border: 2px solid var(--neon-green);
}

.rankings-table tbody tr.current-user td {
    color: var(--neon-green);
    text-shadow: 0 0 5px var(--neon-green);
}

.rankings-table td {
    padding: 1rem;
    color: var(--text-primary);
}

.rankings-table td:first-child {
    font-size: 1rem;
    color: var(--neon-pink);
    text-shadow: 0 0 10px var(--neon-pink);
    font-weight: bold;
}

.rankings-table td:nth-child(3) {
    color: var(--neon-yellow);
    text-shadow: 0 0 5px var(--neon-yellow);
}

.no-data {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
    font-size: 0.7rem;
}

.avatar-display {
    display: inline-block;
    width: 30px;
    height: 30px;
    line-height: 30px;
    text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background: rgba(10, 14, 39, 0.8);
    font-size: 0.8rem;
}

.rankings-actions {
    text-align: center;
    margin-top: 2rem;
}

.rank-medal {
    font-size: 1.2rem;
}

.rank-1 .rank-medal {
    color: #ffd700;
    text-shadow: 0 0 15px #ffd700;
}

.rank-2 .rank-medal {
    color: #c0c0c0;
    text-shadow: 0 0 15px #c0c0c0;
}

.rank-3 .rank-medal {
    color: #cd7f32;
    text-shadow: 0 0 15px #cd7f32;
}

/* ============================================
   MEDIA QUERIES
   ============================================ */

@media (max-width: 1200px) {
    .game-container {
        flex-direction: column;
        align-items: center;
        height: auto;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-menu {
        gap: 1rem;
    }

    .nav-link {
        font-size: 0.6rem;
        padding: 0.4rem 0.8rem;
    }

    .nav-logo {
        font-size: 1.2rem;
    }

    .arcade-button {
        font-size: 0.7rem;
        padding: 0.8rem 1.5rem;
    }

    .how-to-play-btn {
        font-size: 0.55rem;
        padding: 0.7rem 1.1rem;
        top: 70px;
        right: 15px;
    }

    .form-container, .rankings-container {
        padding: 1rem;
        margin: 2rem auto;
    }

    .form-panel, .rankings-panel {
        padding: 2rem;
    }

    .form-title, .rankings-title {
        font-size: 1.5rem;
    }

    .form-subtitle, .rankings-subtitle {
        font-size: 0.6rem;
    }

    .form-label {
        font-size: 0.6rem;
    }

    .form-input {
        font-size: 0.6rem;
        padding: 0.8rem;
    }

    .game-container {
        padding: 1rem;
    }

    #gameCanvas {
        width: 250px;
        height: 500px;
    }

    #holdCanvas, #nextCanvas {
        width: 100px;
        height: 100px;
    }

    .panel-header {
        font-size: 0.8rem;
    }

    .score-label, .timer-label {
        font-size: 0.6rem;
    }

    .score-value, .timer-value {
        font-size: 1rem;
    }

    .controls-list .key-icon {
        font-size: 0.6rem;
        padding: 0.3rem 0.5rem;
        min-width: 45px;
    }

    .controls-list .control-item span:last-child {
        font-size: 0.55rem;
    }

    .rankings-table {
        font-size: 0.6rem;
    }

    .rankings-table th, .rankings-table td {
        padding: 0.7rem 0.5rem;
    }
}

@media (max-width: 480px) {
    .nav-logo {
        font-size: 1rem;
    }

    .nav-link {
        font-size: 0.5rem;
        padding: 0.3rem 0.6rem;
    }

    .arcade-button {
        font-size: 0.6rem;
        padding: 0.7rem 1.2rem;
    }

    .how-to-play-btn {
        font-size: 0.5rem;
        padding: 0.6rem 0.9rem;
        top: 65px;
        right: 10px;
    }

    .form-panel, .rankings-panel {
        padding: 1.5rem;
    }

    .form-title, .rankings-title {
        font-size: 1.2rem;
    }

    .avatar-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.5rem;
    }

    .avatar-box {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    #gameCanvas {
        width: 200px;
        height: 400px;
    }

    #holdCanvas, #nextCanvas {
        width: 80px;
        height: 80px;
    }

    .side-panel {
        padding: 1rem;
    }

    #overlayTitle {
        font-size: 1rem;
    }

    #overlayMessage {
        font-size: 0.6rem;
    }

    .rankings-table {
        font-size: 0.5rem;
    }

    .rankings-table th, .rankings-table td {
        padding: 0.5rem 0.3rem;
    }

    .avatar-display {
        width: 25px;
        height: 25px;
        line-height: 25px;
        font-size: 0.6rem;
    }
}
