/*
 * chanda-vi : styles
 * ---------------------------------------------------------------------------
 *   1. Font and page
 *   2. Top bar (HUD) and route line
 *   3. Messages (prompt, payment bar, toast)
 *   4. Touch buttons
 *   5. Start and result screens
 *   6. Result chart and table
 * The smallest text on the screen is 15px.
 */

/* ---------- 1. Font and page ---------- */

@font-face {
    font-family: "Noto Sans Bengali";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/noto-sans-bengali-bengali.woff2") format("woff2");
    unicode-range: U+0951-0952, U+0964-0965, U+0980-09FE, U+1CD0, U+1CD2, U+1CD5-1CD6, U+1CD8, U+1CE1, U+1CEA, U+1CED, U+1CF2, U+1CF5-1CF7, U+200C-200D, U+20B9, U+25CC, U+A8F1, U+11DF0-11DF1;
}
@font-face {
    font-family: "Noto Sans Bengali";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/noto-sans-bengali-latin-ext.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Noto Sans Bengali";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/noto-sans-bengali-latin.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #1a110b;
    --panel: rgba(30, 20, 13, 0.94);
    --line: rgba(255, 255, 255, 0.14);
    --text: #fff4e6;
    --muted: #d9c3a8;
    --amber: #f5a623;
    --red: #e8503f;
    --blue: #4aa8e8;
    --green: #5cc46a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: "Noto Sans Bengali", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-user-select: none;
    user-select: none;
    touch-action: none;
}

#scene {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.hidden { display: none !important; }

/* ---------- 2. Top bar (HUD) and route line ---------- */

.hud {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    right: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    pointer-events: none;
}
.hud-box {
    display: flex;
    flex-direction: column;
    min-width: 92px;
    padding: 6px 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 12px;
}
.hud-label { font-size: 15px; color: var(--muted); }
.hud-value { font-size: 17px; font-weight: 600; }
.hud-value b { font-size: 21px; }
.hud-red { border-color: var(--red); }
.hud-red .hud-value b { color: var(--red); }
.hud-blue { border-color: var(--blue); }
.hud-blue .hud-value b { color: var(--blue); }
.hud-limit { border-color: var(--amber); }
.hud-limit .hud-value b { color: var(--amber); }

.route {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(100px, calc(env(safe-area-inset-bottom) + 100px));
    pointer-events: none;
}
.route-line {
    position: relative;
    height: 8px;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 6px;
}
.route-truck {
    position: absolute;
    top: -16px;
    left: 0;
    font-size: 22px;
    transform: translateX(-50%) scaleX(-1);
}
.route-names {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 15px;
    color: var(--muted);
}

/* ---------- 3. Messages ---------- */

.prompt {
    position: fixed;
    top: 17%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(92vw, 560px);
    padding: 10px 18px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    background: var(--panel);
    border: 1px solid var(--amber);
    border-radius: 14px;
    pointer-events: none;
}

.pay-box {
    position: fixed;
    top: 44%;
    left: 50%;
    transform: translateX(-50%);
    width: min(90vw, 380px);
    padding: 12px 16px;
    text-align: center;
    background: var(--panel);
    border: 1px solid var(--red);
    border-radius: 14px;
    pointer-events: none;
}
.pay-text { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.pay-track { height: 12px; background: rgba(255, 255, 255, 0.18); border-radius: 8px; overflow: hidden; }
.pay-bar { width: 0; height: 100%; background: var(--red); }

.toast {
    position: fixed;
    top: 34%;
    left: 50%;
    transform: translateX(-50%);
    width: max-content;
    max-width: min(92vw, 520px);
    padding: 10px 18px;
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    background: rgba(232, 80, 63, 0.95);
    border-radius: 14px;
    pointer-events: none;
}
.toast.good { background: rgba(60, 150, 80, 0.95); }

/* ---------- 4. Touch buttons ---------- */

.controls {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
}
.ctl-group { display: flex; gap: 12px; }
.ctl {
    pointer-events: auto;
    width: 76px;
    height: 76px;
    font-family: inherit;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    background: rgba(30, 20, 13, 0.82);
    border: 2px solid var(--line);
    border-radius: 50%;
    touch-action: none;
}
.ctl.on { background: var(--amber); color: #1a110b; }
.ctl-gas { border-color: var(--green); }
.ctl-brake { border-color: var(--red); }

/* ---------- Loading screen, vignette, sound button ---------- */

.loading { z-index: 50; background: var(--bg); }
.loading-box { width: min(90vw, 380px); text-align: center; }
.loading-title { font-size: 40px; font-weight: 700; color: var(--amber); }
#loadingText { margin: 6px 0 14px; color: var(--muted); }
.vignette {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.38) 100%);
}
.mute {
    position: fixed;
    right: 12px;
    top: 12px;
    width: 44px;
    height: 44px;
    font-size: 20px;
    color: var(--text);
    background: rgba(30, 20, 13, 0.82);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
}
.ctl-horn { border-color: var(--amber); font-size: 17px; }

