* {
    box-sizing: border-box;
    user-select: none;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000; /* Pure black */
    font-family: 'VT323', monospace;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* 9:16 aspect ratio game container */
#game-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 540px;
    max-height: 960px;
    background-color: transparent; /* Fallback Sky Blue removed */
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    image-rendering: pixelated; /* Ensures the upscaled 288x512 canvas remains crisp and pixelated */
}

.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.ui-layer.hidden {
    display: none;
}

button, input, select {
    pointer-events: auto;
    font-family: 'VT323', monospace;
    font-size: 18px;
}

:root {
    --bg-beige: #EEDB9F;
    --border-brown: #3C2314;
    --orange-btn: #E05C1E;
    --orange-hover: #F27136;
    --text-brown: #3C2314;
}

.menu-box {
    background-color: var(--bg-beige);
    border: 4px solid var(--border-brown);
    border-radius: 8px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    pointer-events: auto;
}
.menu-box.main {
    margin-top: 20px;
    width: 250px;
}
.menu-box.large {
    width: 90%;
    max-width: 380px;
    margin-top: 50px;
    gap: 10px;
}

.btn-orange {
    background-color: var(--orange-btn);
    color: white;
    border: 3px solid var(--border-brown);
    border-radius: 4px;
    padding: 10px 15px;
    font-size: 20px;
    width: 100%;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.5);
    cursor: pointer;
}
.btn-orange:hover { background-color: var(--orange-hover); }
.btn-orange:active { transform: translateY(2px); }

.btn-primary {
    background-color: var(--bg-beige);
    color: var(--text-brown);
    border: 3px solid var(--border-brown);
    border-radius: 4px;
    padding: 15px 20px;
    font-size: 22px;
    margin-top: 40px;
    cursor: pointer;
}
.btn-primary:active { transform: translateY(2px); }

.btn-outline {
    background: transparent;
    color: var(--text-brown);
    border: none;
    font-size: 18px;
    cursor: pointer;
    text-transform: uppercase;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 20px;
}

.score-box {
    background-color: var(--bg-beige);
    border: 3px solid var(--border-brown);
    border-radius: 6px;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    color: var(--text-brown);
    font-size: 20px;
}

/* Crisp pixel shadow for text */
.author-credits {
    color: white;
    font-size: 24px;
    text-shadow: 
        -2px -2px 0 #000,  
         2px -2px 0 #000,
        -2px  2px 0 #000,
         2px  2px 0 #000,
         4px  4px 0 rgba(0,0,0,0.8);
}

.game-title {
    font-size: 72px;
    color: white;
    text-shadow: 
        -3px -3px 0 #000,  
         3px -3px 0 #000,
        -3px  3px 0 #000,
         3px  3px 0 #000,
         5px  5px 0 #000;
    margin-top: 0;
    text-align: center;
}

.bird-mascot {
    width: 92px;
    height: 36px;
    background-image: url('../assets/ball_skin.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    animation: hoverBird 1s infinite alternate ease-in-out;
    image-rendering: pixelated;
}
@keyframes hoverBird {
    0% { transform: translateY(-8px); }
    100% { transform: translateY(8px); }
}

.credits {
    font-size: 16px;
    color: var(--text-brown);
    margin-top: 5px;
}

/* Settings & Events */
.menu-title {
    color: var(--text-brown);
    font-size: 24px;
    margin: 5px 0 15px 0;
}

.section-title {
    background-color: transparent;
    border: 3px solid var(--border-brown);
    border-radius: 6px;
    padding: 10px;
    width: 100%;
    text-align: center;
    color: var(--text-brown);
    font-size: 18px;
}
.section-title.mt { margin-top: 15px; }

.slider-row {
    display: flex;
    align-items: center;
    width: 100%;
    justify-content: space-between;
    font-size: 18px;
    color: var(--text-brown);
}
.slider-row input[type=range] {
    flex-grow: 1;
    margin: 0 10px;
    -webkit-appearance: none;
    background: transparent;
}
.slider-row input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 8px;
    background: var(--text-brown);
    border-radius: 4px;
}
.slider-row input[type=range]::-webkit-slider-thumb {
    height: 20px;
    width: 12px;
    background: #EAEAEA;
    border: 2px solid var(--text-brown);
    border-radius: 2px;
    -webkit-appearance: none;
    margin-top: -6px;
}

.keys-row {
    display: flex;
    justify-content: space-around;
    width: 100%;
}
.key-bind {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-brown);
    font-size: 16px;
}
.key-bind.centered {
    flex-direction: row;
    justify-content: center;
}
.btn-key {
    background-color: #B29B69;
    color: var(--text-brown);
    border: 2px solid var(--text-brown);
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 16px;
    cursor: pointer;
}

.full-width { width: 100%; }
.mt-small { margin-top: 5px; }

