/* ============================================================
   L'Orto di Marzia — Main Stylesheet
   ============================================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #2d1b0e;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
}

/* --- Game Container --- */
#game-container {
    position: relative;
    width: 100%;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #1a1a1a;
}

#game-canvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* --- Screen Overlays --- */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: none;
}

.screen.active {
    display: flex;
    pointer-events: auto;
}

/* --- Menu Screen --- */
.menu-top-bar {
    position: absolute;
    top: env(safe-area-inset-top, 12px);
    right: 12px;
    display: flex;
    gap: 10px;
    z-index: 20;
}

.icon-btn {
    width: 44px;
    height: 44px;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 10px;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
}

.icon-btn:active {
    background: rgba(255,255,255,0.2);
}

.menu-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 20px;
    width: 100%;
    max-width: 360px;
}

.game-title {
    font-size: 32px;
    color: #fff;
    text-shadow: 2px 2px 0 #2d5a1e, 0 0 10px rgba(74,124,63,0.6);
    text-align: center;
    margin-top: 60px;
    letter-spacing: 1px;
}

.personal-best {
    color: #c8e6c0;
    font-size: 14px;
    text-align: center;
    min-height: 20px;
}

/* --- Play Button --- */
.btn-play {
    width: 200px;
    height: 56px;
    border: 3px solid #fff;
    border-radius: 14px;
    background: linear-gradient(180deg, #5cb846 0%, #3a8a28 100%);
    color: #fff;
    font-size: 24px;
    font-weight: bold;
    letter-spacing: 3px;
    cursor: pointer;
    text-shadow: 1px 1px 0 #2d5a1e;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: transform 0.1s;
}

.btn-play:active {
    transform: scale(0.95);
}

/* --- Leaderboard Box --- */
.leaderboard-box {
    width: 100%;
    background: rgba(0,0,0,0.5);
    border-radius: 12px;
    padding: 14px 18px;
    border: 1px solid rgba(255,255,255,0.15);
}

.leaderboard-box h2 {
    color: #ffd700;
    font-size: 16px;
    text-align: center;
    margin-bottom: 8px;
    letter-spacing: 1px;
}

.leaderboard-box ol {
    list-style: none;
    counter-reset: lb;
}

.leaderboard-box li {
    counter-increment: lb;
    display: flex;
    align-items: center;
    padding: 5px 0;
    color: #e0e0e0;
    font-size: 15px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    font-family: 'Courier New', monospace;
}

.leaderboard-box li::before {
    content: counter(lb) ".";
    width: 28px;
    color: #ffd700;
    font-weight: bold;
}

.leaderboard-box .lb-name {
    width: 48px;
    font-weight: bold;
    color: #fff;
}

.leaderboard-box .lb-score {
    flex: 1;
    text-align: right;
    color: #8eff7a;
    font-weight: bold;
}

.leaderboard-box .lb-date {
    width: 70px;
    text-align: right;
    color: #aaa;
    font-size: 12px;
    margin-left: 8px;
}

/* --- HUD --- */
#hud {
    pointer-events: none;
    z-index: 5;
}

#hud.active {
    pointer-events: none;
}

.hud-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: env(safe-area-inset-top, 6px) 12px 4px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 100%);
}

.hud-item {
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    font-family: 'Courier New', monospace;
}

.hud-progress {
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255,255,255,0.15);
}

#hud-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #8eff7a, #ffd700);
    transition: width 0.3s linear;
}

/* --- Overlay Box (game over, season end, credits) --- */
.overlay-box {
    background: rgba(0,0,0,0.85);
    border-radius: 16px;
    border: 2px solid rgba(255,255,255,0.2);
    padding: 30px 24px;
    text-align: center;
    max-width: 320px;
    width: 90%;
}

.overlay-box h2 {
    color: #ffd700;
    font-size: 26px;
    margin-bottom: 12px;
}

.big-score {
    color: #8eff7a;
    font-size: 48px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    margin: 8px 0;
}

.subtitle {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 16px;
}

.btn-continue {
    padding: 12px 32px;
    border: 2px solid #fff;
    border-radius: 10px;
    background: rgba(255,255,255,0.15);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    margin-top: 8px;
}

.btn-continue:active {
    background: rgba(255,255,255,0.3);
}

/* --- Name Entry --- */
.nameentry-box {
    background: rgba(0,0,0,0.9);
    border-radius: 16px;
    border: 2px solid rgba(255,215,0,0.3);
    padding: 24px 16px;
    text-align: center;
    max-width: 340px;
    width: 95%;
}

.nameentry-box h2 {
    color: #ffd700;
    font-size: 20px;
    margin-bottom: 8px;
}

.name-display {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 16px 0;
}

.name-char {
    width: 48px;
    height: 56px;
    line-height: 56px;
    font-size: 36px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    color: #fff;
    background: rgba(255,255,255,0.1);
    border: 2px solid #ffd700;
    border-radius: 8px;
    text-align: center;
}

.name-char.active {
    border-color: #8eff7a;
    background: rgba(142,255,122,0.15);
}

.arcade-keyboard {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    margin-top: 12px;
}

.key-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.key-btn:active {
    background: rgba(255,255,255,0.3);
}

.key-btn.key-backspace {
    grid-column: span 2;
    aspect-ratio: auto;
    height: 100%;
    font-size: 20px;
}

.key-btn.key-submit {
    grid-column: span 3;
    aspect-ratio: auto;
    height: 100%;
    background: rgba(142,255,122,0.25);
    border-color: #8eff7a;
    color: #8eff7a;
    font-size: 14px;
}

.key-btn.key-submit.ready {
    background: rgba(142,255,122,0.4);
}

/* --- Season End warm filter --- */
#screen-seasonend .overlay-box {
    background: rgba(80,50,10,0.9);
    border-color: rgba(255,200,50,0.4);
}

.season-filter {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,180,50,0.25);
    pointer-events: none;
    z-index: 4;
}

/* --- Landscape Warning --- */
#landscape-warning {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    color: #fff;
    font-size: 20px;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    text-align: center;
}

@media (orientation: landscape) {
    #landscape-warning {
        display: flex;
    }
    #game-container {
        visibility: hidden;
    }
}

/* --- Scrollbar hide --- */
::-webkit-scrollbar { display: none; }
