/* ======================================
   gabs.day v2 - Pixel Art Value Tracker
   Palette:
     High Contrast Black: #1A1A2E
     Pixel White:         #F0F0E8
     Retro Green:         #38B764
     Coin Gold:           #F7D358
     Sky Blue:            #5B8EE0
     Sunset Coral:        #E06060
     Brick Brown:         #8B5E3C
   ====================================== */

/* --- Reset --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: auto;
    image-rendering: pixelated;
    -ms-interpolation-mode: nearest-neighbor;
}

body {
    font-family: 'VT323', monospace;
    font-weight: 400;
    font-size: clamp(16px, 2vw, 22px);
    line-height: 1.8;
    color: #F0F0E8;
    background-color: #1A1A2E;
    overflow-x: hidden;
    -webkit-font-smoothing: none;
    -moz-osx-font-smoothing: unset;
}

/* --- CRT Scanline Overlay --- */
#crt-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    opacity: 0;
    background-image:
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.04) 2px,
            rgba(0, 0, 0, 0.04) 4px
        ),
        repeating-linear-gradient(
            90deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.02) 2px,
            rgba(0, 0, 0, 0.02) 4px
        );
    transition: opacity 0.3s steps(4);
}

#crt-overlay.on {
    opacity: 1;
}

/* --- Background Layer (Fixed, Parallax) --- */
#bg-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

/* --- Pixel Clouds --- */
.pixel-cloud {
    position: absolute;
    opacity: 0;
    transition: opacity 0.1s steps(2);
}

.pixel-cloud.shown {
    opacity: 0.9;
}

.cloud-block {
    position: absolute;
    background: #F0F0E8;
}

.cloud-a {
    top: 7%;
    left: -100px;
    animation: driftA 36s steps(72) infinite;
}

.cloud-b {
    top: 14%;
    left: -80px;
    animation: driftB 48s steps(96) infinite;
}

.cloud-c {
    top: 22%;
    left: -90px;
    animation: driftC 42s steps(84) infinite;
}

.cloud-d {
    top: 4%;
    left: -70px;
    animation: driftD 52s steps(104) infinite;
}

.cloud-e {
    top: 30%;
    left: -100px;
    animation: driftE 40s steps(80) infinite;
}

@keyframes driftA {
    from { transform: translateX(-100px); }
    to   { transform: translateX(calc(100vw + 200px)); }
}

@keyframes driftB {
    from { transform: translateX(-80px); }
    to   { transform: translateX(calc(100vw + 180px)); }
}

@keyframes driftC {
    from { transform: translateX(-90px); }
    to   { transform: translateX(calc(100vw + 190px)); }
}

@keyframes driftD {
    from { transform: translateX(-70px); }
    to   { transform: translateX(calc(100vw + 170px)); }
}

@keyframes driftE {
    from { transform: translateX(-100px); }
    to   { transform: translateX(calc(100vw + 200px)); }
}

/* --- Game Level (Sections) --- */
.game-level {
    position: relative;
    min-height: 100vh;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 64px 20px;
}

/* --- HERO Section --- */
#hero {
    padding: 0;
    overflow: hidden;
}

/* Stepped Sky Gradient */
#sky-gradient {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    z-index: 0;
}

.sky-band {
    flex: 1;
    opacity: 0;
    transition: none;
}

.sky-band.lit {
    opacity: 1;
}

