:root { --ink: #2a1a50; --yel: #ffd21a; --red: #ff4a5a; --pink: #ff5aa8; --sky: #3d9cff; --mint: #3cd07a; --fnt: "Trebuchet MS", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #3d9cff; font-family: var(--fnt); color: var(--ink); touch-action: none; user-select: none; -webkit-user-select: none; overscroll-behavior: none; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#ui { position: fixed; inset: 0; pointer-events: none; }
.hidden { display: none !important; }
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2vmin; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); pointer-events: auto; overflow-y: auto; }
.screen.panel { background: rgba(30, 16, 70, 0.55); backdrop-filter: blur(3px); }
h2 { margin: 0; font-size: clamp(22px, 4.6vmin, 46px); color: #fff; -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); letter-spacing: 0.02em; text-align: center; }
button { font-family: var(--fnt); font-weight: 800; font-size: clamp(14px, 2.4vmin, 21px); color: var(--ink); background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 0.55em 1.1em; box-shadow: 0 4px 0 var(--ink); cursor: pointer; transition: transform 0.08s; pointer-events: auto; }
button:hover { transform: translateY(-2px) rotate(-1deg); }
button:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
button.big { background: var(--yel); font-size: clamp(18px, 3.4vmin, 30px); min-width: min(78vw, 360px); }
button.go { background: var(--mint); color: #fff; -webkit-text-stroke: 0.6px var(--ink); paint-order: stroke fill; }
button.small { font-size: 14px; padding: 0.4em 0.8em; }
button.warn { background: #ffb0b8; }
button.sel, .seg button.sel { background: var(--pink); color: #fff; }
.logo { text-align: center; transform: rotate(-3deg); margin-bottom: 1vmin; }
.logo .l1, .logo .l2 { display: inline-block; font-size: clamp(46px, 12vmin, 130px); font-weight: 900; line-height: 0.95; -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); }
.logo .l1 { color: var(--red); } .logo .l2 { color: #ffb84a; }
.logo .sub { font-size: clamp(14px, 3vmin, 26px); color: #fff; font-weight: 800; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; margin-top: 0.4em; }
.menu { display: flex; flex-direction: column; gap: 1.4vmin; align-items: center; }
.menu .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.foot { position: absolute; bottom: max(8px, env(safe-area-inset-bottom)); font-size: 12px; color: #fff; opacity: 0.9; text-shadow: 0 1px 2px #0008; text-align: center; padding: 0 8px; }
.navrow { display: flex; gap: 12px; justify-content: center; margin-top: 1vmin; }
.navrow.wrap { flex-wrap: wrap; }
.optrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.optrow.center { justify-content: center; }
.optrow > span { font-weight: 800; color: #fff; -webkit-text-stroke: 0.8px var(--ink); paint-order: stroke fill; min-width: 6.5em; font-size: 17px; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { padding: 0.35em 0.75em; font-size: clamp(13px, 2vmin, 17px); border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
/* Fahrerwahl */
#scr-select { justify-content: flex-end; }
#scr-select h2 { margin-bottom: auto; }
.selwrap { display: flex; gap: 2vmin; align-items: flex-start; justify-content: center; width: min(1100px, 100%); }
.chars { display: grid; grid-template-columns: repeat(4, minmax(70px, 120px)); gap: 1.2vmin; }
.card { background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); padding: 4px; text-align: center; cursor: pointer; font-weight: 800; font-size: clamp(11px, 1.7vmin, 15px); }
.card img { width: 100%; aspect-ratio: 1; display: block; border-radius: 9px; background: linear-gradient(#9fd4ff, #e8f6ff); }
.card.sel { background: var(--yel); transform: translateY(-3px) rotate(-1.5deg); }
.kartpanel { background: rgba(255, 255, 255, 0.88); border: 3px solid var(--ink); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 9px; box-shadow: 0 5px 0 var(--ink); min-width: 290px; max-width: 420px; }
.kartpanel .optrow > span { color: var(--ink); -webkit-text-stroke: 0; min-width: 5.5em; font-size: 15px; }
.charinfo b { font-size: 21px; } .charinfo p { margin: 2px 0 0; font-size: 14px; }
.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatches button { width: 30px; height: 30px; padding: 0; border-radius: 50%; box-shadow: 0 2px 0 var(--ink); }
.swatches button.sel { outline: 3px solid var(--pink); outline-offset: 2px; }
.statbars { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; font-size: 14px; font-weight: 800; align-items: center; }
.statbars .b { height: 12px; background: #e8e0f8; border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; }
.statbars .b i { display: block; height: 100%; background: linear-gradient(90deg, #ffb84a, var(--red)); }
/* Strecken */
.tracklist { display: grid; grid-template-columns: repeat(4, minmax(120px, 210px)); gap: 1.4vmin; max-width: 100%; }
.tcard { background: #fff; border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); padding: 8px; cursor: pointer; font-size: 13px; }
.tcard b { display: block; font-size: clamp(14px, 2vmin, 18px); }
.tcard .thumb { height: 60px; border-radius: 8px; margin-bottom: 6px; border: 2px solid var(--ink); background-size: contain; background-repeat: no-repeat; background-position: center; }
.tcard .best { color: #6a4aa0; font-weight: 700; }
.tcard.sel { background: var(--yel); transform: translateY(-3px); }
.tcard.cup { min-height: 150px; }
.cupwrap { display: flex; gap: 2vmin; flex-wrap: wrap; justify-content: center; }
.cupwrap .tcard { width: min(80vw, 300px); }
.trophy { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--ink); vertical-align: middle; margin-left: 6px; }
.trophy.g { background: #ffd21a; } .trophy.s { background: #d8dce8; } .trophy.b { background: #e0904a; }
/* Einstellungen / Hilfe */
.setlist, .help { background: rgba(255, 255, 255, 0.92); border: 3px solid var(--ink); border-radius: 16px; padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; max-width: min(640px, 94vw); box-shadow: 0 5px 0 var(--ink); }
.setlist .optrow > span { color: var(--ink); -webkit-text-stroke: 0; }
.help p { margin: 0; line-height: 1.45; font-size: 15px; }
.tog { font-weight: 800; display: flex; gap: 8px; align-items: center; font-size: 16px; cursor: pointer; color: var(--ink); background: #fff; border-radius: 10px; padding: 4px 8px; }
.tog input { width: 22px; height: 22px; accent-color: var(--pink); }
.records { font-size: 13px; line-height: 1.5; }
.spk { font-weight: 900; padding: 0 4px; border-radius: 4px; color: #fff; } .spk.b { background: #2f8cff; } .spk.o { background: #ff8a1a; } .spk.p { background: #b040ff; }
.itemhelp { display: grid; grid-template-columns: 40px 1fr; gap: 6px 10px; align-items: center; font-size: 14px; }
.itemhelp img { width: 40px; height: 40px; }
/* HUD */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-tl { position: absolute; left: max(10px, env(safe-area-inset-left)); top: max(8px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 10px; }
.pos { font-size: clamp(44px, 9vmin, 84px); font-weight: 900; color: var(--yel); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); line-height: 1; }
.pos small { font-size: 0.5em; }
.lapbox { font-weight: 900; color: #fff; -webkit-text-stroke: 1.2px var(--ink); paint-order: stroke fill; font-size: clamp(16px, 3vmin, 26px); text-shadow: 0 2px 0 var(--ink); }
.hud-tr { position: absolute; right: max(10px, env(safe-area-inset-right)); top: max(8px, env(safe-area-inset-top)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.itemslot { width: clamp(64px, 12vmin, 96px); height: clamp(64px, 12vmin, 96px); border: 4px solid var(--ink); border-radius: 18px; background: rgba(255, 255, 255, 0.85); box-shadow: 0 4px 0 var(--ink); position: relative; }
.itemslot canvas { width: 100%; height: 100%; }
.itemslot span { position: absolute; right: 4px; bottom: 0; font-weight: 900; font-size: 20px; -webkit-text-stroke: 1px #fff; }
.itemslot.roll { animation: wob 0.15s infinite; }
@keyframes wob { 50% { transform: rotate(5deg) scale(1.05); } }
.coins { font-weight: 900; font-size: clamp(18px, 3.2vmin, 28px); color: var(--yel); -webkit-text-stroke: 1.2px var(--ink); paint-order: stroke fill; display: flex; align-items: center; gap: 5px; }
.coins i { width: 0.9em; height: 0.9em; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6b0, #ffc61a 55%, #c88a00); border: 2px solid var(--ink); }
.minimap { position: absolute; left: max(8px, env(safe-area-inset-left)); bottom: max(8px, env(safe-area-inset-bottom)); width: clamp(110px, 22vmin, 180px); height: clamp(110px, 22vmin, 180px); }
.speed { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: max(10px, env(safe-area-inset-bottom)); text-align: right; font-weight: 900; color: #fff; -webkit-text-stroke: 1.2px var(--ink); paint-order: stroke fill; }
.speed span { font-size: clamp(26px, 5vmin, 44px); } .speed small { font-size: 14px; margin-left: 3px; }
.speed .bar { width: clamp(100px, 18vmin, 160px); height: 10px; border: 2px solid var(--ink); border-radius: 6px; background: #fff8; overflow: hidden; margin-left: auto; }
.speed .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--mint), var(--yel), var(--red)); }
.pausebtn { position: absolute; top: max(8px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); padding: 0.3em 0.75em; font-size: 18px; pointer-events: auto; background: #fffc; }
.pausebtn:hover { transform: translateX(-50%); }
.ranklist { position: absolute; left: max(10px, env(safe-area-inset-left)); top: clamp(80px, 15vmin, 120px); display: flex; flex-direction: column; gap: 2px; font-size: 12px; font-weight: 800; }
.ranklist div { background: #fffc; border: 2px solid var(--ink); border-radius: 8px; padding: 0 6px; display: flex; gap: 5px; align-items: center; width: 118px; }
.ranklist div.me { background: var(--yel); }
.ranklist div i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--ink); }
#msg { position: absolute; left: 0; right: 0; top: 30%; text-align: center; font-size: clamp(40px, 12vmin, 120px); font-weight: 900; color: var(--yel); -webkit-text-stroke: 3px var(--ink); paint-order: stroke fill; text-shadow: 0 7px 0 var(--ink); pointer-events: none; opacity: 0; transition: opacity 0.2s; }
#msg.show { opacity: 1; animation: pop 0.35s; }
#msg.smallmsg { font-size: clamp(26px, 6vmin, 60px); }
@keyframes pop { 0% { transform: scale(0.4); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
#toast { position: absolute; left: 50%; bottom: 18%; transform: translateX(-50%); background: #fff; border: 3px solid var(--ink); border-radius: 12px; padding: 8px 14px; font-weight: 800; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
#toast.show { opacity: 1; }
#loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 900; color: #fff; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; background: #3d9cff; pointer-events: auto; }
#sharebox { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: #0006; pointer-events: auto; }
#sharebox .panel { background: #fff; border: 3px solid var(--ink); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
#sharebox input { font-size: 16px; padding: 6px; width: min(80vw, 360px); }
/* Ergebnisse */
#scr-results { justify-content: flex-start; padding-top: max(14px, env(safe-area-inset-top)); }
#scr-results .sub { color: #fff; font-weight: 800; -webkit-text-stroke: 0.8px var(--ink); paint-order: stroke fill; font-size: clamp(15px, 2.6vmin, 22px); text-align: center; }
.restable { margin-top: auto; background: rgba(255, 255, 255, 0.92); border: 3px solid var(--ink); border-radius: 14px; box-shadow: 0 4px 0 var(--ink); padding: 6px 10px; font-size: clamp(12px, 1.9vmin, 16px); font-weight: 700; display: grid; grid-template-columns: auto auto 1fr auto auto; gap: 1px 12px; max-width: 96vw; }
.restable .me { color: #d02a7a; font-weight: 900; }
.restable .hd { font-weight: 900; border-bottom: 2px solid var(--ink); }
.restable i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; border: 1.5px solid var(--ink); vertical-align: middle; }
/* Touch */
#touch { position: absolute; inset: 0; pointer-events: none; }
.tbtn { position: absolute; pointer-events: auto; display: flex; align-items: center; justify-content: center; font-weight: 900; color: #fff; -webkit-text-stroke: 1px var(--ink); paint-order: stroke fill; border: 4px solid var(--ink); border-radius: 50%; background: rgba(255, 255, 255, 0.35); box-shadow: 0 4px 0 rgba(42, 26, 80, 0.7); font-size: clamp(16px, 3.4vmin, 24px); touch-action: none; }
.tbtn.on { transform: translateY(3px) scale(0.96); background: rgba(255, 210, 26, 0.75); }
.tbtn.steer { width: clamp(70px, 16vmin, 110px); height: clamp(70px, 16vmin, 110px); bottom: max(18px, env(safe-area-inset-bottom)); font-size: clamp(26px, 6vmin, 40px); }
.tbtn.steer.l { left: max(14px, env(safe-area-inset-left)); }
.tbtn.steer.r { left: calc(max(14px, env(safe-area-inset-left)) + clamp(80px, 18vmin, 124px)); }
.tbtn.gas { width: clamp(78px, 17vmin, 118px); height: clamp(78px, 17vmin, 118px); right: max(14px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); background: rgba(60, 208, 122, 0.55); }
.tbtn.drift { width: clamp(70px, 15vmin, 104px); height: clamp(70px, 15vmin, 104px); right: calc(max(14px, env(safe-area-inset-right)) + clamp(86px, 19vmin, 130px)); bottom: max(18px, env(safe-area-inset-bottom)); background: rgba(255, 90, 168, 0.55); font-size: clamp(13px, 2.8vmin, 19px); }
.tbtn.item { width: clamp(62px, 13vmin, 92px); height: clamp(62px, 13vmin, 92px); right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + clamp(88px, 19vmin, 132px)); background: rgba(61, 156, 255, 0.55); font-size: clamp(13px, 2.6vmin, 18px); }
.tbtn.brake { width: clamp(46px, 9vmin, 64px); height: clamp(46px, 9vmin, 64px); right: calc(max(14px, env(safe-area-inset-right)) + clamp(96px, 21vmin, 144px)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + clamp(84px, 18vmin, 124px)); font-size: 18px; }
.swipe { position: absolute; left: 0; bottom: 0; width: 45%; height: 55%; pointer-events: auto; touch-action: none; }
.swipe .knob { position: absolute; width: 70px; height: 70px; border-radius: 50%; border: 4px solid var(--ink); background: rgba(255, 255, 255, 0.4); left: 60px; bottom: 40px; opacity: 0.8; }
body.touch .minimap { bottom: auto; top: clamp(150px, 28vmin, 200px); left: auto; right: max(8px, env(safe-area-inset-right)); width: clamp(90px, 18vmin, 140px); height: clamp(90px, 18vmin, 140px); }
body.touch .speed { bottom: auto; top: max(8px, env(safe-area-inset-top)); right: auto; left: 50%; transform: translateX(-50%); margin-top: 44px; text-align: center; }
body.touch .speed .bar { display: none; }
body.touch .ranklist { display: none; }
@media (max-width: 760px), (max-height: 520px) {
  .selwrap { flex-direction: column; align-items: center; }
  .chars { grid-template-columns: repeat(8, minmax(36px, 1fr)); width: 100%; gap: 4px; }
  .card { font-size: 0; padding: 2px; border-width: 2px; }
  .kartpanel { min-width: 0; width: 100%; padding: 8px 10px; gap: 6px; }
  .tracklist { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .tcard .thumb { height: 42px; }
}
@media (max-height: 520px) and (orientation: landscape) {
  .selwrap { flex-direction: row; align-items: flex-start; }
  .chars { grid-template-columns: repeat(4, 54px); width: auto; }
  .tracklist { grid-template-columns: repeat(4, minmax(110px, 1fr)); }
  .tcard { padding: 4px; font-size: 11px; } .tcard .thumb { height: 34px; }
  #scr-select h2 { display: none; }
  #scr-select { align-items: flex-end; }
  .selwrap { justify-content: flex-end; width: auto; }
  .kartpanel { max-width: 380px; padding: 6px 10px; gap: 4px; }
  .charinfo p { display: none; }
  .logo .l1, .logo .l2 { font-size: 13vmin; }
  .menu { gap: 6px; } button.big { padding: 0.3em 1em; }
  #scr-results .restable { position: absolute; right: max(10px, env(safe-area-inset-right)); top: 64px; margin: 0; font-size: 11px; max-width: 46vw; }
  #scr-results .navrow { margin-top: auto; }
}
@media (orientation: portrait) and (max-width: 760px) {
  #scr-select { justify-content: flex-start; }
  #scr-select h2 { margin-top: 4px; }
  .selwrap { margin-top: auto; }
}

/* Tastatur-/Gamepad-Fokus sichtbar */
button:focus-visible, .card:focus-visible, .tcard:focus-visible, .card:focus, .tcard:focus { outline: 4px solid #ffd21a; outline-offset: 2px; }
