/* truck.css: "벼랑길 짐트럭" (retro-truck.js and truck-*.js). Every rule lives under .tt-truck-.
   The stage is a size container: the layout follows the size of the game itself, in the page, pinned over it or on the whole screen.
   Words pinned to the picture (speech, pop-ups, the blue pin) are moved by the script with a transform. */
.tt-truck-lead { margin: 0 0 .8rem; }
.tt-truck-help { margin: .7rem 0 0; font-size: .86rem; color: #5b5568; }
.tt-truck-stage {
  --ink: #2f2437; --paper: #fffaf0; --sun: #ffd23f; --coral: #ff6b4a; --mint: #2fc36b; --blue: #2c6fd6; --red: #e5484d;
  position: relative; container: tt-truck / size; width: min(100%, 64rem); aspect-ratio: 9 / 17; max-height: 88vh; overflow: hidden;
  border-radius: 18px; background: #cfe3f2; color: var(--ink); line-height: 1.3; font-weight: 700;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
@media (min-width: 720px) { .tt-truck-stage { aspect-ratio: 16 / 10; } }
@media (orientation: landscape) and (max-height: 520px) { .tt-truck-stage { aspect-ratio: auto; height: 88vh; } }
.tt-truck-stage:not([data-phase="title"]) { touch-action: none; }
.tt-truck-stage.tt-truck-filled { position: fixed; inset: 0; z-index: 9999; width: auto; height: auto; max-height: none; aspect-ratio: auto; border-radius: 0; }
.tt-truck-stage:fullscreen { width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto; border-radius: 0; }
.tt-truck-stage:-webkit-full-screen { width: 100vw; height: 100vh; max-height: none; aspect-ratio: auto; border-radius: 0; }
html.tt-truck-lock, html.tt-truck-lock body { overflow: hidden; overscroll-behavior: none; }
.tt-truck-stage .tt-truck-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; border-radius: 0; outline: none; touch-action: none; }
.tt-truck-stage p, .tt-truck-stage h3, .tt-truck-stage dl, .tt-truck-stage dd { margin: 0; padding: 0; }
.tt-truck-stage i, .tt-truck-stage small { font-style: normal; font-family: inherit; }
.tt-truck-stage button { margin: 0; font: inherit; font-weight: 800; color: var(--ink); cursor: pointer; touch-action: manipulation; }
.tt-truck-stage button:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.tt-truck-stage .tt-truck-sorry { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: #2c2440; color: #fff; }

/* The edge of the screen: amber when the wheels are close to the drop, red and beating when one hangs over it. */
.tt-truck-edge { position: absolute; inset: 0; pointer-events: none; border-radius: inherit; transition: box-shadow .15s linear; }
.tt-truck-stage[data-danger="near"] .tt-truck-edge { box-shadow: inset 0 0 0 4px rgba(255, 196, 0, .8), inset 0 0 50px 4px rgba(255, 196, 0, .28); }
.tt-truck-stage[data-danger="hang"] .tt-truck-edge { box-shadow: inset 0 0 0 9px rgba(230, 40, 40, .95), inset 0 0 110px 30px rgba(230, 40, 40, .55); animation: tt-truck-beat .55s ease-in-out infinite; }

/* Words pinned to things in the picture */
.tt-truck-tags { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.tt-truck-tags > * { position: absolute; left: 0; top: 0; will-change: transform; }
.tt-truck-bubble { z-index: 3; translate: -50% -100%; max-width: 180px; padding: 5px 11px 6px; border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 0 3px 0 rgba(47, 36, 55, .4); font-size: .86rem; font-weight: 900; line-height: 1.25; text-align: center; word-break: keep-all; animation: tt-truck-pop-in .16s ease-out; }
.tt-truck-bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; width: 10px; height: 10px; border: solid var(--ink); border-width: 0 2.5px 2.5px 0; background: inherit; transform: translateX(-50%) rotate(45deg); }
.tt-truck-bubble.tt-truck-angry { background: #ffe1dc; color: #9c1f1f; animation: tt-truck-pop-in .16s ease-out, tt-truck-jolt .1s linear .16s 3; }
.tt-truck-bubble.tt-truck-glad { background: #e3ffe9; }
.tt-truck-pop { z-index: 4; translate: -50% -50%; color: #fff; font-size: 1.15rem; font-weight: 900; line-height: 1; white-space: nowrap; letter-spacing: -.01em;
  text-shadow: -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 2px 2px 0 var(--ink), 0 2px 0 var(--ink), 0 -2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 4px 0 var(--ink); }
.tt-truck-pop[data-tone="bad"] { color: #ff9a8c; font-size: 1.3rem; }
.tt-truck-pop[data-tone="warn"] { color: #ffd08a; }
.tt-truck-pop[data-tone="close"] { color: var(--sun); font-size: 1.2rem; }
.tt-truck-pop[data-tone="horn"] { color: #fff6c8; font-size: 1.05rem; }
.tt-truck-pop[data-tone="goat"] { color: #ffffff; font-size: 1.1rem; }
.tt-truck-pin { z-index: 5; translate: -50% -100%; padding: 4px 11px 5px; border: 2.5px solid #fff; border-radius: 999px; background: var(--blue); box-shadow: 0 3px 0 var(--ink); color: #fff; font-size: .86rem; font-weight: 900; white-space: nowrap; animation: tt-truck-bob .7s ease-in-out infinite; }
.tt-truck-pin::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 11px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; background: inherit; transform: translateX(-50%) rotate(45deg); }
.tt-truck-pin[data-off="yes"]::after { display: none; }

/* The strip at the top: the clock, the load, the close calls; the trip below it; the small buttons at the right. */
.tt-truck-hud { position: absolute; left: 0; top: 0; display: flex; flex-wrap: wrap; gap: 5px; max-width: calc(100% - 150px); pointer-events: none;
  padding: max(8px, env(safe-area-inset-top)) 0 0 max(8px, env(safe-area-inset-left)); }
.tt-truck-stage[data-phase="title"] .tt-truck-hud, .tt-truck-stage[data-phase="none"] .tt-truck-hud,
.tt-truck-stage[data-phase="title"] .tt-truck-trip, .tt-truck-stage[data-phase="none"] .tt-truck-trip { display: none; }
.tt-truck-chip { display: flex; align-items: center; gap: 4px; box-sizing: border-box; height: 38px; padding: 0 10px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); font-size: .8rem; font-weight: 800; white-space: nowrap; }
.tt-truck-chip b { font-size: 1.1rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.tt-truck-chip i { color: #6b5a78; }
.tt-truck-chip small { color: #6b5a78; font-size: .78rem; }
.tt-truck-load { background: var(--sun); }
.tt-truck-load[data-n="0"] { animation: tt-truck-bump-a .45s ease-out; }
.tt-truck-load[data-n="1"] { animation: tt-truck-bump-b .45s ease-out; }
.tt-truck-close[data-n="0"] b { animation: tt-truck-bump-a .3s ease-out; }
.tt-truck-close[data-n="1"] b { animation: tt-truck-bump-b .3s ease-out; }
.tt-truck-trip { --trip: 0; position: absolute; left: max(10px, env(safe-area-inset-left)); right: max(10px, env(safe-area-inset-right)); top: calc(max(8px, env(safe-area-inset-top)) + 50px); height: 8px; border: 2px solid var(--ink); border-radius: 999px; background: rgba(255, 250, 240, .8); pointer-events: none; }
.tt-truck-trip i { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--trip) * 100%); border-radius: inherit; background: var(--coral); }
.tt-truck-trip i::after { content: ''; position: absolute; right: -9px; top: -7px; width: 18px; height: 18px; border: 2px solid var(--ink); border-radius: 6px; background: var(--sun); }
.tt-truck-trip b { position: absolute; right: -2px; top: 10px; padding: 1px 6px; border-radius: 8px; background: var(--ink); color: var(--sun); font-size: .66rem; font-weight: 900; }
.tt-truck-tools { position: absolute; right: 0; top: 0; display: flex; gap: 4px; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) 0 0; }
.tt-truck-stage .tt-truck-tools button { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 2.5px solid var(--ink); border-radius: 13px; background: var(--paper); box-shadow: 0 3px 0 var(--ink); font-size: .8rem; line-height: 1; }
.tt-truck-stage .tt-truck-tools button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tt-truck-stage .tt-truck-tools [data-sound][aria-pressed="false"] { background: #d9d3de; color: #8a8192; text-decoration: line-through; }
.tt-truck-stage .tt-truck-tools [data-sound] { font-size: 1.2rem; }
.tt-truck-stage[data-phase="title"] .tt-truck-tools [data-pause], .tt-truck-stage[data-phase="none"] .tt-truck-tools { display: none; }

/* A line of advice under the top strip, big words across the middle, the reverse light */
.tt-truck-hint { position: absolute; left: 50%; top: calc(max(8px, env(safe-area-inset-top)) + 70px); translate: -50% 0; box-sizing: border-box; width: max-content; max-width: calc(100% - 20px);
  padding: 7px 14px; border: 2.5px solid var(--ink); border-radius: 16px; background: rgba(255, 250, 240, .96); box-shadow: 0 3px 0 var(--ink); pointer-events: none;
  font-size: .9rem; font-weight: 900; line-height: 1.3; text-align: center; word-break: keep-all; text-wrap: balance; }
.tt-truck-hint[data-n="0"] { animation: tt-truck-rise-a .22s ease-out; }
.tt-truck-hint[data-n="1"] { animation: tt-truck-rise-b .22s ease-out; }
.tt-truck-banner { position: absolute; left: 50%; top: 30%; translate: -50% -50%; width: max-content; pointer-events: none; color: #fff; font-size: clamp(2rem, 11cqw, 3.6rem); font-weight: 900; line-height: 1.05; white-space: nowrap; letter-spacing: -.02em;
  text-shadow: -3px -3px 0 var(--ink), 3px -3px 0 var(--ink), -3px 3px 0 var(--ink), 3px 3px 0 var(--ink), 0 3px 0 var(--ink), 0 -3px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink), 0 7px 0 var(--ink); }
.tt-truck-banner[data-n="0"] { animation: tt-truck-stamp-a .22s ease-out; }
.tt-truck-banner[data-n="1"] { animation: tt-truck-stamp-b .22s ease-out; }
.tt-truck-banner[data-tone="good"] { color: #9dffbd; }
.tt-truck-banner[data-tone="warn"] { color: #ff9a8c; }
.tt-truck-gear { position: absolute; left: 50%; bottom: calc(118px + env(safe-area-inset-bottom)); translate: -50% 0; padding: 3px 12px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; color: #c62626; font-size: .9rem; font-weight: 900; pointer-events: none; animation: tt-truck-blink .5s steps(2, jump-none) infinite; }
.tt-truck-stage:not([data-input="touch"]) .tt-truck-gear { bottom: calc(18px + env(safe-area-inset-bottom)); }

/* Thumbs: the steering pair at the left, horn, brake and accelerator at the right */
.tt-truck-pad { position: absolute; inset: auto 0 0 0; display: none; justify-content: space-between; align-items: flex-end; gap: 8px; pointer-events: none;
  padding: 0 max(12px, env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
.tt-truck-stage[data-input="touch"][data-phase="play"] .tt-truck-pad { display: flex; }
.tt-truck-wheel { display: flex; gap: 6px; padding: 5px; border-radius: 24px; background: rgba(47, 36, 55, .22); pointer-events: auto; touch-action: none; }
.tt-truck-stage .tt-truck-wheel button { width: 72px; height: 76px; padding: 0; border: 3px solid var(--ink); border-radius: 20px; background: rgba(255, 250, 240, .92); box-shadow: 0 5px 0 var(--ink); font-size: 1.7rem; line-height: 1; pointer-events: none; }
.tt-truck-stage .tt-truck-wheel button.tt-truck-on { background: var(--sun); transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.tt-truck-pedals { display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; gap: 8px; align-items: end; pointer-events: none; }
.tt-truck-stage .tt-truck-pedals button { pointer-events: auto; touch-action: none; display: grid; place-items: center; padding: 4px; border: 3px solid var(--ink); line-height: 1.05; text-align: center; word-break: keep-all; }
.tt-truck-stage .tt-truck-horn { grid-column: 1 / 3; justify-self: end; width: 98px; height: 46px; border-radius: 999px; background: var(--sun); box-shadow: 0 4px 0 var(--ink); font-size: 1rem; font-weight: 900; }
.tt-truck-stage .tt-truck-horn[data-n="0"] { animation: tt-truck-honk-a .25s ease-out; }
.tt-truck-stage .tt-truck-horn[data-n="1"] { animation: tt-truck-honk-b .25s ease-out; }
.tt-truck-stage .tt-truck-brake { width: 74px; height: 80px; border-radius: 18px; background: rgba(255, 250, 240, .92); box-shadow: 0 5px 0 var(--ink); font-size: .98rem; font-weight: 900; }
.tt-truck-stage .tt-truck-brake small { display: block; margin-top: 3px; font-size: .64rem; font-weight: 800; color: #6b5a78; }
.tt-truck-stage .tt-truck-gas { width: 82px; height: 96px; border-radius: 18px; background: var(--mint); color: #fff; box-shadow: 0 5px 0 var(--ink); font-size: 1.12rem; font-weight: 900; text-shadow: 0 2px 0 rgba(47, 36, 55, .45); }
.tt-truck-stage .tt-truck-brake[aria-pressed="true"], .tt-truck-stage .tt-truck-gas[aria-pressed="true"] { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.tt-truck-stage .tt-truck-brake[aria-pressed="true"] { background: #ffd0c8; }
.tt-truck-stage .tt-truck-gas[aria-pressed="true"] { background: #27a85b; }
@container tt-truck (max-width: 430px) {
  .tt-truck-hud { gap: 4px; max-width: calc(100% - 144px); }
  .tt-truck-chip { height: 34px; padding: 0 7px; gap: 3px; font-size: .72rem; }
  .tt-truck-chip b { font-size: 1rem; }
  .tt-truck-trip { top: calc(max(8px, env(safe-area-inset-top)) + 54px); }
}
@container tt-truck (max-width: 340px) {
  .tt-truck-stage .tt-truck-wheel button { width: 62px; }
  .tt-truck-stage .tt-truck-brake { width: 66px; }
  .tt-truck-stage .tt-truck-gas { width: 72px; }
}
@container tt-truck (max-height: 430px) {
  .tt-truck-stage .tt-truck-wheel button { height: 64px; }
  .tt-truck-stage .tt-truck-brake { height: 64px; }
  .tt-truck-stage .tt-truck-gas { height: 74px; }
  .tt-truck-stage .tt-truck-horn { height: 40px; }
  .tt-truck-hint { top: calc(max(8px, env(safe-area-inset-top)) + 64px); font-size: .82rem; padding: 5px 12px; }
  .tt-truck-pad { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}

/* The cards */
.tt-truck-card { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 6; display: grid; gap: 9px; box-sizing: border-box; width: min(calc(100% - 24px), 21.5rem); max-height: calc(100% - 16px); padding: 16px 18px 15px; overflow: auto;
  border: 3px solid var(--ink); border-radius: 22px; background: var(--paper); box-shadow: 0 7px 0 var(--ink), 0 0 0 200vmax rgba(36, 26, 52, .3); text-align: center; word-break: keep-all; animation: tt-truck-pop-in .2s ease-out; }
.tt-truck-kicker { justify-self: center; padding: 3px 12px; border-radius: 999px; background: var(--ink); color: var(--sun); font-size: .8rem; font-weight: 900; }
.tt-truck-card h3 { font-size: 1.6rem; font-weight: 900; line-height: 1.12; letter-spacing: -.02em; }
.tt-truck-stage .tt-truck-card button { min-height: 48px; padding: 0 14px; border: 2.5px solid var(--ink); border-radius: 14px; background: #fff; box-shadow: 0 3px 0 var(--ink); font-size: .98rem; }
.tt-truck-stage .tt-truck-card button:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.tt-truck-stage .tt-truck-card .tt-truck-go { min-height: 56px; background: var(--coral); color: #fff; font-size: 1.18rem; font-weight: 900; text-shadow: 0 2px 0 rgba(47, 36, 55, .45); }
.tt-truck-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.tt-truck-rule { font-size: 1.02rem; font-weight: 900; line-height: 1.3; text-wrap: balance; }
.tt-truck-keys { font-size: .78rem; font-weight: 700; color: #6b5a78; }
.tt-truck-best { font-size: .8rem; font-weight: 800; color: #6b5a78; }
.tt-truck-stage[data-input="touch"] .tt-truck-forkeys, .tt-truck-stage:not([data-input="touch"]) .tt-truck-fortouch { display: none; }
.tt-truck-title { box-shadow: 0 7px 0 var(--ink), 0 0 0 200vmax rgba(36, 26, 52, .12); background: linear-gradient(#fffaf0 0 60%, #ffe8c2); }
.tt-truck-title h3 { margin: 2px 0 2px; font-size: clamp(2.4rem, 13cqmin, 3.2rem); line-height: 1.02; color: var(--red); rotate: -3deg;
  text-shadow: 2px 2px 0 var(--sun), 4px 4px 0 var(--ink); }
.tt-truck-joke { padding: 6px 10px; border: 2.5px dashed var(--ink); border-radius: 12px; background: #fff3c4; font-size: .92rem; font-weight: 900; rotate: 1.5deg; }
.tt-truck-fall h3 { font-size: 2rem; color: #c62626; }
.tt-truck-minus { font-size: .84rem; font-weight: 800; color: #6b5a78; }
.tt-truck-minus b { color: #c62626; }
.tt-truck-result h3 b { font-size: clamp(2.6rem, 14cqmin, 3.4rem); color: var(--red); font-variant-numeric: tabular-nums; }
.tt-truck-result h3 small { margin-left: 3px; font-size: 1.2rem; }
.tt-truck-badge { justify-self: center; padding: 6px 14px; border: 2.5px dashed var(--ink); border-radius: 12px; background: #fff3c4; font-size: 1rem; font-weight: 900; rotate: -2deg; }
.tt-truck-rows { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; padding: 8px 12px; border-radius: 12px; background: #f3ecdd; font-size: .9rem; text-align: left; }
.tt-truck-rows dt { font-weight: 800; color: #6b5a78; }
.tt-truck-rows dd { font-weight: 900; text-align: right; font-variant-numeric: tabular-nums; }
.tt-truck-rows dd b { display: inline-block; min-width: 3.4em; color: var(--blue); }
@container tt-truck (max-height: 430px) {
  .tt-truck-card { gap: 6px; padding: 10px 14px; }
  .tt-truck-title h3 { font-size: 2.1rem; }
  .tt-truck-rows { gap: 1px 10px; padding: 5px 10px; font-size: .82rem; }
  .tt-truck-result h3 b { font-size: 2.2rem; }
  .tt-truck-stage .tt-truck-card .tt-truck-go { min-height: 46px; }
}

@keyframes tt-truck-beat { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
@keyframes tt-truck-blink { 50% { opacity: .35; } }
@keyframes tt-truck-bob { 0%, 100% { margin-top: 0; } 50% { margin-top: -6px; } }
@keyframes tt-truck-pop-in { from { scale: .7; opacity: 0; } to { scale: 1; opacity: 1; } }
@keyframes tt-truck-jolt { 25% { margin-left: -3px; } 75% { margin-left: 3px; } }
@keyframes tt-truck-bump-a { 30% { scale: 1.18; } }
@keyframes tt-truck-bump-b { 30% { scale: 1.18; } }
@keyframes tt-truck-rise-a { from { opacity: 0; margin-top: 10px; } }
@keyframes tt-truck-rise-b { from { opacity: 0; margin-top: 10px; } }
@keyframes tt-truck-stamp-a { from { scale: 1.6; opacity: 0; } }
@keyframes tt-truck-stamp-b { from { scale: 1.6; opacity: 0; } }
@keyframes tt-truck-honk-a { 40% { scale: 1.15; } }
@keyframes tt-truck-honk-b { 40% { scale: 1.15; } }
@media (prefers-reduced-motion: reduce) {
  .tt-truck-stage *, .tt-truck-stage *::after { animation: none !important; }
}