.sky-band[data-band="0"]  { background-color: #1A1A2E; }
.sky-band[data-band="1"]  { background-color: #212040; }
.sky-band[data-band="2"]  { background-color: #283060; }
.sky-band[data-band="3"]  { background-color: #304280; }
.sky-band[data-band="4"]  { background-color: #3A5498; }
.sky-band[data-band="5"]  { background-color: #4466AA; }
.sky-band[data-band="6"]  { background-color: #4E78BC; }
.sky-band[data-band="7"]  { background-color: #5B8EE0; }
.sky-band[data-band="8"]  { background-color: #6898E6; }
.sky-band[data-band="9"]  { background-color: #78A4EC; }
.sky-band[data-band="10"] { background-color: #88B0F2; }
.sky-band[data-band="11"] { background-color: #98BCF8; }

/* --- Pixel Sun --- */
#pixel-sun {
    position: absolute;
    bottom: 14%;
    left: 50%;
    transform: translateX(-50%) translateY(48px);
    z-index: 2;
    opacity: 0;
    width: 64px;
    height: 64px;
}

#pixel-sun.risen {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.sun-core {
    position: absolute;
    inset: 0;
    background: #F7D358;
}

.sun-ray {
    position: absolute;
    background: #F7D358;
    opacity: 0;
}

#pixel-sun.risen .sun-ray {
    opacity: 0.7;
}

.ray-n  { width: 8px; height: 20px; top: -24px; left: 28px; }
.ray-s  { width: 8px; height: 20px; bottom: -24px; left: 28px; }
.ray-w  { width: 20px; height: 8px; top: 28px; left: -24px; }
.ray-e  { width: 20px; height: 8px; top: 28px; right: -24px; }
.ray-ne { width: 8px; height: 8px; top: -10px; right: -10px; }
.ray-nw { width: 8px; height: 8px; top: -10px; left: -10px; }
.ray-se { width: 8px; height: 8px; bottom: -10px; right: -10px; }
.ray-sw { width: 8px; height: 8px; bottom: -10px; left: -10px; }

/* --- Hero Title --- */
#hero-title {
    position: relative;
    z-index: 5;
    text-align: center;
    margin-bottom: 24px;
}

#gabs-letters,
#day-letters {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(32px, 8vw, 80px);
    letter-spacing: 0.02em;
    display: inline-block;
}

#gabs-letters .letter {
    display: inline-block;
    opacity: 0;
    color: #F0F0E8;
    text-shadow: 4px 4px 0 #1A1A2E;
}

#gabs-letters .letter.pop {
    opacity: 1;
}

#day-letters {
    color: #F7D358;
    text-shadow: 4px 4px 0 #8B5E3C;
    opacity: 0;
}

#day-letters.pop {
    opacity: 1;
}

.dot-letter {
    color: #E06060;
}

/* --- Hero Tagline --- */
#hero-tagline {
    font-family: 'VT323', monospace;
    font-size: clamp(18px, 3vw, 28px);
    color: #38B764;
    position: relative;
    z-index: 5;
    opacity: 0;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

#hero-tagline.pop {
    opacity: 1;
}

/* --- Ground Blocks --- */
#hero-ground,
#footer-ground {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    display: flex;
    align-items: flex-end;
    z-index: 3;
}

.ground-block {
    flex: 1;
    height: 32px;
    background: #8B5E3C;
    border-top: 4px solid #38B764;
}

.ground-block.tall-block {
    height: 48px;
}

/* --- Coin Sprites --- */
.coin-sprite {
    width: 16px;
    height: 16px;
    background: #F7D358;
    border-left: 2px solid #FFEEBB;
    border-right: 2px solid #C4A02E;
    border-top: 2px solid #FFEEBB;
    border-bottom: 2px solid #C4A02E;
    position: absolute;
    z-index: 6;
    opacity: 0;
}

.coin-sprite.bounce {
    opacity: 1;
    animation: coinJump 1s steps(8) infinite;
}

.hc-1 { top: 34%; left: 12%; }
.hc-2 { top: 26%; right: 14%; }
.hc-3 { bottom: 24%; left: 22%; }
.hc-4 { bottom: 30%; right: 12%; }

@keyframes coinJump {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-12px); }
}

/* Floating section coins */
.floating-coin {
    position: absolute;
    z-index: 10;
}

.fc-1 { top: 14%; right: 7%; }
.fc-2 { bottom: 18%; left: 6%; }
.fc-3 { top: 12%; left: 7%; }
.fc-4 { bottom: 14%; right: 10%; }