/* ---------- 5. Start and result screens ---------- */

.screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow-y: auto;
    background: rgba(10, 6, 3, 0.55);
    touch-action: pan-y;
    z-index: 10;
}
.screen.loading { z-index: 50; }
.panel {
    width: min(100%, 640px);
    max-height: 100%;
    overflow-y: auto;
    padding: 22px 22px 26px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 18px;
}
.panel-wide { width: min(100%, 760px); }

.title { margin: 0; font-size: 42px; line-height: 1.2; color: var(--amber); }
.title.small { font-size: 30px; }
.tagline { margin: 4px 0 14px; font-size: 17px; color: var(--muted); }
.sub { margin: 14px 0 8px; font-size: 18px; }

.field-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.field-card {
    padding: 10px 12px;
    text-align: left;
    font-family: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 2px solid var(--line);
    border-radius: 14px;
    cursor: pointer;
}
.field-card.active { border-color: var(--amber); background: rgba(245, 166, 35, 0.16); }
.field-name { display: block; font-size: 20px; font-weight: 700; }
.field-price { display: block; font-size: 17px; color: var(--amber); }
.field-meta { display: block; font-size: 15px; color: var(--muted); }

.how { margin: 14px 0; padding-left: 20px; font-size: 15px; color: var(--muted); }
.how li { margin-bottom: 4px; }
.how b { color: var(--text); }

.sponsors { margin: 0 0 14px; font-size: 15px; color: var(--muted); }
.sponsors b { color: var(--amber); }
.sponsors a { color: var(--text); }

.btn {
    display: block;
    width: 100%;
    padding: 13px 20px;
    font-family: inherit;
    font-size: 20px;
    font-weight: 700;
    color: #1a110b;
    background: var(--amber);
    border: 0;
    border-radius: 14px;
    cursor: pointer;
}
.btn:active { transform: translateY(1px); }
.btn-row { margin-top: 16px; }

/* ---------- 6. Result chart and table ---------- */

.big-number {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    margin-bottom: 4px;
    background: rgba(232, 80, 63, 0.14);
    border: 1px solid var(--red);
    border-radius: 14px;
}
.big-label { font-size: 17px; color: var(--muted); }
.big-value { font-size: 20px; font-weight: 700; }
.big-value b { font-size: 46px; color: var(--red); line-height: 1.2; }

.stack { display: flex; height: 34px; overflow: hidden; border-radius: 10px; background: rgba(255, 255, 255, 0.08); }
.stack div { height: 100%; min-width: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 15px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }

