/* General resets and fonts */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #121519;
    font-family: 'Patrick Hand', 'Schoolbell', cursive, sans-serif;
    color: #e3e8f0;
}

/* Blackboard Background */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background-color: #15191e;
}

#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
}

/* Hand-drawn sketchy border generator */
.sketchy-box {
    border: 3px solid rgba(224, 230, 237, 0.7);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    background: rgba(21, 25, 30, 0.85);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

/* Overlay Panels (Start/Game Over) */
.overlay-panel {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 580px;
    padding: 30px;
    z-index: 10;
    text-align: center;
    border: 3px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px 300px 20px 280px/25px 20px 25px 300px;
    background: rgba(20, 24, 30, 0.95);
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hidden {
    display: none !important;
}

/* Titles and Typography */
.game-title {
    font-size: 3.5rem;
    font-weight: bold;
    color: #ffe066; /* Yellow chalk */
    text-shadow: 2px 2px 0px rgba(0,0,0,0.5), 0 0 10px rgba(255, 224, 102, 0.4);
    letter-spacing: 2px;
    margin-bottom: 2px;
}

.subtitle {
    font-size: 1.5rem;
    color: #a0aec0;
    margin-bottom: 20px;
    font-style: italic;
}

.rules-container {
    width: 100%;
    border-top: 2px dashed rgba(224, 230, 237, 0.4);
    border-bottom: 2px dashed rgba(224, 230, 237, 0.4);
    padding: 15px 0;
    margin-bottom: 25px;
    text-align: left;
    font-size: 1.25rem;
    line-height: 1.4;
}

.rules-container h3 {
    text-align: center;
    color: #ffe066;
    margin-bottom: 10px;
}

.objective {
    margin: 10px 0;
    padding: 8px;
    background: rgba(255, 224, 102, 0.1);
    border-left: 4px solid #ffe066;
}

.control-list {
    list-style-type: none;
    margin-top: 10px;
}

.control-list li {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}

.key {
    background: #2d3748;
    border: 2px solid #a0aec0;
    border-radius: 5px;
    padding: 2px 8px;
    margin-right: 10px;
    font-weight: bold;
    font-family: monospace;
    font-size: 1rem;
    display: inline-block;
    color: #fff;
    box-shadow: 1px 2px 0px rgba(0,0,0,0.4);
}

/* Sketchy Button styling */
.sketch-btn {
    font-family: inherit;
    font-size: 1.8rem;
    padding: 10px 30px;
    background: transparent;
    color: #ffe066;
    border: 3px solid #ffe066;
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.sketch-btn:hover {
    background: rgba(255, 224, 102, 0.15);
    transform: scale(1.05) rotate(-1deg);
    box-shadow: 0px 0px 15px rgba(255, 224, 102, 0.5);
}

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

/* HUD Panels */
.hud-panel {
    position: absolute;
    z-index: 5;
    padding: 15px;
    pointer-events: auto;
    border: 3px solid rgba(224, 230, 237, 0.5);
    border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
    background: rgba(21, 25, 30, 0.85);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4);
    font-size: 1.3rem;
}

.left-hud {
    top: 20px;
    left: 20px;
    width: 250px;
}

.right-hud {
    top: 20px;
    right: 20px;
    width: 250px;
}

.center-top-hud {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 480px;
    font-size: 1.15rem;
    line-height: 1.35;
    border-color: rgba(255, 224, 102, 0.4);
    border-radius: 8px 120px 8px 100px/4px 100px 4px 120px;
    background: rgba(21, 25, 30, 0.85);
}

.guide-title {
    font-size: 1.35rem;
    font-weight: bold;
    color: #ffe066;
    margin-bottom: 5px;
    text-align: center;
    border-bottom: 1.5px dashed rgba(255, 224, 102, 0.35);
    padding-bottom: 2px;
}

.guide-item {
    margin-bottom: 4px;
}

.center-bottom-hud {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 560px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    border-radius: 15px 255px 15px 225px/225px 15px 255px 15px;
}

/* Colors for Factions */
.player-color {
    color: #4df0ff; /* Crayon blue-cyan */
    text-shadow: 0 0 5px rgba(77, 240, 255, 0.3);
}

.enemy-color {
    color: #ff5d6c; /* Crayon red-coral */
    text-shadow: 0 0 5px rgba(255, 93, 108, 0.3);
}

.ship-header {
    font-size: 1.6rem;
    margin-bottom: 10px;
    text-align: center;
    border-bottom: 2px dashed currentColor;
    padding-bottom: 5px;
}

.telemetry-item {
    margin-bottom: 5px;
}

.telemetry-val {
    font-weight: bold;
    color: #ffffff;
}

/* Custom Crayon-style Meters */
.meter-container {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.meter-label {
    font-size: 1.1rem;
    color: #cbd5e0;
}

.meter-bg {
    width: 100%;
    height: 12px;
    background: rgba(45, 55, 72, 0.7);
    border: 2px solid rgba(224, 230, 237, 0.5);
    border-radius: 120px 4px 100px 4px/4px 100px 4px 120px;
    overflow: hidden;
    position: relative;
}

.meter-fill {
    height: 100%;
    width: 0%;
    transition: width 0.1s ease;
    border-radius: 120px 4px 100px 4px/4px 100px 4px 120px;
}

.player-fuel-fill {
    background: #4df0ff;
    box-shadow: 0 0 8px rgba(77, 240, 255, 0.7);
}

.player-shield-fill {
    background: #4df0ff;
    box-shadow: 0 0 8px rgba(77, 240, 255, 0.7);
}

.enemy-fuel-fill {
    background: #ff5d6c;
    box-shadow: 0 0 8px rgba(255, 93, 108, 0.7);
}

.enemy-shield-fill {
    background: #ff5d6c;
    box-shadow: 0 0 8px rgba(255, 93, 108, 0.7);
}

.meter-text {
    text-align: right;
    font-size: 1rem;
    color: #a0aec0;
}

/* Autopilot Buttons and Weapon buttons */
.ap-buttons {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.ap-btn {
    font-family: inherit;
    font-size: 1.1rem;
    padding: 6px 12px;
    background: rgba(45, 55, 72, 0.5);
    color: #e2e8f0;
    border: 2px solid rgba(224, 230, 237, 0.4);
    border-radius: 15px 4px 12px 4px/4px 12px 4px 15px;
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
}

.ap-btn:hover {
    background: rgba(77, 240, 255, 0.15);
    color: #4df0ff;
    border-color: #4df0ff;
    transform: translateY(-2px);
}

.ap-btn:active {
    transform: translateY(0);
}

.weapon-selector {
    display: flex;
    gap: 10px;
    width: 100%;
    justify-content: center;
}

.weap-btn {
    font-family: inherit;
    font-size: 1.1rem;
    padding: 6px 14px;
    background: rgba(45, 55, 72, 0.3);
    color: #a0aec0;
    border: 2px solid rgba(224, 230, 237, 0.3);
    border-radius: 10px 150px 10px 120px/15px 12px 15px 12px;
    cursor: pointer;
    outline: none;
    transition: all 0.15s ease;
}

.weap-btn:hover {
    color: #ffe066;
    border-color: #ffe066;
    background: rgba(255, 224, 102, 0.1);
}

.weap-btn.active {
    color: #ffe066;
    border: 2px solid #ffe066;
    background: rgba(255, 224, 102, 0.15);
    box-shadow: 0 0 8px rgba(255, 224, 102, 0.3);
}

/* Warnings and Alerts */
.warning-alert {
    position: absolute;
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 25px;
    z-index: 5;
    background: rgba(255, 93, 108, 0.25);
    color: #ff5d6c;
    border: 3px solid #ff5d6c;
    border-radius: 20px 200px 20px 200px/20px 20px 20px 20px;
    font-size: 1.8rem;
    font-weight: bold;
    text-shadow: 0 0 5px rgba(255, 93, 108, 0.5);
    animation: alert-blink 1.2s infinite;
}

@keyframes alert-blink {
    0%, 100% { opacity: 1; transform: translateX(-50%) scale(1); }
    50% { opacity: 0.3; transform: translateX(-50%) scale(1.05); }
}

/* Sound Toggle Button */
.sound-toggle-btn {
    position: absolute;
    bottom: 20px;
    right: 20px;
    z-index: 5;
    background: rgba(21, 25, 30, 0.85);
    color: #cbd5e0;
    border: 2px solid rgba(224, 230, 237, 0.4);
    border-radius: 20px 4px 20px 4px/4px 20px 4px 20px;
    font-family: inherit;
    font-size: 1.2rem;
    padding: 6px 14px;
    cursor: pointer;
    transition: all 0.15s ease;
    outline: none;
}

.sound-toggle-btn:hover {
    color: #ffe066;
    border-color: #ffe066;
    background: rgba(255, 224, 102, 0.1);
}

/* Custom animations for damage shake */
.damage-flash-player {
    animation: damage-flash-p-anim 0.3s;
}

.damage-flash-enemy {
    animation: damage-flash-e-anim 0.3s;
}

@keyframes damage-flash-p-anim {
    0%, 100% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); border-color: rgba(224, 230, 237, 0.5); }
    50% { box-shadow: 0 0 20px rgba(77, 240, 255, 0.8); border-color: #4df0ff; }
}

@keyframes damage-flash-e-anim {
    0%, 100% { box-shadow: 0 4px 10px rgba(0, 0, 0, 0.4); border-color: rgba(224, 230, 237, 0.5); }
    50% { box-shadow: 0 0 20px rgba(255, 93, 108, 0.8); border-color: #ff5d6c; }
}
