/* ============================================
   Kapitän Joswich - Windows 98 Style CSS
   ============================================ */

/* Import Pixel Font */
@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* CSS Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Windows 98 Color Palette */
    --win98-bg: #008080;
    --win98-gray: #c0c0c0;
    --win98-dark-gray: #808080;
    --win98-white: #ffffff;
    --win98-black: #000000;
    --win98-blue: #000080;
    --win98-highlight: #0000ff;
    
    /* Game Colors */
    --water-surface: #1a5f7a;
    --water-deep: #0d2137;
    --sky-color: #87ceeb;
    --hud-bg: rgba(0, 0, 0, 0.7);
    --danger-red: #ff0000;
    --safe-green: #00ff00;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'VT323', 'MS Sans Serif', Arial, sans-serif;
    background: var(--win98-bg);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ============================================
   Game Container
   ============================================ */
#game-container {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ============================================
   Screen Management
   ============================================ */
.screen {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.screen.hidden {
    display: none;
}

/* ============================================
   Windows 98 Window Styling
   ============================================ */
.win98-window {
    background: var(--win98-gray);
    border: 2px solid;
    border-color: var(--win98-white) var(--win98-dark-gray) var(--win98-dark-gray) var(--win98-white);
    box-shadow: 
        inset 1px 1px 0 var(--win98-white),
        inset -1px -1px 0 var(--win98-black),
        4px 4px 0 rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 600px;
}

.win98-window.small {
    min-width: 300px;
    max-width: 350px;
}

.win98-title-bar {
    background: linear-gradient(90deg, var(--win98-blue), #1084d0);
    color: var(--win98-white);
    padding: 4px 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 14px;
    user-select: none;
}

.win98-buttons {
    display: flex;
    gap: 2px;
}

.win98-btn {
    width: 16px;
    height: 14px;
    background: var(--win98-gray);
    border: 2px solid;
    border-color: var(--win98-white) var(--win98-dark-gray) var(--win98-dark-gray) var(--win98-white);
    font-size: 10px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
}

.win98-btn:active {
    border-color: var(--win98-dark-gray) var(--win98-white) var(--win98-white) var(--win98-dark-gray);
}

.win98-content {
    padding: 20px;
    text-align: center;
}

/* ============================================
   Title Screen
   ============================================ */
#title-screen h1 {
    font-size: 36px;
    color: var(--win98-blue);
    text-shadow: 2px 2px 0 var(--win98-gray);
    margin-bottom: 5px;
}

#title-screen h2 {
    font-size: 24px;
    color: var(--win98-dark-gray);
    margin-bottom: 15px;
}

.title-art {
    font-family: monospace;
    font-size: 12px;
    color: var(--win98-blue);
    margin: 20px 0;
    line-height: 1.2;
}

.title-art pre {
    display: inline-block;
    text-align: left;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 20px 0;
}

.copyright {
    font-size: 12px;
    color: var(--win98-dark-gray);
    margin-top: 15px;
}

/* ============================================
   Windows 98 Button
   ============================================ */
.win98-button {
    font-family: 'VT323', 'MS Sans Serif', Arial, sans-serif;
    font-size: 18px;
    padding: 8px 20px;
    background: var(--win98-gray);
    border: 2px solid;
    border-color: var(--win98-white) var(--win98-dark-gray) var(--win98-dark-gray) var(--win98-white);
    cursor: pointer;
    min-width: 150px;
    transition: all 0.1s;
}

.win98-button:hover {
    background: #d4d4d4;
}

.win98-button:active {
    border-color: var(--win98-dark-gray) var(--win98-white) var(--win98-white) var(--win98-dark-gray);
    padding: 9px 19px 7px 21px;
}

.win98-button:focus {
    outline: 1px dotted var(--win98-black);
    outline-offset: -4px;
}

/* ============================================
   Controls & Highscore Tables
   ============================================ */
.controls-table,
.highscore-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
    font-size: 16px;
}

.controls-table td,
.highscore-table td,
.highscore-table th {
    padding: 8px;
    border: 1px solid var(--win98-dark-gray);
    text-align: left;
}

.controls-table td:first-child {
    font-weight: bold;
    width: 120px;
    text-align: center;
    background: #e0e0e0;
}

.highscore-table th {
    background: var(--win98-blue);
    color: var(--win98-white);
}

.highscore-table tr:nth-child(even) {
    background: #e0e0e0;
}

.win98-content ul {
    text-align: left;
    margin-left: 20px;
    font-size: 14px;
}

.win98-content ul li {
    margin: 5px 0;
}

.win98-content h3 {
    margin-top: 15px;
    color: var(--win98-blue);
}

/* ============================================
   Game Screen & Canvas
   ============================================ */
#game-screen {
    background: linear-gradient(
        to bottom,
        var(--sky-color) 0%,
        var(--sky-color) 15%,
        var(--water-surface) 15%,
        var(--water-deep) 100%
    );
    flex-direction: column;
}