.c-buy { background: #8bc34a; }
.c-fuel { background: #9e9e9e; }
.c-toll { background: #4aa8e8; }
.c-chanda { background: #e8503f; }
.c-fine { background: #f5a623; }
.c-spoil { background: #8d6e63; }
.c-rest { background: #7e57c2; }

.table { width: 100%; margin-top: 14px; border-collapse: collapse; font-size: 16px; }
.table td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
.table td:last-child { text-align: right; font-weight: 600; }
.table tr.total td { border-bottom: 0; font-size: 18px; color: var(--amber); }

.hint { margin: 0 0 8px; font-size: 15px; color: var(--muted); }
.log-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 6px 2px; border-bottom: 1px solid var(--line); }
.log-line span { flex: 1; min-width: 160px; }
.tag { font-style: normal; font-size: 15px; padding: 1px 10px; border-radius: 10px; border: 1px solid var(--line); }
.tag-official { color: #6fd388; border-color: #6fd388; }
.tag-reported { color: #7cc4f4; border-color: #7cc4f4; }
.tag-derived { color: #b9a4f0; border-color: #b9a4f0; }
.tag-estimate { color: #f5a623; border-color: #f5a623; }
.tag-satire { color: #f0806f; border-color: #f0806f; }
.sources-list { margin: 0; padding-left: 20px; font-size: 15px; }
.sources-list li { margin-bottom: 6px; }
.sources-list a { color: var(--amber); word-break: break-word; }
.prompt { white-space: pre-line; }

/* ---------- Choice at a barricade, haggling, chase, pause ---------- */

.choice {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(92vw, 460px);
    padding: 14px;
    background: var(--panel);
    border: 2px solid var(--red);
    border-radius: 16px;
}
.choice-title { font-size: 20px; font-weight: 700; color: var(--red); }
.choice-story { margin: 2px 0 10px; font-size: 15px; color: var(--muted); }
.choice-btn {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 8px;
    width: 100%;
    margin-top: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 17px;
    text-align: left;
    color: var(--text);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
}
.choice-btn:hover { border-color: var(--amber); }
.choice-btn b { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; color: #1a110b; background: var(--amber); border-radius: 50%; }
.choice-btn i { font-style: normal; font-size: 15px; color: var(--muted); }

.haggle {
    position: fixed;
    left: 50%;
    top: 40%;
    transform: translateX(-50%);
    width: min(92vw, 420px);
    padding: 14px;
    text-align: center;
    background: var(--panel);
    border: 2px solid var(--amber);
    border-radius: 16px;
}
.haggle-text { margin-bottom: 10px; font-size: 17px; font-weight: 600; }
.haggle-track { position: relative; height: 26px; margin-bottom: 12px; background: rgba(255, 255, 255, 0.16); border-radius: 14px; overflow: hidden; }
.haggle-zone { position: absolute; left: 40%; width: 20%; top: 0; bottom: 0; background: rgba(92, 196, 106, 0.7); }
.haggle-marker { position: absolute; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: #fff; }

.chase {
    position: fixed;
    left: 50%;
    top: 14%;
    transform: translateX(-50%);
    width: min(92vw, 400px);
    padding: 8px 14px;
    text-align: center;
    font-weight: 700;
    background: rgba(120, 20, 20, 0.92);
    border: 2px solid var(--red);
    border-radius: 14px;
    pointer-events: none;
}
.chase-bar { background: var(--green); }
.pause {
    position: fixed;
    left: 50%;
    top: 45%;
    transform: translateX(-50%);
    padding: 14px 24px;
    font-size: 22px;
    font-weight: 700;
    background: var(--panel);
    border: 2px solid var(--amber);
    border-radius: 16px;
}
.fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; }
.hud-cash { border-color: var(--green); }
.hud-cash .hud-value b { color: var(--green); }

/* ---------- Buying screen and score ---------- */

.buy-row { display: flex; justify-content: space-between; padding: 7px 2px; border-bottom: 1px solid var(--line); font-size: 17px; }
.slider-label { display: block; margin: 16px 0 6px; font-size: 18px; }
#buyKg { width: 100%; accent-color: var(--amber); }
.score-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0 4px; }
.score-row div { padding: 8px; text-align: center; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); border-radius: 12px; }
.score-row span { display: block; font-size: 15px; color: var(--muted); }
.score-row b { font-size: 24px; color: var(--amber); }
.btn.ghost { color: var(--text); background: transparent; border: 1px solid var(--line); }
.btn-row + .btn-row { margin-top: 8px; }

/* ---------- The new HUD: info card, route icons, top right buttons, speedometer, cab view ---------- */

.hud {
    top: max(10px, env(safe-area-inset-top));
    left: 10px;
    right: auto;
    flex-direction: column;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: flex-start;
}
.hud-card { min-width: 230px; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; }
.hud-line { display: flex; justify-content: space-between; gap: 14px; padding: 2px 0; font-size: 15px; }
.hud-line span { color: var(--muted); }
.hud-line b { font-size: 17px; }
.hud-line i { font-style: normal; }
.hud-line.hud-red b { color: var(--red); }
.hud-line.hud-blue b { color: var(--blue); }
.hud-limit {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 96px;
    padding: 6px 4px;
    background: #fff;
    color: #b02a1a;
    border: 6px solid #d93a2b;
    border-radius: 50%;
    line-height: 1.15;
    text-align: center;
}
.hud-limit span { font-size: 15px; font-weight: 600; }
.hud-limit b { font-size: 30px; color: #1a110b; }

.route { left: 270px; right: 330px; top: max(14px, env(safe-area-inset-top)); bottom: auto; }
.route-line { height: 10px; margin-top: 22px; }
.route-icon { position: absolute; top: -24px; font-size: 18px; transform: translateX(-50%); line-height: 1; }
.route-icon.done { opacity: 0.3; filter: grayscale(1); }
.route-names { margin-top: 6px; }

.top-right { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 64px; display: flex; gap: 8px; align-items: center; }
.chip { padding: 6px 12px; font-size: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; }
.round-btn {
    width: 44px;
    height: 44px;
    font-size: 19px;
    color: var(--text);
    background: rgba(30, 20, 13, 0.82);
    border: 1px solid var(--line);
    border-radius: 50%;
    cursor: pointer;
}

.speedo { position: fixed; left: 50%; bottom: 0; width: 178px; height: 178px; transform: translateX(-50%); pointer-events: none; }

.cockpit { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.ck-beam { position: absolute; top: 0; left: 0; right: 0; height: 13vh; background: linear-gradient(#4a2410, #6b3718); border-bottom: 6px solid #2c1508; }
.ck-bunting { position: absolute; left: 4%; right: 4%; bottom: -36px; display: flex; justify-content: space-between; }
.ck-bunting i { width: 3.2vw; height: 34px; clip-path: polygon(0 0, 100% 0, 50% 100%); }
.ck-pillar { position: absolute; top: 12vh; bottom: 0; width: 8vw; background: linear-gradient(#5b2d12, #3a1b0b); }
.ck-left { left: 0; clip-path: polygon(0 0, 100% 0, 55% 100%, 0 100%); }
.ck-right { right: 0; clip-path: polygon(0 0, 100% 0, 100% 100%, 45% 100%); }
.ck-mirror { position: absolute; top: 13vh; left: 38%; width: 14vw; height: 6vh; background: #111; border: 3px solid #333; border-radius: 6px; }
.ck-dash { position: absolute; left: 50%; bottom: 8vh; width: min(560px, 62vw); transform: translateX(-50%); background: #090909; clip-path: polygon(8% 0, 92% 0, 100% 100%, 0 100%); padding: 18px 0 0; }
.ck-dash canvas { display: block; width: 100%; height: auto; }
.ck-bottom { position: absolute; left: 0; right: 0; bottom: 0; height: 9vh; background: linear-gradient(#8a0a0a, #5a0505); border-top: 8px solid #1a0505; }

/* the cab view stays behind every information box */
.cockpit { z-index: 1; }
.hud, .route, .top-right, .prompt, .toast, .pay-box, .chase, .speedo { z-index: 5; }
.choice, .haggle, .pause { z-index: 8; }
.fade { z-index: 9; }

@media (max-width: 640px) {
    .hud-card { min-width: 190px; padding: 6px 9px; }
    .hud-line { font-size: 14px; }
    .route { left: 10px; right: 10px; top: auto; bottom: 168px; }
    .top-right { right: 60px; }
    .speedo { width: 150px; height: 150px; bottom: 90px; }
}

/* ---------- Small screens ---------- */

@media (max-width: 640px) {
    .field-list { grid-template-columns: 1fr; }
    .title { font-size: 34px; }
    .hud-box { min-width: 80px; padding: 4px 8px; }
    .hud-value { font-size: 16px; }
    .hud-value b { font-size: 18px; }
    .route { bottom: max(104px, calc(env(safe-area-inset-bottom) + 104px)); }
    .ctl { width: 68px; height: 68px; }
}

/* On a computer with a keyboard the touch buttons stay hidden (game.js shows them on touch screens) */

/* ---------- Player name and leaderboard ---------- */

.player-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 10px; font-size: 17px; }
.mini-btn { padding: 5px 12px; font-family: inherit; font-size: 15px; color: var(--text); background: transparent; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.panel-small { width: min(100%, 440px); }
#startScreen .panel { width: min(100%, 980px); }
#nameScreen { z-index: 30; background: rgba(10, 6, 3, 0.8); }   /* above the start, buying and result screens */
.text-input { width: 100%; padding: 12px 14px; font-family: inherit; font-size: 18px; color: var(--text); background: #120b06; border: 1px solid var(--line); border-radius: 12px; }
.lb-table td, .lb-table th { padding: 6px 4px; font-size: 15px; }
.lb-table th { text-align: left; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
.lb-table td:first-child { width: 34px; color: var(--muted); }
.lb-table td:last-child, .lb-table th:last-child { text-align: right; }
.lb-table td:nth-child(3), .lb-table td:nth-child(4) { text-align: right; }
.lb-table th:nth-child(3), .lb-table th:nth-child(4) { text-align: right; }
.lb-table tr.me td { color: var(--amber); font-weight: 700; background: rgba(245, 166, 35, 0.1); }
.lb-me { color: var(--amber); font-weight: 600; }
.rank-line { font-size: 17px; color: var(--amber); }

/* ---------- Fish farm: ice and the notebook against the software ---------- */

.check-row { display: flex; align-items: center; gap: 10px; margin: 12px 0 4px; font-size: 17px; }
.check-row input { width: 22px; height: 22px; accent-color: var(--amber); }
.check-row b { margin-left: auto; color: var(--amber); }
.ledger { margin: 12px 0; padding: 10px 12px; background: rgba(255, 255, 255, 0.05); border: 1px dashed var(--line); border-radius: 14px; }
.ledger-story p { margin: 0 0 6px; font-size: 15px; color: var(--muted); }
.ledger-story b { color: var(--text); }
.ledger-line { padding: 4px 0; font-size: 17px; }
.ledger-soft { color: var(--green); font-weight: 600; }
.ledger-diff { color: var(--red); font-weight: 700; }
.ledger-result { color: var(--text); }
.c-ice { background: #7fd1e8; }

/* ---------- Phones: smaller boxes so nothing lies on top of something else (this block must stay last) ---------- */

@media (max-width: 640px) {
    .hud-card { min-width: 168px; padding: 5px 8px; }
    .hud-line { font-size: 13px; padding: 1px 0; }
    .hud-line b { font-size: 14px; }
    .chip { display: none; }
    .round-btn, .mute { width: 36px; height: 36px; font-size: 16px; }
    .mute { top: 10px; right: 10px; }
    .top-right { right: 54px; gap: 6px; }
    .prompt, .toast { top: 36%; font-size: 16px; }
    .speedo { width: 112px; height: 112px; bottom: 92px; }
    .route { left: 10px; right: 10px; bottom: 214px; top: auto; }
    .choice-btn { font-size: 16px; grid-template-columns: 30px 1fr; }
    .choice-btn i { grid-column: 2; }
}

/* ---------- user guide opened on top of the game ---------- */
.guide-box { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; background: #1a110b; }
.guide-box.hidden { display: none; }
.guide-box-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; background: rgba(0, 0, 0, 0.35); border-bottom: 1px solid var(--line); }
.guide-box-frame { flex: 1; width: 100%; border: 0; background: #1a110b; }