/* --- Retro Game Window UI --- */
.retro-window {
    background: #1A1A2E;
    border: 2px solid #F0F0E8;
    max-width: 720px;
    width: 90%;
    margin: 24px auto;
    position: relative;
    opacity: 0;
    transform: translateY(48px);
}

.retro-window.enter {
    opacity: 1;
    transform: translateY(0);
}

.retro-titlebar {
    background: #5B8EE0;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px;
    border-bottom: 2px solid #F0F0E8;
}

.retro-title {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #F0F0E8;
    letter-spacing: 0.05em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.retro-controls {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.ctrl-btn {
    display: block;
    width: 8px;
    height: 8px;
}

.ctrl-min {
    background: #F7D358;
}

.ctrl-close {
    background: #E06060;
}

.retro-body {
    padding: 16px;
}

/* --- Typography --- */
.body-text {
    font-family: 'VT323', monospace;
    font-size: clamp(16px, 2vw, 22px);
    line-height: 1.8;
    color: #F0F0E8;
    margin-bottom: 16px;
}

.body-text:last-child {
    margin-bottom: 0;
}

.display-text {
    font-family: 'Press Start 2P', cursive;
    font-size: clamp(16px, 3vw, 36px);
    letter-spacing: 0.02em;
    color: #F0F0E8;
}

.label-text {
    font-family: 'Silkscreen', cursive;
    font-size: clamp(10px, 1.5vw, 14px);
    color: #F0F0E8;
    letter-spacing: 0.05em;
}

.hl-green {
    color: #38B764;
}

.gold-text {
    color: #F7D358;
}

/* --- Bar Chart (Level 2) --- */
#bar-chart {
    position: relative;
}

.chart-heading {
    font-family: 'Silkscreen', cursive;
    font-size: 12px;
    color: #F7D358;
    text-align: center;
    margin-bottom: 12px;
    letter-spacing: 0.1em;
}

.bar-chart-area {
    display: flex;
    gap: 8px;
    height: 160px;
    align-items: flex-end;
}

.bar-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    font-family: 'Silkscreen', cursive;
    font-size: 9px;
    color: #5B8EE0;
    width: 30px;
    text-align: right;
    padding-right: 4px;
}

.bar-columns {
    display: flex;
    gap: 6px;
    flex: 1;
    align-items: flex-end;
    height: 100%;
    border-left: 2px solid #F0F0E8;
    border-bottom: 2px solid #F0F0E8;
    padding: 0 4px;
}

.bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
}

.bar-fill-inner {
    width: 100%;
    background: #38B764;
    border-top: 2px solid #4EE07B;
    height: 0;
    transition: height 0.6s steps(10);
}

.bar-day {
    font-family: 'Silkscreen', cursive;
    font-size: 8px;
    color: #F0F0E8;
    margin-top: 4px;
    text-align: center;
}

.bar-x-label {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #5B8EE0;
    text-align: center;
    margin-top: 8px;
    letter-spacing: 0.1em;
}

/* --- Line Chart (Level 2) --- */
#line-chart {
    position: relative;
    height: 120px;
    border-left: 2px solid #F0F0E8;
    border-bottom: 2px solid #F0F0E8;
    margin-top: 8px;
}

