/* GLITCH RALLY */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    background: #0b0e0c;
    color: #e9f2ec;
    font-family: ui-monospace, 'JetBrains Mono', Consolas, Menlo, monospace;
}

[hidden] { display: none !important; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

.screen { display: flex; flex-direction: column; align-items: center; text-align: center; }

#menu {
    position: fixed;
    inset: 0;
    z-index: 3;
    justify-content: center;
    gap: 16px;
    padding: 20px;
    overflow-y: auto;
    background: rgba(8, 12, 10, 0.55);
}

#menu h1 {
    margin: 0;
    color: #ffffff;
    font-size: clamp(44px, 10vw, 104px);
    font-weight: 900;
    letter-spacing: 2px;
    text-shadow: 4px 0 0 #ff5c8a, -4px 0 0 #39ff88;
}
#menu h1 span { color: #39ff88; text-shadow: 4px 0 0 #ff5c8a; }

.tag { margin: 0 0 12px; color: #d3e2d8; font-size: clamp(14px, 2vw, 18px); }
.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.btn {
    min-height: 46px;
    padding: 10px 18px;
    border: 1px solid #5a6e62;
    border-radius: 7px;
    background: #101511;
    color: #e9f2ec;
    font: 700 14px ui-monospace, Consolas, monospace;
    cursor: pointer;
}
.btn:hover { border-color: #39ff88; color: #39ff88; }
.btn.primary { padding: 15px 34px; border: 0; background: #39ff88; color: #06140c; font-size: 20px; }
.btn.primary:hover { background: #7dffaf; color: #06140c; }

#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 10px 0;
    pointer-events: none;
    text-shadow: 0 2px 0 rgba(0, 0, 0, .75);
}
.hud-col { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.hud-col.right { align-items: flex-end; }

.meter { position: relative; width: min(220px, 100%); height: 18px; overflow: hidden; border: 1px solid #39ff88; border-radius: 4px; background: rgba(0, 0, 0, .65); }
.meter > div { height: 100%; width: 100%; background: #39ff88; }
.meter span { position: absolute; inset: 0; color: #fff; font-size: 11px; font-weight: 700; line-height: 16px; text-align: center; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.meter.nitro { border-color: #7ae7ff; }
.meter.nitro > div { background: #1fb7e0; }

.hud-mid { text-align: center; }
#time { color: #fff; font-size: clamp(32px, 6vw, 54px); font-weight: 900; line-height: 1; }
#time.low { color: #ff5c8a; }
#sector { margin-top: 2px; color: #d9ffe7; font-size: 12px; font-weight: 700; }
#score { color: #fff; font-size: 22px; font-weight: 900; line-height: 1; }
#speed { color: #d9ffe7; font-size: 12px; font-weight: 700; }

.hud-btns { display: flex; gap: 6px; margin-top: 3px; pointer-events: auto; }
.hud-btns button { min-width: 44px; height: 44px; padding: 0 10px; border: 1px solid #5a6e62; border-radius: 7px; background: rgba(0, 0, 0, .68); color: #fff; font: 700 12px ui-monospace, Consolas, monospace; cursor: pointer; }
#btn-cheats { border-color: #39ff88; color: #39ff88; }

#cheat-flag {
    position: fixed;
    left: 50%;
    top: calc(92px + env(safe-area-inset-top));
    z-index: 2;
    max-width: 90%;
    padding: 4px 10px;
    border: 1px solid #39ff88;
    border-radius: 5px;
    background: rgba(0, 0, 0, .72);
    color: #7dffaf;
    font-size: 11px;
    font-weight: 700;
    pointer-events: none;
    transform: translateX(-50%);
}

#touch { position: fixed; inset: auto 0 0 0; z-index: 2; display: none; justify-content: space-between; gap: 8px; padding: 0 10px calc(10px + env(safe-area-inset-bottom)); pointer-events: none; }
#touch button { width: 76px; height: 68px; border: 2px solid rgba(255, 255, 255, .5); border-radius: 12px; background: rgba(0, 0, 0, .45); color: #fff; font: 700 13px ui-monospace, Consolas, monospace; pointer-events: auto; touch-action: none; -webkit-user-select: none; user-select: none; }
#t-left { order: 1; }
#t-right { order: 2; margin-right: auto; }
#t-jump { order: 3; border-color: #39ff88; }
#t-nitro { order: 4; border-color: #7ae7ff; }
#touch button.on { background: rgba(255, 255, 255, .28); }

@media (pointer: coarse) {
    #touch { display: flex; }
    #touch[hidden] { display: none !important; }
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 5;
    justify-content: center;
    gap: 14px;
    padding: 16px;
    overflow-y: auto;
    background: rgba(5, 8, 6, .84);
}
.modal h2 { margin: 0; color: #39ff88; font-size: clamp(26px, 5vw, 42px); font-weight: 900; }

#panel-body { display: flex; flex-direction: column; gap: 8px; width: min(520px, 100%); text-align: left; }
#panel-body .help { color: #d3e2d8; font-family: Arial, sans-serif; font-size: 15px; line-height: 1.5; }
#panel-body .help b { color: #39ff88; }
#panel-body .note { margin: 4px 0 0; color: #c7d3cb; font-size: 13px; }

.cheat { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 56px; padding: 8px 12px; border: 1px solid #5a6e62; border-radius: 7px; background: #0b0e0c; color: #e9f2ec; font: inherit; text-align: left; cursor: pointer; }
.cheat small { display: block; margin-top: 2px; color: #c7d3cb; font-size: 12px; }
.cheat b { font-size: 14px; }
.cheat i { flex: none; font-style: normal; font-weight: 900; font-size: 13px; }
.cheat.on { border-color: #39ff88; background: #39ff88; color: #06140c; }
.cheat.on small { color: #06240f; }

#over-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; width: min(560px, 100%); }
.stat { padding: 10px; border: 1px solid #3a4a40; border-radius: 8px; background: #101511; }
.stat b { display: block; color: #fff; font-size: 21px; }
.stat span { color: #c7d3cb; font-size: 11px; }

.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.board h3 { margin: 0 0 6px; color: #39ff88; font-size: 15px; }
.board ol { margin: 0; padding-left: 26px; color: #e9f2ec; font-size: 14px; }
.board p { margin: 0; color: #c7d3cb; font-size: 13px; }

.promo { margin: 4px 0 0; color: #d3e2d8; font-size: 14px; }
.promo a { display: inline-block; padding: 8px 4px; color: #39ff88; font-weight: 700; }

.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.site-home { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 12px; z-index: 4; }
