:root { --safe-left:env(safe-area-inset-left,0px); --safe-right:env(safe-area-inset-right,0px); --safe-top:env(safe-area-inset-top,0px); --safe-bottom:env(safe-area-inset-bottom,0px); --glass:#102331db; }
[hidden] { display:none !important; }
body { overscroll-behavior:none; height:100dvh; }
body.touch { -webkit-user-select:none; user-select:none; -webkit-touch-callout:none; }
.touch #welcome { padding:max(18px,var(--safe-top)) max(22px,var(--safe-right)) max(18px,var(--safe-bottom)) max(22px,var(--safe-left)); }
.touch .controls { margin-top:12px; font-size:13px; }
.touch #message { max-width:440px; }
#touch-ui { position:fixed; inset:0; pointer-events:none; display:none; color:#f5f1dc; }
body.touch[data-game-started="true"] #touch-ui { display:block; }
#touch-ui button { padding:8px 12px; margin:0; min-height:44px; font-size:12px; border-color:#bcebd14a; color:#f5f1dc; background:var(--glass); pointer-events:auto; touch-action:none; -webkit-tap-highlight-color:transparent; }
#touch-ui button.active { background:#bcebd1cc; color:#142432; }
.touch-tools { position:absolute; top:calc(var(--safe-top) + 10px); left:calc(var(--safe-left) + 10px); display:flex; gap:6px; }
.touch-tools button { min-width:48px; }
.touch-clock { position:absolute; top:calc(var(--safe-top) + 62px); left:calc(var(--safe-left) + 12px); display:flex; align-items:center; gap:12px; padding:9px 12px; border:1px solid #bcebd12e; border-radius:13px; background:var(--glass); font-size:12px; }
.touch-clock #touch-phase { font-size:17px; }
.touch-clock small { display:block; color:#bcebd1; margin-top:4px; font-size:11px; }
.day-dial { position:relative; width:48px; height:48px; flex:none; border:1px solid #bcebd152; border-radius:50%; background:#bcebd10a; }
.day-dial::before { content:''; position:absolute; inset:5px; border-radius:50%; background:repeating-conic-gradient(from -1deg,#bcebd15e 0deg 2deg,transparent 2deg 30deg); mask:radial-gradient(transparent 0 15px,#000 15.5px); -webkit-mask:radial-gradient(transparent 0 15px,#000 15.5px); }
.day-dial::after { content:''; position:absolute; width:5px; height:5px; left:50%; top:50%; transform:translate(-50%,-50%); border-radius:50%; background:#f4b58c; }
.clock-hand { position:absolute; width:3px; height:17px; left:calc(50% - 1.5px); bottom:50%; border-radius:3px; background:#f4b58cd9; transform-origin:50% 100%; }
.touch.paused .clock-hand,.touch.map .clock-hand { transition:none !important; }
.touch-speed { position:absolute; bottom:calc(var(--safe-bottom) + 10px); left:50%; transform:translateX(-50%); text-align:center; font-size:12px; color:#bcebd1; }
.touch-speed strong { font-size:26px; color:#f5f1dc; font-variant-numeric:tabular-nums; }
#steering { position:absolute; bottom:calc(var(--safe-bottom) + 40px); left:calc(var(--safe-left) + 20px); width:126px; height:126px; padding:0 !important; border-radius:50% !important; background:#10233199 !important; }
#steering::before { content:'STEER'; position:absolute; left:0; right:0; bottom:12px; font-size:10px; letter-spacing:.1em; color:#bcebd1; }
#steer-knob { position:absolute; width:54px; height:54px; top:35px; left:35px; border-radius:50%; border:1px solid #bcebd189; background:#bcebd14d; transform:translateX(var(--steer,0px)); pointer-events:none; }
.touch-pedals { position:absolute; bottom:calc(var(--safe-bottom) + 40px); right:calc(var(--safe-right) + 16px); display:grid; grid-template-columns:64px 76px; gap:8px; align-items:end; }
#touch-ui .pedal { height:98px; border-radius:16px; letter-spacing:.06em; }
#touch-ui #gas { background:#bcebd132; border-color:#bcebd18c; }
.touch-pedals .aux { height:44px; border-radius:14px; }
#trial-card { position:absolute; top:calc(var(--safe-top) + 62px); left:50%; transform:translateX(-50%); width:min(360px,calc(100% - 24px)); padding:10px 12px; border:1px solid #ef9ddb65; border-radius:14px; background:#101b2bea; font-size:12px; }
#trial-title { color:#ef9ddb; font-size:11px; text-transform:uppercase; letter-spacing:.05em; }
#trial-live { display:flex; align-items:baseline; gap:14px; margin-top:4px; }
#trial-time { font-size:25px; font-variant-numeric:tabular-nums; }
#trial-direction { color:#bcebd1; margin:5px 0; font-size:16px; }
#trial-tiers { display:flex; gap:5px; margin:8px 0; }
#trial-tiers button { flex:1; padding:6px !important; font-size:11px !important; }
#trial-tiers button:disabled { opacity:.5; cursor:default; }
#trial-card button { min-height:44px; }
#trial-start { width:100%; color:#142432 !important; background:#bcebd1 !important; }
.trial-footer { display:flex; align-items:center; justify-content:space-between; gap:8px; }
#trial-gate { color:#bcebd1; }
#trial-cancel { flex:none; }
#touch-notice { position:absolute; top:48%; left:50%; transform:translate(-50%,-50%); max-width:calc(100% - 28px); padding:10px 16px; background:var(--glass); border-radius:12px; font-size:13px; text-align:center; }
.touch-dialog { pointer-events:auto; position:absolute; inset:calc(var(--safe-top) + 10px) calc(var(--safe-right) + 10px) calc(var(--safe-bottom) + 10px) calc(var(--safe-left) + 10px); overflow:auto; overscroll-behavior:contain; border:1px solid #bcebd14a; border-radius:20px; background:#16353df7; padding:20px; max-width:720px; margin:auto; touch-action:pan-y; }
.touch-dialog h2 { font-size:26px; margin:0 0 6px; font-weight:600; letter-spacing:-.03em; }
.touch-dialog p { font-size:13px; margin:5px 0 14px; }
.pause-grid { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.pause-actions { display:flex; flex-direction:column; gap:8px; }
#touch-ui .pause-actions button { min-height:46px; text-align:left; font-size:14px; background:#285258; }
#touch-ui .pause-actions .primary { color:#142432; background:#bcebd1; }
.pause-settings label { display:block; font-size:13px; color:#bcebd1; margin:10px 0 8px; }
.pause-settings input[type=range] { width:100%; height:32px; accent-color:#bcebd1; touch-action:pan-y; }
.pause-settings button { width:100%; margin:5px 0 !important; text-align:left; }
.touch-graphics { margin:10px 0; border:1px solid #bcebd14a; border-radius:12px; padding:10px; background:#10233180; }
.touch-graphics summary { min-height:38px; padding:8px 0; color:#f5f1dc; cursor:pointer; }
.touch-graphics label { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.touch-graphics select { width:46%; min-height:44px; color:#f5f1dc; background:#285258; border:1px solid #bcebd167; border-radius:8px; font:inherit; padding:8px; }
#new-confirm { grid-column:1 / -1; border:1px solid #f4b58c70; padding:12px; border-radius:12px; }
#new-seed { width:100%; height:44px; border:1px solid #bcebd167; border-radius:8px; color:#f5f1dc; background:#102331; font:inherit; font-size:16px; padding:8px; -webkit-user-select:text; user-select:text; }
#credits-text { white-space:pre-wrap; font-size:12px; line-height:1.6; }
.touch.map #touch-clock,.touch.map #trial-card,.touch.map .touch-speed,.touch.map #steering,.touch.map .touch-pedals,.touch.paused #touch-clock,.touch.paused #trial-card,.touch.paused .touch-speed,.touch.paused #steering,.touch.paused .touch-pedals { display:none; }
.touch.paused .touch-tools { display:none; }
.touch.map .touch-tools button:not([data-action=map]) { display:none; }
@media(max-width:600px) and (orientation:portrait) {
  .pause-grid { grid-template-columns:1fr; gap:12px; }
  #trial-card { top:calc(var(--safe-top) + 173px); }
  .touch-clock { max-width:calc(100% - 160px); }
  #steering { width:116px; height:116px; left:calc(var(--safe-left) + 12px); }
  #steer-knob { top:30px; left:30px; }
  .touch-pedals { right:calc(var(--safe-right) + 12px); grid-template-columns:60px 70px; }
}
@media(max-height:500px) {
  .touch-clock { padding:7px 10px; }
  .day-dial { width:42px; height:42px; }
  #trial-card { top:calc(var(--safe-top) + 10px); width:min(350px,calc(100% - 410px)); min-width:245px; }
  #trial-time { font-size:21px; }
  #trial-tiers { margin:5px 0; }
  #trial-tiers button { min-height:44px; }
  #steering { bottom:calc(var(--safe-bottom) + 14px); width:108px; height:108px; }
  #steer-knob { top:26px; left:26px; }
  .touch-pedals { bottom:calc(var(--safe-bottom) + 14px); grid-template-columns:60px 70px; }
  #touch-ui .pedal { height:74px; }
  .touch-dialog { padding:15px 20px; }
  .touch-dialog h2 { font-size:23px; }
  .touch .intro p { margin:8px 0; line-height:1.4; }
  .touch #welcome h1 { font-size:38px; margin:8px 0; }
  .touch .controls { margin-top:5px; line-height:1.6; }
  .touch #welcome button { padding:12px 22px; margin:8px 0; }
}

@media(max-width:740px) and (orientation:landscape) { .touch.has-trial .touch-clock { display:none; } }
@media(max-width:600px) and (orientation:landscape) { #trial-card { min-width:220px; } #trial-gate { font-size:10px; } }

#touch-mini-time { display:none; font-size:11px; color:#f4b58c; }
@media(max-height:380px) { .touch.has-trial #touch-mini-time { display:block; } .touch:not(.in-trial) #trial-direction { display:none; } }

@media(max-width:360px) and (orientation:portrait) { .touch-speed { bottom:calc(var(--safe-bottom) + 172px); } }
@media(max-width:600px) and (orientation:landscape) { #touch-ui .touch-tools button { font-size:11px; padding:8px; } }
