/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0a2e 100%);
    color: #fff;
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#gameContainer {
    width: 1920px;
    height: 1080px;
    max-width: 100vw;
    max-height: 100vh;
    position: relative;
    background: #000;
    border: 4px solid #00ffff;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.5),
                inset 0 0 100px rgba(0, 255, 255, 0.1);
}

/* Screen Management */
.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.screen.active {
    display: flex;
}

/* Start Screen */
#startScreen {
    background: radial-gradient(circle at center, #1a0a2e 0%, #0a0a0a 100%);
}

.title-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.game-title {
    font-size: 120px;
    font-weight: bold;
    color: #00ffff;
    text-shadow: 
        0 0 10px #00ffff,
        0 0 20px #00ffff,
        0 0 30px #00ffff,
        0 0 40px #ff00ff,
        0 0 70px #ff00ff,
        0 0 80px #ff00ff;
    letter-spacing: 20px;
    animation: titlePulse 2s ease-in-out infinite;
    margin-bottom: 30px;
}

@keyframes titlePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.bird-animation {
    width: 200px;
    height: 100px;
    position: relative;
    animation: birdFly 3s linear infinite;
}

@keyframes birdFly {
    0% { transform: translateX(-300px); opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { transform: translateX(300px); opacity: 0; }
}

.menu-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-top: -300px;
}

.press-start {
    font-size: 32px;
    color: #ffff00;
    margin-bottom: 40px;
    animation: blink 1s step-start infinite;
}

@keyframes blink {
    50% { opacity: 0; }
}

.main-menu {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.menu-btn {
    font-family: 'Courier New', monospace;
    font-size: 28px;
    padding: 15px 40px;
    background: transparent;
    color: #fff;
    border: 3px solid #00ffff;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 400px;
    text-align: center;
}

.menu-btn:hover,
.menu-btn.selected {
    background: #00ffff;
    color: #000;
    box-shadow: 0 0 20px #00ffff;
    transform: scale(1.05);
}

.menu-btn:active {
    transform: scale(0.95);
}



/* Help Screen */
#helpScreen {
    background: radial-gradient(circle at center, #1a0a2e 0%, #0a0a0a 100%);
}

#helpScreen h2 {
    font-size: 64px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
    margin-bottom: 40px;
}

.help-content {
    max-width: 1200px;
    overflow-y: auto;
    padding: 20px;
    margin-bottom: 30px;
    max-height: 700px;
}

.help-content section {
    margin-bottom: 40px;
}

.help-content h3 {
    color: #ff00ff;
    font-size: 32px;
    margin-bottom: 15px;
    text-shadow: 0 0 10px #ff00ff;
}

.help-content p,
.help-content ul {
    font-size: 20px;
    line-height: 1.8;
    color: #ccc;
}

.help-content ul {
    list-style: none;
    padding-left: 20px;
}

.help-content li:before {
    content: "▶ ";
    color: #00ffff;
    margin-right: 10px;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    margin-top: 20px;
}

.player-controls {
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid #00ffff;
    padding: 25px;
    border-radius: 10px;
}

.player1-controls {
    border-color: #00ffff;
    background: rgba(0, 255, 255, 0.1);
}

.player2-controls {
    border-color: #ff0000;
    background: rgba(255, 0, 0, 0.1);
}

.player-controls h4 {
    color: #00ffff;
    font-size: 24px;
    margin-bottom: 15px;
    text-align: center;
}

.player2-controls h4 {
    color: #ff0000;
}

.player-controls ul {
    padding-left: 0;
}

.player-controls li {
    margin-bottom: 8px;
}

.player-controls strong {
    color: #ffff00;
    font-size: 22px;
}

.goal-location {
    margin-top: 15px;
    font-size: 18px;
    text-align: center;
    color: #ffff00;
    font-weight: bold;
    background: rgba(255, 255, 0, 0.1);
    padding: 10px;
    border-radius: 5px;
}

.universal-controls {
    margin-top: 30px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid #888;
    padding: 20px;
    border-radius: 10px;
}

.universal-controls h4 {
    color: #ffff00;
    font-size: 22px;
    margin-bottom: 15px;
    text-align: center;
}

.universal-controls ul {
    padding-left: 0;
    list-style: none;
    display: flex;
    justify-content: space-around;
}

.universal-controls strong {
    color: #ffff00;
    font-size: 20px;
}

.mechanics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
    margin-top: 20px;
}

.mechanic-item {
    background: rgba(255, 0, 255, 0.1);
    border: 2px solid #ff00ff;
    padding: 20px;
    border-radius: 10px;
}

.mechanic-item h4 {
    color: #ff00ff;
    font-size: 22px;
    margin-bottom: 10px;
}

.mechanic-item p {
    font-size: 18px;
    line-height: 1.6;
}