#game-canvas {
    display: block;
    background: transparent;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ============================================
   HUD (Heads Up Display)
   ============================================ */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: var(--hud-bg);
    border-bottom: 3px solid var(--win98-blue);
    z-index: 100;
    font-size: 20px;
    color: var(--win98-white);
}

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

.hud-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hud-label {
    color: #aaa;
    font-size: 14px;
}

#score,
#wave {
    color: #00ff00;
    font-size: 24px;
    min-width: 60px;
}

#torpedoes {
    color: #ffff00;
    letter-spacing: 4px;
}

#lives {
    color: #ff4444;
    letter-spacing: 4px;
    font-size: 24px;
}

/* Depth Meter */
.depth-meter {
    flex-direction: column;
    gap: 2px;
}

#depth-bar {
    width: 150px;
    height: 15px;
    background: #333;
    border: 2px solid;
    border-color: var(--win98-dark-gray) var(--win98-white) var(--win98-white) var(--win98-dark-gray);
    position: relative;
}

#depth-indicator {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--safe-green), #ffff00, var(--danger-red));
    transition: width 0.2s ease;
}

#depth-value {
    font-size: 14px;
    color: #00ffff;
}

/* Periscope Indicator */
#periscope-indicator {
    background: #004400;
    padding: 5px 10px;
    border: 2px solid var(--safe-green);
    animation: blink 0.5s infinite;
}

#periscope-indicator.hidden {
    display: none;
}

.periscope-active {
    color: var(--safe-green);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   Periscope Overlay
   ============================================ */
#periscope-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 50;
}

#periscope-overlay.hidden {
    display: none;
}

.periscope-view {
    width: 100%;
    height: 100%;
    position: relative;
    background: radial-gradient(
        circle at center,
        transparent 28%,
        rgba(0, 0, 0, 0.6) 33%,
        rgba(0, 0, 0, 0.85) 42%,
        rgba(0, 0, 0, 0.98) 55%
    );
}

.periscope-crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 2px solid rgba(0, 255, 0, 0.5);
    border-radius: 50%;
}

.periscope-crosshair::before,
.periscope-crosshair::after {
    content: '';
    position: absolute;
    background: rgba(0, 255, 0, 0.5);
}

.periscope-crosshair::before {
    width: 100%;
    height: 2px;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
}

.periscope-crosshair::after {
    width: 2px;
    height: 100%;
    left: 50%;
    top: 0;
    transform: translateX(-50%);
}

.periscope-range {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    border: 1px dashed rgba(0, 255, 0, 0.3);
    border-radius: 50%;
}

/* ============================================
   Game Over Screen
   ============================================ */
#gameover-screen h2 {
    color: var(--danger-red);
    font-size: 32px;
    margin-bottom: 20px;
}

.gameover-stats {
    background: #e0e0e0;
    border: 2px solid;
    border-color: var(--win98-dark-gray) var(--win98-white) var(--win98-white) var(--win98-dark-gray);
    padding: 15px;
    margin: 15px 0;
    font-size: 18px;
}

.gameover-stats p {
    margin: 8px 0;
}

.gameover-stats span {
    font-weight: bold;
    color: var(--win98-blue);
}

.name-input {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.name-input input {
    font-family: 'VT323', monospace;
    font-size: 20px;
    padding: 8px;
    border: 2px solid;
    border-color: var(--win98-dark-gray) var(--win98-white) var(--win98-white) var(--win98-dark-gray);
    text-align: center;
    text-transform: uppercase;
}

/* ============================================
   Pause Screen
   ============================================ */
#pause-screen {
    background: rgba(0, 0, 0, 0.7);
}

#pause-screen h2 {
    color: var(--win98-blue);
    margin-bottom: 20px;
}

#pause-screen .win98-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 768px) {
    .win98-window {
        min-width: 95%;
        max-width: 95%;
        margin: 10px;
    }
    
    #hud {
        flex-wrap: wrap;
        font-size: 14px;
        padding: 5px 10px;
    }
    
    .hud-left,
    .hud-center,
    .hud-right {
        gap: 10px;
    }
    
    #depth-bar {
        width: 100px;
    }
}

/* ============================================
   Animations
   ============================================ */
@keyframes explosion {
    0% { transform: scale(0); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.8; }
    100% { transform: scale(2); opacity: 0; }
}

@keyframes sonar-ping {
    0% { transform: scale(0); opacity: 1; border-width: 3px; }
    100% { transform: scale(3); opacity: 0; border-width: 1px; }
}

/* Scanlines Effect (optional retro feel) */
#game-screen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.1) 0px,
        rgba(0, 0, 0, 0.1) 1px,
        transparent 1px,
        transparent 3px
    );
    pointer-events: none;
    z-index: 200;
}