.line-grid {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.grid-line {
    border-bottom: 1px dashed rgba(240, 240, 232, 0.15);
    width: 100%;
}

.line-dots {
    position: absolute;
    inset: 0;
}

.dot {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #E06060;
    z-index: 2;
    opacity: 0;
}

.dot.vis {
    opacity: 1;
}

.line-connectors {
    position: absolute;
    inset: 0;
}

.connector {
    position: absolute;
    height: 2px;
    background: #E06060;
    transform-origin: left center;
    opacity: 0;
}

.connector.vis {
    opacity: 1;
}

/* --- Inventory Grid (Level 3) --- */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.inv-item {
    border: 2px solid #F0F0E8;
    padding: 12px 8px;
    text-align: center;
    background: rgba(26, 26, 46, 0.8);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.inv-sprite {
    width: 24px;
    height: 24px;
    image-rendering: pixelated;
}

/* Pixel art sprites via CSS */
.spr-coffee {
    background: #8B5E3C;
    border-bottom: 4px solid #8B5E3C;
    border-right: 4px solid #8B5E3C;
    width: 16px;
    height: 20px;
    position: relative;
}

.spr-coffee::after {
    content: '';
    position: absolute;
    top: 4px;
    right: -8px;
    width: 6px;
    height: 10px;
    border: 2px solid #8B5E3C;
    border-left: none;
}

.spr-bread {
    background: #F7D358;
    width: 22px;
    height: 16px;
    border-top: 4px solid #C4A02E;
}

.spr-transit {
    width: 24px;
    height: 16px;
    background: #5B8EE0;
    border-bottom: 4px solid #333;
    position: relative;
}

.spr-transit::before,
.spr-transit::after {
    content: '';
    position: absolute;
    bottom: -8px;
    width: 6px;
    height: 6px;
    background: #333;
}

.spr-transit::before { left: 2px; }
.spr-transit::after  { right: 2px; }

.spr-lunch {
    width: 20px;
    height: 8px;
    background: #F0F0E8;
    border-top: 6px solid #E06060;
    border-bottom: 4px solid #F7D358;
}

.spr-data {
    width: 18px;
    height: 22px;
    background: #1A1A2E;
    border: 2px solid #38B764;
    position: relative;
}

.spr-data::before {
    content: '';
    position: absolute;
    top: 4px;
    left: 3px;
    width: 8px;
    height: 2px;
    background: #38B764;
    box-shadow: 0 4px 0 #38B764, 0 8px 0 #38B764;
}

.spr-time {
    width: 22px;
    height: 22px;
    border: 2px solid #F7D358;
    position: relative;
}

.spr-time::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 50%;
    width: 2px;
    height: 8px;
    background: #F7D358;
    transform: translateX(-50%);
}

.spr-time::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 6px;
    height: 2px;
    background: #F7D358;
    transform: translate(-50%, -50%);
}

.inv-name {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #F0F0E8;
    letter-spacing: 0.05em;
}

.inv-cost {
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    color: #38B764;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mini-coin {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #F7D358;
    border-left: 1px solid #FFEEBB;
    border-top: 1px solid #FFEEBB;
    border-right: 1px solid #C4A02E;
    border-bottom: 1px solid #C4A02E;
}

.inv-note {
    font-style: normal;
    color: #5B8EE0;
}

/* --- Worth Grid (Level 4) --- */
.worth-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin: 20px 0;
}

.worth-card {
    border: 2px solid #F7D358;
    padding: 16px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: rgba(247, 211, 88, 0.05);
}

.worth-icon {
    width: 32px;
    height: 32px;
    position: relative;
}

/* Pixel art worth icons */
.icon-sunrise {
    background: #F7D358;
    width: 32px;
    height: 16px;
    margin-top: 16px;
    position: relative;
}

.icon-sunrise::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 8px;
    width: 4px;
    height: 12px;
    background: #F7D358;
    box-shadow: -8px 4px 0 #F7D358, 8px 4px 0 #F7D358, -12px 8px 0 #F7D358, 12px 8px 0 #F7D358;
}

.icon-talk {
    border: 2px solid #5B8EE0;
    width: 28px;
    height: 22px;
    position: relative;
}

.icon-talk::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 4px;
    width: 8px;
    height: 8px;
    background: #5B8EE0;
    clip-path: polygon(0 0, 100% 0, 0 100%);
}

.icon-walk {
    width: 12px;
    height: 28px;
    background: #38B764;
    position: relative;
}

.icon-walk::before {
    content: '';
    position: absolute;
    top: -10px;
    left: 1px;
    width: 10px;
    height: 10px;
    background: #38B764;
}

.icon-walk::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: -4px;
    width: 8px;
    height: 4px;
    background: #38B764;
    box-shadow: 8px 0 0 #38B764;
}

