:root {
    --rust: #a0522d;
    --oil: #0a0a0a;
    --acid: #39ff14;
    --metal: #2c2c2c;
    --dirty-orange: #ff8c00;
}

* {
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--oil);
    color: var(--acid);
    font-family: 'Courier New', Courier, monospace;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    background-image: radial-gradient(circle, #1a1a1a 1px, transparent 1px);
    background-size: 20px 20px;
}

/* Oil/Dirt overlay when machines are broken */
#game-root {
    min-height: 100vh;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: hidden;
    transition: filter 0.5s ease;
}

#game-root.broken-world {
    filter: grayscale(0.8) contrast(1.2) blur(0.5px);
}

h1 {
    font-size: 22px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--dirty-orange);
    text-shadow: 2px 2px 0px #4b0000;
    margin-bottom: 2px;
    margin-top: 10px;
}

.subtitle {
    font-size: 12px;
    color: #555;
    margin-bottom: 15px;
    text-transform: uppercase;
}

.stats-container {
    width: 100%;
    max-width: 400px;
    background: var(--metal);
    border: 2px solid #444;
    padding: 10px;
    box-shadow: inset 0 0 10px #000;
    margin-bottom: 15px;
    position: relative;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    margin: 3px 0;
    font-size: 16px;
}

.zone-info {
    font-size: 13px;
    color: var(--dirty-orange);
    text-align: center;
    border-bottom: 1px solid #333;
    padding-bottom: 5px;
    margin-bottom: 10px;
}

.energy-bar-bg {
    width: 100%;
    height: 8px;
    background: #111;
    border: 1px solid #333;
    margin-top: 5px;
    position: relative;
}

#energy-fill {
    height: 100%;
    background: linear-gradient(90deg, #660000, #ff0000);
    width: 100%;
    transition: width 0.3s ease;
    box-shadow: 0 0 5px #ff0000;
}

#stencil-btn {
    width: 180px;
    height: 180px;
    border-radius: 50%;
    background: radial-gradient(circle, #333, #111);
    border: 8px solid #444;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5), inset 0 0 15px #000;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s, box-shadow 0.1s;
    margin: 10px 0;
}

#stencil-btn::before {
    content: "STENCIL";
    color: rgba(255, 255, 255, 0.05);
    font-weight: bold;
    font-size: 24px;
}

#stencil-btn:active {
    transform: scale(0.95);
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.8);
}

.shop-container {
    width: 100%;
    max-width: 400px;
    margin-top: 10px;
    border-top: 2px solid #333;
    padding-top: 10px;
}