.bottom-actions {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    margin-top: 10px;
    gap: 10px;
}
.small-bird {
    width: 32px;
    height: 24px;
    background-image: url('../assets/ball_skin.png');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Events */
.subtitle {
    font-size: 16px;
    color: var(--text-brown);
    margin-bottom: 10px;
}

.add-action-container {
    display: flex;
    width: 100%;
    gap: 10px;
    margin-bottom: 10px;
}
.dropdown {
    flex-grow: 1;
    background: var(--bg-beige);
    border: 3px solid var(--border-brown);
    color: var(--text-brown);
    border-radius: 4px;
    padding: 5px;
}

.action-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px; /* for scrollbar */
}
/* Scrollbar styling */
.action-list::-webkit-scrollbar {
    width: 8px;
}
.action-list::-webkit-scrollbar-track {
    background: #DCC48E;
    border-radius: 4px;
}
.action-list::-webkit-scrollbar-thumb {
    background: var(--border-brown);
    border-radius: 4px;
}

.action-item {
    border: 3px solid var(--border-brown);
    border-radius: 6px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #EAEAEA; /* Slightly different bg for contrast */
}
.action-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 18px;
    color: var(--text-brown);
}
.btn-trash {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-brown);
}
.action-body {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 16px;
    color: var(--text-brown);
}
.num-input {
    width: 60px;
    background: #B29B69;
    border: 2px solid var(--text-brown);
    color: var(--text-brown);
    padding: 4px;
    font-size: 16px;
    border-radius: 4px;
}

/* Pause Menu */
.pause-box {
    margin: auto;
}
.pause-title {
    font-size: 42px;
    color: white;
    text-shadow: -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000, 2px 2px 0 #000, 4px 4px 0 rgba(0,0,0,0.5);
    margin: 10px 0;
}
.pause-stats {
    font-size: 24px;
    color: var(--text-brown);
    margin-bottom: 10px;
}
.pause-hint {
    font-size: 16px;
    color: var(--text-brown);
}

/* HUD Live Score */
#live-score {
    font-size: 72px;
    color: white;
    text-shadow: 
        -4px -4px 0 #000,  
         4px -4px 0 #000,
        -4px  4px 0 #000,
         4px  4px 0 #000,
         6px  6px 0 #000;
    line-height: 1;
}

/* Floating Animations */
#animations-layer {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.floating-text {
    position: absolute;
    font-size: 36px;
    font-weight: bold;
    color: #39ff14;
    text-shadow: 2px 2px 0 #000, -2px -2px 0 #000, 2px -2px 0 #000, -2px 2px 0 #000;
    animation: floatUp 1s ease-out forwards;
}
.floating-text.negative {
    color: #ff3939;
}

@keyframes floatUp {
    0% { transform: translateY(0) scale(1); opacity: 1; }
    50% { transform: translateY(-40px) scale(1.2); opacity: 1; }
    100% { transform: translateY(-80px) scale(1); opacity: 0; }
}

/* Acceleration visual */
.speed-lines {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: repeating-linear-gradient(90deg, rgba(255,255,255,0) 0%, rgba(255,255,255,0.1) 10%, rgba(255,255,255,0) 20%);
    background-size: 200% 100%;
    animation: speedFlash 0.5s ease-out forwards;
    pointer-events: none;
}
@keyframes speedFlash {
    0% { opacity: 0; background-position: 0 0; }
    50% { opacity: 1; }
    100% { opacity: 0; background-position: -100% 0; }
}

/* INTERNAL WIDGET OVERLAY STYLES */
.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.9) translateY(20px);
    pointer-events: none;
    transition: opacity 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), 
                transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.overlay.active {
    opacity: 1;
    transform: scale(1) translateY(0);
}

.reset-title {
    font-size: 80px;
    letter-spacing: 4px;
    color: #ffffff;
    -webkit-text-stroke: 10px #3D1C12;
    paint-order: stroke fill;
    margin-bottom: -20px;
    z-index: 2;
    white-space: nowrap;
}

.reset-timer {
    font-size: 250px;
    line-height: 1;
    margin: 0;
    color: #ffffff;
    -webkit-text-stroke: 26px #4B1B1C;
    paint-order: stroke fill;
    filter: drop-shadow(0 0 40px rgba(255, 50, 50, 0.9)) drop-shadow(0 0 20px rgba(255, 0, 0, 0.8));
    z-index: 1;
    white-space: nowrap;
}

.reset-subtitle {
    font-size: 48px;
    letter-spacing: 2px;
    color: #ffffff;
    -webkit-text-stroke: 8px #3D1C12;
    paint-order: stroke fill;
    margin-top: -15px;
    z-index: 2;
    white-space: nowrap;
}

.reset-img {
    width: 450px;
    margin-bottom: 15px;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.4));
}

.saved-title {
    color: #96E7A6;
    font-size: 180px;
    letter-spacing: 8px;
    -webkit-text-stroke: 16px #3D764E;
    paint-order: stroke fill;
    margin-bottom: 10px;
    filter: drop-shadow(5px 5px 0px rgba(61,118,78,0.7));
    white-space: nowrap;
}

.saved-subtitle {
    color: white;
    font-size: 120px;
    letter-spacing: 8px;
    margin-bottom: 20px;
    -webkit-text-stroke: 10px #3D1C12;
    paint-order: stroke fill;
    text-shadow: 0px 5px 15px rgba(0,0,0,0.5);
    white-space: nowrap;
}

.saved-footer {
    color: white;
    font-size: 48px;
    letter-spacing: 2px;
    -webkit-text-stroke: 6px #3D1C12;
    paint-order: stroke fill;
    text-shadow: 2px 2px 5px rgba(0,0,0,0.6);
    white-space: nowrap;
}
