/* RUST RIG */
* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: #120a06;
    color: #fff1e0;
    font-family: 'Orbitron', Arial, sans-serif;
}

[hidden] { display: none !important; }

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

body.in-game { overflow: hidden; overscroll-behavior: none; }
body.in-game #game { display: block; }
body.in-game .main-nav, body.in-game .fx-canvas { display: none; }

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

#menu {
    position: relative;
    z-index: 1;
    gap: 16px;
    padding: 48px 16px 24px;
    min-height: calc(100vh - 60px);
}

.title {
    margin: 0;
    font-size: clamp(42px, 10vw, 104px);
    font-weight: 900;
    letter-spacing: 4px;
    color: #ff9a3d;
    text-shadow: 0 4px 0 #6d2c08, 0 0 34px rgba(255, 122, 26, 0.55);
}

.tag { margin: 0 0 14px; color: #d8bda3; font-size: clamp(12px, 2vw, 16px); letter-spacing: 1px; }

.row { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

.btn {
    min-height: 44px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 154, 61, 0.6);
    border-radius: 10px;
    background: rgba(32, 18, 10, 0.88);
    color: #ffe9d2;
    font: 700 13px 'Orbitron', Arial, sans-serif;
    letter-spacing: 1px;
    cursor: pointer;
    transition: transform .12s, box-shadow .2s, background .2s;
}

.btn:hover { background: rgba(255, 154, 61, 0.16); box-shadow: 0 0 18px rgba(255, 154, 61, 0.35); transform: translateY(-1px); }
.btn:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.btn.primary { padding: 16px 44px; border: 0; background: #ff9a3d; color: #241005; font-size: 20px; font-weight: 900; box-shadow: 0 5px 0 #8a3b0c, 0 0 28px rgba(255, 154, 61, 0.45); }
.btn.primary:hover { background: #ffb36b; }
.btn.danger { border-color: rgba(255, 70, 70, 0.7); color: #ff9a9a; }

.best { min-height: 18px; color: #ffd60a; font-size: 13px; letter-spacing: 1px; }

.seo {
    max-width: 720px;
    margin-top: 18px;
    padding: 16px 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    background: rgba(24, 14, 8, 0.78);
    font-family: Arial, sans-serif;
    color: #c9b6a3;
    font-size: 14px;
    line-height: 1.6;
    text-align: left;
}

.seo h2 { margin: 0 0 8px; font: 700 15px 'Orbitron', Arial, sans-serif; color: #fff1e0; }
.seo strong { color: #ff9a3d; }
.seo p { margin: 0; }

/* HUD */
#hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 5;
    padding: env(safe-area-inset-top) 10px 0;
    pointer-events: none;
}

.xp { position: relative; height: 16px; margin: 6px 0; border: 1px solid rgba(255, 214, 10, 0.6); border-radius: 5px; background: rgba(0, 0, 0, 0.6); overflow: hidden; }
#xp-fill { height: 100%; width: 0; background: linear-gradient(90deg, #ff9a3d, #ffd60a); }
#xp-level { position: absolute; inset: 0; font-size: 10px; font-weight: 900; line-height: 14px; text-shadow: 0 0 3px #000, 0 0 3px #000; }

.hud-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 10px; }
.bars { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.bar { position: relative; height: 16px; max-width: 230px; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 5px; background: rgba(0, 0, 0, 0.6); overflow: hidden; }
.bar > div { height: 100%; width: 0; }
.bar span { position: absolute; inset: 0; text-align: center; font-size: 9px; font-weight: 700; line-height: 14px; letter-spacing: 1px; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.bar.power { border-color: rgba(72, 214, 255, 0.7); }
#power-fill { background: linear-gradient(90deg, #1279d6, #48d6ff); }
.bar.power.low { animation: power-low .4s infinite alternate; }
.bar.road { border-color: rgba(255, 154, 61, 0.7); }
#road-fill { background: linear-gradient(90deg, #a84a12, #ff9a3d); }

@keyframes power-low { to { border-color: #ff4646; box-shadow: 0 0 12px #ff4646; } }

#zone { font-size: clamp(13px, 2.6vw, 22px); font-weight: 900; color: #fff; letter-spacing: 1px; text-shadow: 0 2px 0 rgba(0, 0, 0, .7), 0 0 10px rgba(0, 0, 0, .6); }

.hud-right { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 14px; color: #ffd60a; text-shadow: 0 1px 3px #000; }
.hud-right span { color: #fff; font-weight: 900; font-size: 15px; }

#btn-pause, #btn-fs {
    pointer-events: auto;
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

#boss-bar { position: relative; width: min(560px, 92%); height: 18px; margin: 6px auto 0; border: 1px solid #ff4646; border-radius: 5px; background: rgba(0, 0, 0, 0.7); overflow: hidden; }
#boss-fill { height: 100%; background: linear-gradient(90deg, #ff2d2d, #ff9a3d); }
#boss-name { position: absolute; inset: 0; font-size: 10px; font-weight: 900; line-height: 16px; letter-spacing: 2px; text-shadow: 0 0 3px #000, 0 0 3px #000; }

#place-hint {
    width: fit-content;
    max-width: 92%;
    margin: 10px auto 0;
    padding: 8px 14px;
    border: 1px solid #ffd60a;
    border-radius: 9px;
    background: rgba(0, 0, 0, 0.78);
    color: #ffe98a;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
}

/* Gumbi za akcije */
#actions {
    position: fixed;
    right: calc(10px + env(safe-area-inset-right));
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 5;
    display: flex;
    gap: 8px;
}

.act {
    position: relative;
    width: 86px;
    height: 62px;
    padding: 0;
    border: 2px solid #ff9a3d;
    border-radius: 12px;
    background: rgba(24, 12, 6, 0.86);
    color: #fff;
    cursor: pointer;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
}

.act i { position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--cd, 0) * 100%); background: rgba(0, 0, 0, 0.66); }
.act b { position: relative; display: block; font: 900 10px 'Orbitron', Arial, sans-serif; letter-spacing: .5px; }
.act span { position: relative; display: block; margin-top: 4px; font: 700 8px 'Orbitron', Arial, sans-serif; color: #c9a98c; }
.act.ready { box-shadow: 0 0 14px rgba(255, 154, 61, 0.6); }
#btn-over { border-color: #48d6ff; }
#btn-over.ready { box-shadow: 0 0 14px rgba(72, 214, 255, 0.6); }

/* Prozori preko igre */
.modal {
    position: fixed;
    inset: 0;
    z-index: 10;
    justify-content: center;
    gap: 16px;
    padding: 16px;
    overflow-y: auto;
    background: rgba(14, 7, 3, 0.78);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.modal h2 { margin: 0; font-size: clamp(24px, 5vw, 42px); font-weight: 900; letter-spacing: 3px; color: #ff9a3d; text-shadow: 0 3px 0 #5c2506; }

#cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; width: 100%; max-width: 900px; }

.card {
    position: relative;
    flex: 1 1 220px;
    max-width: 280px;
    min-height: 210px;
    padding: 16px 14px;
    border: 2px solid var(--c);
    border-radius: 14px;
    background: linear-gradient(180deg, #33200f, #170c05);
    box-shadow: 0 6px 0 rgba(0, 0, 0, .45);
    color: #fff1e0;
    font-family: 'Orbitron', Arial, sans-serif;
    cursor: pointer;
    transition: transform .12s, box-shadow .15s;
    animation: card-in .22s cubic-bezier(.2, 1.4, .4, 1) backwards;
}

.card:hover, .card:focus-visible { transform: translateY(-5px) scale(1.02); box-shadow: 0 0 26px var(--c); outline: 0; }
.card canvas { display: block; width: 72px; height: 72px; margin: 0 auto; }
.card h3 { margin: 8px 0 4px; font-size: 15px; color: var(--c); letter-spacing: 1px; }
.card .kind { font-size: 10px; letter-spacing: 2px; color: #b89d84; }
.card p { margin: 10px 0 0; font: 13px/1.45 Arial, sans-serif; color: #e3d2c0; }
.card .key { position: absolute; top: 8px; left: 10px; font-size: 11px; color: #8c745e; }

@keyframes card-in { from { opacity: 0; transform: translateY(24px) scale(.9); } }

@media (max-height: 560px), (max-width: 720px) {
    .modal { justify-content: flex-start; gap: 10px; }
    .act { width: 76px; height: 54px; }
}

#pause-stats, #over-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; width: min(560px, 100%); }
.stat { padding: 10px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; background: rgba(0, 0, 0, 0.4); }
.stat b { display: block; font-size: 20px; color: #fff; }
.stat span { font-size: 10px; letter-spacing: 1px; color: #b89d84; }
.stat.hl b { color: #ffd60a; }

#panel-body { display: flex; flex-direction: column; gap: 8px; width: min(560px, 100%); text-align: left; }
#panel-body .help { font: 14px/1.6 Arial, sans-serif; color: #e3d2c0; }
#panel-body .help b { color: #ff9a3d; }

.shop-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px; background: rgba(0, 0, 0, 0.4); }
.shop-row h3 { margin: 0; font-size: 13px; color: #ff9a3d; }
.shop-row p { margin: 3px 0 0; font: 12px Arial, sans-serif; color: #c9b6a3; }
.credits { color: #ffd60a; font-size: 15px; font-weight: 900; text-align: center; }

/* Garaža */
#garage {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(430px, 50vw);
    padding: calc(8px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) 10px;
    border-left: 2px solid rgba(255, 154, 61, .55);
    background: rgba(24, 13, 7, .95);
}
.gar-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.gar-head .btn { padding: 8px 12px; }
.gar-head strong { font-size: 15px; color: #ffb36b; letter-spacing: 1px; text-align: center; }
.gar-cash { color: #ffd60a; font-size: 13px; white-space: nowrap; }
.gar-cash b { color: #fff; font-size: 15px; }
.gar-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.gar-tab { padding: 8px 4px; font-size: 11px; }
.gar-tab.on { background: #ff9a3d; color: #241005; }
#gar-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding-right: 2px; }
.gar-title { margin: 12px 0 6px; color: #ffb36b; font-size: 11px; letter-spacing: 1px; }
.gar-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.gar-nav strong { font-size: 13px; }
.gar-nav .btn { min-width: 52px; padding: 8px; }
.gar-nav.small .btn { flex: 1; font-size: 10px; }
.gar-row { display: flex; align-items: center; gap: 8px; min-height: 56px; margin-bottom: 5px; padding: 6px 8px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 9px; background: rgba(0, 0, 0, .35); }
.gar-row canvas { flex: none; width: 44px; height: 44px; }
.gar-info { flex: 1; min-width: 0; }
.gar-info h4 { margin: 0; color: #fff1e0; font-size: 11px; letter-spacing: .5px; }
.gar-info p { margin: 2px 0 0; color: #c9b6a3; font: 12px/1.3 Arial, sans-serif; }
.gar-buy { flex: none; min-width: 78px; padding: 8px 6px; font-size: 12px; }
#btn-go { flex: none; padding: 12px; font-size: 18px; }

@media (orientation: portrait) {
    #garage { top: auto; left: 0; width: 100%; height: 56%; border-left: 0; border-top: 2px solid rgba(255, 154, 61, .55); }
}

#hud { padding-top: calc(6px + env(safe-area-inset-top)); }
#gar-body { scrollbar-width: thin; scrollbar-color: #8a4f22 transparent; }
#gar-body::-webkit-scrollbar { width: 6px; }
#gar-body::-webkit-scrollbar-thumb { background: #8a4f22; border-radius: 3px; }
