:root {
  --bg: #1c232d; --ink: #1f2833; --paper: #f4f6f9; --muted: #6a7684; --line: #d5dbe2;
  --orange: #f07a1a; --orange-d: #c85d0c; --green: #2e8c58; --sky: #a9c2da;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", sans-serif; overflow: hidden; -webkit-user-select: none; user-select: none; touch-action: none; }
button { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 10px; padding: 8px 14px; }
button:hover { border-color: #b8c2cd; }
button.big { background: var(--orange); border-color: var(--orange-d); color: #fff; font-weight: 700; padding: 12px 20px; font-size: 17px; }
button.big:hover { background: #f58a2e; }
button:disabled { opacity: 0.45; cursor: default; }
[hidden] { display: none !important; }

#stage { position: absolute; }
#cv { display: block; width: 100%; height: 100%; border-radius: 6px; }

#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; pointer-events: none; font-size: 13px; }
#hud > div { display: flex; align-items: center; gap: 8px; background: rgba(28, 35, 45, 0.82); color: #fff; border-radius: 10px; padding: 4px 10px; pointer-events: auto; }
#hud .hud-c { gap: 10px; }
#hud b { font-size: 16px; }
#shiftName { font-weight: 600; white-space: nowrap; }
.dawn { width: 90px; height: 7px; border-radius: 4px; background: #34404f; overflow: hidden; }
#dawnFill { height: 100%; width: 0; background: linear-gradient(90deg, #6a8fd0, #f4b860); }
#clock { font-variant-numeric: tabular-nums; min-width: 32px; }
#bladeChip { font-weight: 600; white-space: nowrap; }
#hud button { padding: 3px 10px; border-radius: 8px; font-size: 13px; background: #3a4757; color: #fff; border-color: #4b5a6c; }
#hud #closeBtn { background: var(--green); border-color: #1f6640; font-weight: 700; }

#hint { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); width: min(560px, 90%); background: rgba(28, 35, 45, 0.88); color: #fff; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.4; text-align: center; pointer-events: none; }
#toasts { position: absolute; top: 44px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; }
.toast { background: rgba(28, 35, 45, 0.85); color: #fff; padding: 4px 12px; border-radius: 999px; font-size: 13px; animation: toast 2.2s ease forwards; white-space: nowrap; }
.toast.good { background: rgba(46, 140, 88, 0.92); }
.toast.bad { background: rgba(176, 80, 30, 0.92); }
@keyframes toast { 0% { opacity: 0; transform: translateY(-4px); } 10% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

.screen, .modal { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 16px; overflow: auto; }
.screen { background: rgba(20, 26, 34, 0.55); }
.modal { background: rgba(20, 26, 34, 0.6); z-index: 20; }
.card { background: var(--paper); border-radius: 16px; padding: 20px 22px; max-width: 420px; width: 100%; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35); max-height: 100%; overflow: auto; }
.card.wide { max-width: 860px; }
.titlecard { text-align: center; }
h1 { font-size: 46px; margin: 4px 0 2px; letter-spacing: 1px; color: var(--ink); }
h2 { margin: 0 0 10px; font-size: 22px; }
h3 { margin: 2px 0 4px; font-size: 19px; }
.tag { color: var(--muted); margin: 0 0 16px; }
.keys { color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.ghead { display: flex; justify-content: space-between; align-items: baseline; }
.cash { font-size: 22px; font-weight: 800; color: var(--green); }
.label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin: 8px 0 4px; }
.gtop { display: flex; gap: 18px; align-items: stretch; margin-bottom: 8px; }
#truckPrev { background: #4b5562; border-radius: 12px; width: 240px; height: 150px; flex: none; }
.next { flex: 1; min-width: 0; }
.next p { margin: 0 0 8px; color: #3b4652; font-size: 14px; line-height: 1.4; }
.attach { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.attach .label { margin: 0; }
#attachBtns button { padding: 5px 10px; font-size: 13px; margin-right: 4px; }
#attachBtns button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.shop { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.tile { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.tile h4 { margin: 0; font-size: 15px; display: flex; justify-content: space-between; }
.tile h4 span { color: var(--green); }
.tile p { margin: 0; font-size: 13px; color: #3b4652; line-height: 1.35; }
.tile .handy { color: var(--muted); font-size: 12px; }
.tile button { margin-top: 4px; align-self: flex-start; padding: 5px 12px; font-size: 13px; }
.tile.owned { background: #eef6f1; border-color: #b9dcc6; }
.tile .own { color: var(--green); font-weight: 700; font-size: 13px; margin-top: 4px; }

.rbody { display: flex; gap: 16px; align-items: flex-start; }
#miniMap { width: 400px; max-width: 50%; height: auto; border-radius: 10px; flex: none; }
.rlist { flex: 1; min-width: 0; }
#rZones { list-style: none; padding: 0; margin: 0 0 8px; font-size: 14px; }
#rZones li { display: flex; justify-content: space-between; padding: 3px 0; border-bottom: 1px solid #e4e8ed; }
#rZones li .no { color: #b0501e; }
#rZones li .yes { color: var(--green); font-weight: 700; }
.rsum { font-size: 15px; line-height: 1.6; }
.rsum .tot { font-size: 20px; font-weight: 800; }
.rsum .help { color: var(--muted); font-size: 13px; }
.rbtns { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.modal .card button { width: 100%; margin-top: 8px; }
#leaveConfirm button { width: 48%; }

#touch { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
#stickZone { position: absolute; left: 0; top: 50px; bottom: 0; width: 55%; pointer-events: auto; }
#stick { position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px; border-radius: 50%; background: rgba(28, 35, 45, 0.25); border: 2px solid rgba(255, 255, 255, 0.5); pointer-events: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px; margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(240, 122, 26, 0.85); border: 2px solid #fff; }
.tbtns { position: absolute; right: max(10px, env(safe-area-inset-right)); bottom: 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-end; pointer-events: auto; }
.tbtns button { width: 78px; height: 78px; border-radius: 50%; background: rgba(28, 35, 45, 0.78); color: #fff; border: 2px solid rgba(255, 255, 255, 0.6); font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; padding: 0; }
.tbtns button span { font-size: 28px; }
.tbtns button small { font-size: 11px; font-weight: 600; }
#actBtn { width: 64px; height: 64px; font-size: 12px; }
#actBtn.on { background: var(--orange); border-color: #fff; }
#rotate { position: fixed; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(28, 35, 45, 0.9); color: #fff; padding: 6px 12px; border-radius: 999px; font-size: 13px; z-index: 6; white-space: nowrap; }

@media (max-width: 640px), (max-height: 460px) {
  .gtop { flex-direction: column; }
  #truckPrev { width: 100%; height: 120px; }
  .rbody { flex-direction: column; }
  #miniMap { max-width: 100%; width: 100%; }
  .card { padding: 14px; }
  h1 { font-size: 38px; }
  #hud { font-size: 12px; padding: 4px; }
  .dawn { width: 50px; }
}
@media (max-height: 460px) and (min-width: 640px) {
  .gtop { flex-direction: row; }
  #truckPrev { width: 200px; height: 125px; }
  .rbody { flex-direction: row; }
  #miniMap { max-width: 45%; }
}
#hud .hud-c span, #hud .hud-l { white-space: nowrap; }
@media (orientation: portrait) and (max-width: 640px) {
  #hud { position: fixed; top: max(8px, env(safe-area-inset-top)); flex-wrap: wrap; justify-content: center; z-index: 6; }
  #hint { position: fixed; bottom: 120px; }
  #rotate { bottom: auto; top: 96px; }
  #toasts { position: fixed; top: 60px; }
}