.icon-book {
    width: 24px;
    height: 20px;
    background: #E06060;
    border-top: 4px solid #E06060;
    position: relative;
}

.icon-book::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -4px;
    width: 32px;
    height: 4px;
    background: #E06060;
}

.icon-book::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 6px;
    width: 12px;
    height: 4px;
    background: #E06060;
}

.worth-name {
    font-family: 'Silkscreen', cursive;
    font-size: 10px;
    color: #F0F0E8;
    letter-spacing: 0.05em;
}

.worth-val {
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
}

/* --- Sunset Footer --- */
#sunset-footer {
    overflow: hidden;
    min-height: 80vh;
    justify-content: center;
}

#sunset-gradient {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    z-index: 0;
}

.sunset-band {
    flex: 1;
}

.sunset-band[data-band="0"] { background-color: #1A1A2E; }
.sunset-band[data-band="1"] { background-color: #2E1A3E; }
.sunset-band[data-band="2"] { background-color: #4A1A4A; }
.sunset-band[data-band="3"] { background-color: #6B2040; }
.sunset-band[data-band="4"] { background-color: #8B3030; }
.sunset-band[data-band="5"] { background-color: #C05030; }
.sunset-band[data-band="6"] { background-color: #E06060; }
.sunset-band[data-band="7"] { background-color: #F7D358; }

/* Pixel Stars */
.pixel-star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #F0F0E8;
    z-index: 1;
    animation: twinkle 2s steps(2) infinite;
}

.ps-1  { top: 4%;  left: 12%; animation-delay: 0s; }
.ps-2  { top: 9%;  left: 28%; animation-delay: 0.3s; }
.ps-3  { top: 2%;  left: 52%; animation-delay: 0.7s; }
.ps-4  { top: 13%; left: 74%; animation-delay: 1.1s; }
.ps-5  { top: 5%;  left: 88%; animation-delay: 0.5s; }
.ps-6  { top: 16%; left: 18%; animation-delay: 1.4s; }
.ps-7  { top: 3%;  left: 42%; animation-delay: 0.9s; }
.ps-8  { top: 19%; left: 63%; animation-delay: 0.2s; }
.ps-9  { top: 11%; left: 83%; animation-delay: 1.6s; }
.ps-10 { top: 21%; left: 6%;  animation-delay: 0.6s; }
.ps-11 { top: 8%;  left: 48%; animation-delay: 1.2s; }
.ps-12 { top: 15%; left: 36%; animation-delay: 0.8s; }

@keyframes twinkle {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.2; }
}

/* Footer Content */
#footer-text {
    position: relative;
    z-index: 5;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

#footer-text .display-text {
    color: #F7D358;
    text-shadow: 4px 4px 0 #1A1A2E;
}

.korean-text {
    color: #E06060;
    font-size: clamp(12px, 1.8vw, 16px);
}

#footer-ground {
    z-index: 3;
}

/* --- Background Patterns --- */
#level-1,
#level-3 {
    background-image:
        repeating-conic-gradient(
            rgba(240, 240, 232, 0.03) 0% 25%,
            transparent 0% 50%
        );
    background-size: 8px 8px;
}

#level-2,
#level-4 {
    background-image:
        repeating-linear-gradient(
            0deg,
            rgba(240, 240, 232, 0.02) 0px,
            rgba(240, 240, 232, 0.02) 2px,
            transparent 2px,
            transparent 4px
        );
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .inventory-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .worth-grid {
        grid-template-columns: 1fr;
    }

    .retro-window {
        width: 95%;
    }

    #pixel-sun {
        width: 44px;
        height: 44px;
    }

    .sun-core {
        width: 44px;
        height: 44px;
    }

    .ray-n  { top: -16px; left: 18px; width: 6px; height: 14px; }
    .ray-s  { bottom: -16px; left: 18px; width: 6px; height: 14px; }
    .ray-w  { left: -16px; top: 18px; width: 14px; height: 6px; }
    .ray-e  { right: -16px; top: 18px; width: 14px; height: 6px; }
}