/* Settings Screen */
#settingsScreen {
    background: radial-gradient(circle at center, #1a0a2e 0%, #0a0a0a 100%);
}

#settingsScreen h2 {
    font-size: 64px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
    margin-bottom: 40px;
}

.settings-content {
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid #00ffff;
    padding: 40px;
    min-width: 600px;
    margin-bottom: 30px;
}

.setting-item {
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.setting-item label {
    font-size: 24px;
    color: #fff;
    min-width: 200px;
}

.setting-item input[type="range"] {
    flex: 1;
    height: 8px;
    background: #333;
    border-radius: 5px;
    outline: none;
}

.setting-item input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    background: #00ffff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px #00ffff;
}

.setting-item select {
    font-family: 'Courier New', monospace;
    font-size: 20px;
    padding: 10px;
    background: #000;
    color: #00ffff;
    border: 2px solid #00ffff;
    border-radius: 5px;
}

.setting-item input[type="checkbox"] {
    width: 24px;
    height: 24px;
    cursor: pointer;
}

.setting-item span {
    color: #00ffff;
    font-size: 20px;
    min-width: 60px;
}

/* High Scores Screen */
#highScoresScreen {
    background: radial-gradient(circle at center, #1a0a2e 0%, #0a0a0a 100%);
    overflow-y: auto;
}

.high-scores-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 60px 40px;
}

#highScoresScreen h2 {
    font-size: 72px;
    color: #ffff00;
    text-shadow: 
        0 0 10px #ffff00,
        0 0 20px #ffff00,
        0 0 30px #ff00ff,
        0 0 40px #ff00ff;
    margin-bottom: 60px;
    letter-spacing: 10px;
    animation: titlePulse 2s ease-in-out infinite;
}

#highScoresTable {
    background: linear-gradient(135deg, rgba(26, 10, 46, 0.95) 0%, rgba(10, 10, 10, 0.95) 100%);
    border: 4px solid #00ffff;
    box-shadow: 
        0 0 30px rgba(0, 255, 255, 0.5),
        inset 0 0 30px rgba(0, 255, 255, 0.1);
    padding: 30px;
    min-width: 1200px;
    max-width: 1400px;
    margin-bottom: 40px;
    font-size: 24px;
    border-radius: 15px;
}

#highScoresTable table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}

#highScoresTable th {
    padding: 20px 15px;
    font-size: 28px;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
    border-bottom: 3px solid #00ffff;
    background: rgba(0, 255, 255, 0.1);
}

#highScoresTable td {
    padding: 15px;
    font-size: 24px;
    background: rgba(0, 0, 0, 0.3);
}

#highScoresTable tr {
    transition: all 0.2s;
}

#highScoresTable tbody tr:hover {
    background: rgba(0, 255, 255, 0.1);
    transform: scale(1.02);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.3);
}

#highScoresTable tr:nth-child(1) td:first-child {
    color: #ffd700;
    font-size: 32px;
    text-shadow: 0 0 10px #ffd700;
}

#highScoresTable tr:nth-child(2) td:first-child {
    color: #c0c0c0;
    font-size: 30px;
    text-shadow: 0 0 10px #c0c0c0;
}

#highScoresTable tr:nth-child(3) td:first-child {
    color: #cd7f32;
    font-size: 28px;
    text-shadow: 0 0 10px #cd7f32;
}

/* Game Screen */
#gameScreen {
    padding: 0;
    background: #000;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100px;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    z-index: 10;
}

.hud-left,
.hud-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.player-portrait {
    width: 60px;
    height: 60px;
    border: 3px solid #00aaff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    background: rgba(0, 0, 0, 0.7);
}

#p2Portrait {
    border-color: #00ff00;
}

.portrait-icon {
    font-size: 20px;
    font-weight: bold;
    color: #00aaff;
}

#p2Portrait .portrait-icon {
    color: #00ff00;
}

.cooldown-indicator {
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
}

.cooldown-indicator::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0%;
    background: #00ff00;
    transition: width 0.1s linear;
}

.cooldown-indicator.active::after {
    animation: cooldownFill 2s linear;
}

@keyframes cooldownFill {
    from { width: 0%; }
    to { width: 100%; }
}

.score-display {
    font-size: 48px;
    font-weight: bold;
    color: #00aaff;
    text-shadow: 0 0 10px #00aaff;
    min-width: 80px;
    text-align: center;
}

.hud-right .score-display {
    color: #00ff00;
    text-shadow: 0 0 10px #00ff00;
}

.hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

#timer {
    font-size: 28px;
    color: #ffff00;
    text-shadow: 0 0 10px #ffff00;
}

.pause-btn {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: 2px solid #fff;
    cursor: pointer;
    transition: all 0.2s;
}

.pause-btn:hover {
    background: #fff;
    color: #000;
}

#gameCanvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* Pause Menu */
.overlay-menu {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    border: 4px solid #00ffff;
    padding: 60px;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    z-index: 100;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.5);
}

.overlay-menu.active {
    display: flex;
}

.overlay-menu h2 {
    font-size: 64px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
}

/* Victory Screen */
#victoryScreen {
    background: radial-gradient(circle at center, #1a0a2e 0%, #0a0a0a 100%);
}

.victory-content {
    text-align: center;
}

#victoryTitle {
    font-size: 72px;
    color: #ffff00;
    text-shadow: 0 0 30px #ffff00;
    margin-bottom: 40px;
    animation: victoryPulse 1.5s ease-in-out infinite;
}

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

#victoryStats {
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid #00ffff;
    padding: 40px;
    margin-bottom: 40px;
    min-width: 600px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 32px;
    padding: 15px 0;
    color: #fff;
}

.stat-row span:last-child {
    color: #00ffff;
    font-weight: bold;
}

.victory-buttons {
    display: flex;
    gap: 30px;
    justify-content: center;
}

/* Scanline Effect */
#gameContainer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 1000;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: #000;
}

::-webkit-scrollbar-thumb {
    background: #00ffff;
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #ff00ff;
}

/* High Score Entry Screen */
#highScoreEntryScreen {
    background: radial-gradient(circle at center, #1a0a2e 0%, #0a0a0a 100%);
}

.high-score-entry-content {
    text-align: center;
}

.congratulations {
    font-size: 72px;
    color: #ffff00;
    text-shadow: 0 0 30px #ffff00;
    margin-bottom: 20px;
    animation: victoryPulse 1.5s ease-in-out infinite;
}

.new-high-score {
    font-size: 36px;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
    margin-bottom: 30px;
    animation: blink 1s step-start infinite;
}

.rank-display {
    font-size: 48px;
    color: #ff00ff;
    text-shadow: 0 0 20px #ff00ff;
    margin-bottom: 40px;
    font-weight: bold;
}

.name-entry-section {
    background: rgba(0, 0, 0, 0.7);
    border: 4px solid #00ffff;
    padding: 60px;
    margin: 0 auto 40px;
    display: inline-block;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.5);
}

.enter-name-prompt {
    font-size: 28px;
    color: #ffffff;
    margin-bottom: 30px;
    letter-spacing: 3px;
}

.player-initial-group {
    margin-bottom: 20px;
}

.player-label {
    font-size: 24px;
    margin-bottom: 15px;
    letter-spacing: 2px;
}

.player1-label {
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}

.player2-label {
    color: #ff0000;
    text-shadow: 0 0 10px #ff0000;
}

.vs-divider {
    font-size: 36px;
    color: #ffff00;
    text-shadow: 0 0 20px #ffff00;
    margin: 30px 0;
    font-weight: bold;
}

.initial-input-container {
    display: flex;
    gap: 30px;
    justify-content: center;
    margin-bottom: 10px;
}

.initial-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.initial-box.active .letter.player1 {
    background: #00ffff;
    color: #000;
    box-shadow: 0 0 30px #00ffff;
    transform: scale(1.1);
}

.initial-box.active .letter.player2 {
    background: #ff0000;
    color: #000;
    box-shadow: 0 0 30px #ff0000;
    transform: scale(1.1);
}

.letter {
    width: 80px;
    height: 100px;
    background: rgba(0, 255, 255, 0.2);
    border: 4px solid #00ffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 52px;
    font-weight: bold;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
    transition: all 0.2s;
}

.letter.player1 {
    background: rgba(0, 255, 255, 0.2);
    border-color: #00ffff;
    color: #00ffff;
    text-shadow: 0 0 10px #00ffff;
}

.letter.player2 {
    background: rgba(255, 0, 0, 0.2);
    border-color: #ff0000;
    color: #ff0000;
    text-shadow: 0 0 10px #ff0000;
}

.arrows {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.arrow {
    font-size: 24px;
    color: #00ffff;
    cursor: pointer;
    transition: all 0.2s;
    opacity: 0.6;
}

.arrow:hover {
    opacity: 1;
    transform: scale(1.2);
}

.controls-hint {
    margin-top: 20px;
}

.controls-hint p {
    font-size: 20px;
    color: #888;
    font-style: italic;
}

.skip-btn {
    margin-top: 20px;
    font-size: 20px;
    padding: 10px 30px;
    opacity: 0.7;
}

.skip-btn:hover {
    opacity: 1;
}

/* Responsive Design */
@media (max-width: 1920px) {
    #gameContainer {
        transform: scale(0.9);
    }
}

@media (max-width: 1600px) {
    #gameContainer {
        transform: scale(0.75);
    }
}

@media (max-width: 1280px) {
    #gameContainer {
        transform: scale(0.6);
    }
}