.shop-item {
    background: #151515;
    border: 1px solid #333;
    padding: 8px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    position: relative;
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.shop-details h4 {
    margin: 0;
    color: var(--dirty-orange);
    font-size: 15px;
}

.shop-details p {
    margin: 2px 0;
    font-size: 12px;
    color: #777;
}

.durability-block {
    margin-top: 5px;
    display: flex;
    align-items: center;
    font-size: 12px;
    gap: 10px;
}

.durability-bar-bg {
    flex-grow: 1;
    height: 4px;
    background: #000;
    border: 1px solid #222;
}

.durability-fill {
    height: 100%;
    background: var(--acid);
    width: 100%;
}

.action-row {
    display: flex;
    gap: 5px;
    margin-top: 8px;
}

button.small-btn {
    flex: 1;
    background: var(--metal);
    color: var(--acid);
    border: 1px solid #444;
    padding: 5px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

button.small-btn:active {
    filter: brightness(1.2);
}

button.small-btn:disabled {
    color: #444;
    cursor: not-allowed;
    border-color: #222;
}

button.buy-btn {
    background: var(--rust);
    color: #fff;
    border: none;
    padding: 5px 10px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 2px 2px 0px #4b0000;
    font-size: 11px;
}

button.bribe-btn {
    width: 100%;
    max-width: 400px;
    background: var(--dirty-orange);
    color: #000;
    border: none;
    padding: 10px;
    margin-top: 20px;
    font-family: inherit;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
}

.buy-mode-row {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

button.mode-btn {
    flex: 1;
    background: var(--metal);
    color: #555;
    border: 1px solid #333;
    padding: 4px;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
}

button.mode-btn.active {
    color: var(--acid);
    border-color: var(--acid);
}

.glitch {
    animation: glitch 1s linear infinite;
}

@keyframes floatUp {
    0%   { opacity: 1; transform: translateX(-50%) translateY(0); }
    100% { opacity: 0; transform: translateX(-50%) translateY(-36px); }
}
.balance-pop {
    position: fixed;
    color: var(--acid);
    font-size: 13px;
    font-weight: bold;
    pointer-events: none;
    white-space: nowrap;
    animation: floatUp 1.1s ease-out forwards;
    z-index: 500;
}

@keyframes glitch {
    0%   { transform: translate(0); }
    20%  { transform: translate(-1.5px, 1.5px); }
    40%  { transform: translate(-1.5px, -1.5px); }
    60%  { transform: translate(1.5px, 1.5px); }
    80%  { transform: translate(1.5px, -1.5px); }
    100% { transform: translate(0); }
}

/* ===== TUTORIAL ===== */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes hintSlideIn {
    from { opacity: 0; transform: translateX(-50%) translateY(12px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Intro splash */
#intro-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 30px;
    box-sizing: border-box;
}
.intro-slide { display: none; animation: fadeIn 0.4s ease; text-align: center; }
.intro-slide.active { display: block; }
.intro-text {
    font-size: 20px;
    color: var(--acid);
    line-height: 1.8;
    margin-bottom: 30px;
    letter-spacing: 1px;
}
.intro-dots { display: flex; gap: 10px; justify-content: center; margin-bottom: 32px; }
.intro-dot { width: 8px; height: 8px; border: 1px solid #333; background: #0a0a0a; }
.intro-dot.active { background: var(--acid); box-shadow: 0 0 6px var(--acid); }
.intro-btn-row { display: flex; gap: 10px; }
.intro-btn {
    background: var(--metal);
    color: var(--acid);
    border: 1px solid #444;
    padding: 8px 16px;
    font-family: inherit;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.intro-btn.primary { border-color: var(--acid); }
.intro-btn.muted { color: #444; border-color: #222; }

/* Spotlight */
#spotlight-overlay {
    position: fixed;
    inset: 0;
    z-index: 1500;
    pointer-events: none;
}
#spotlight-hole {
    position: fixed;
    border: 2px solid var(--acid);
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.87);
    pointer-events: none;
    transition: top 0.35s ease, left 0.35s ease, width 0.35s ease, height 0.35s ease;
    box-sizing: border-box;
}
#spotlight-tooltip {
    position: fixed;
    background: #070f07;
    border: 1px solid var(--acid);
    color: var(--acid);
    padding: 12px 14px;
    font-size: 13px;
    width: calc(100vw - 40px);
    max-width: 360px;
    left: 20px;
    line-height: 1.5;
    pointer-events: all;
    box-shadow: 0 0 16px rgba(57,255,20,0.15);
    box-sizing: border-box;
    transition: top 0.35s ease;
}
.spot-step-label { font-size: 10px; color: #444; margin-bottom: 6px; letter-spacing: 1px; }
.spot-tip-text { margin-bottom: 12px; }
.spotlight-nav { display: flex; gap: 6px; }
.spot-nav-btn {
    flex: 1;
    background: var(--metal);
    color: var(--acid);
    border: 1px solid #444;
    padding: 6px 4px;
    font-family: inherit;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    text-transform: uppercase;
}
.spot-nav-btn.muted { color: #444; border-color: #222; }
.spot-nav-btn:disabled { color: #333; border-color: #1a1a1a; cursor: not-allowed; }

/* Broken world alert */
.broken-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #0a0000;
    border: 2px solid #ff2200;
    color: #ff6600;
    padding: 14px 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 9999;
    text-align: center;
    max-width: 280px;
    width: calc(100vw - 60px);
    box-shadow: 0 0 20px rgba(255,34,0,0.4);
    text-shadow: 0 0 8px #ff4400;
    animation: fadeIn 0.3s ease;
    line-height: 1.6;
    box-sizing: border-box;
}

/* Contextual hints */
.ctx-hint {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #070f07;
    border: 1px solid var(--acid);
    color: var(--acid);
    padding: 10px 18px;
    font-size: 12px;
    z-index: 900;
    text-align: center;
    max-width: 300px;
    width: calc(100vw - 40px);
    animation: hintSlideIn 0.3s ease;
    box-shadow: 0 0 14px rgba(57,255,20,0.2);
    line-height: 1.5;
    box-sizing: border-box;
}
