/* TeeWorlds UI: "Spielzeugwerkstatt" (toy workshop) look (PLAN 7.10): soft rounded cards with a thick dark contour
   like the tee silhouette, a biome edge on top of every card, pickup-style icons, Titan One + Rubik (SIL OFL). */
@font-face { font-family: 'Titan One'; src: url('../assets/fonts/TitanOne-latin.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Rubik'; src: url('../assets/fonts/Rubik-latin.woff2') format('woff2'); font-weight: 300 900; font-display: swap; }

:root {
  --ink: #1d1a2a; --ink2: #3a3450; --paper: #fff8ec; --paper2: #f3e8d6; --mute: #8a8098;
  --grass: #5dbb3f; --grass2: #3d8a2a; --sand: #e7c27a; --snow: #eef4ff; --moss: #58a845; --crystal: #9f7fff;
  --red: #e8483b; --blue: #3b8be8; --gold: #ffd24a; --ok: #4fc86a; --warn: #ffb03a; --bad: #e8483b;
  --edge: var(--grass); --edge2: var(--grass2);
  --ts: 1;  /* text scale (settings) */
  --r: 18px;
  --shadow: 0 6px 0 rgba(20, 14, 34, 0.55), 0 14px 30px rgba(0, 0, 0, 0.35);
  font-family: 'Rubik', system-ui, sans-serif;
}
body[data-biome='desert'] { --edge: var(--sand); --edge2: #b8743f; }
body[data-biome='winter'] { --edge: var(--snow); --edge2: #9ab0d8; }
body[data-biome='jungle'] { --edge: var(--moss); --edge2: #2a5a2a; }
body[data-biome='crystal'] { --edge: var(--crystal); --edge2: #5a3ab0; }
body.cb-protan { --red: #d88a1a; } body.cb-deutan { --red: #d8901a; } body.cb-tritan { --blue: #2ab8b8; }

#ui-root * { box-sizing: border-box; }
.tw-screen { position: absolute; inset: 0; pointer-events: none; display: flex; font-size: calc(16px * var(--ts)); color: var(--ink); }
.tw-screen > * { pointer-events: auto; }
.tw-screen.in { animation: tw-pullin 380ms cubic-bezier(.2, .9, .3, 1.1) both; }
.tw-screen.out { animation: tw-pullout 260ms ease-in both; pointer-events: none; }
.tw-screen.out > * { pointer-events: none; }
@keyframes tw-pullin { from { transform: translateX(-60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes tw-pullout { to { transform: translateX(80px); opacity: 0; } }
.reduced .tw-screen.in, .reduced .tw-screen.out { animation-duration: 1ms; }

/* hook wipe: a claw shoots across, hooks the page and pulls it in */
.tw-wipe { position: absolute; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.tw-wipe .claw { position: absolute; top: 46%; left: 100%; width: 70px; height: 56px; animation: tw-claw 420ms cubic-bezier(.3, .6, .2, 1) both; }
.tw-wipe .rope { position: absolute; top: calc(46% + 26px); height: 6px; right: 0; width: 0; background: repeating-linear-gradient(60deg, #c9a77a 0 6px, #8a6a44 6px 9px); border: 2px solid var(--ink); border-radius: 3px; animation: tw-rope 420ms cubic-bezier(.3, .6, .2, 1) both; }
@keyframes tw-claw { 0% { left: 100%; } 55% { left: -2%; } 100% { left: 110%; } }
@keyframes tw-rope { 0% { width: 0; } 55% { width: 102%; } 100% { width: 0; right: -10%; } }

/* cards and buttons */
.tw-card { position: relative; background: var(--paper); border: 4px solid var(--ink); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px 20px; }
.tw-card::before { content: ''; position: absolute; left: -4px; right: -4px; top: -4px; height: 18px; border: 4px solid var(--ink); border-bottom: none; border-radius: var(--r) var(--r) 0 0;
  background: radial-gradient(circle at 8px 18px, var(--edge) 7px, transparent 8px) 0 0 / 16px 18px repeat-x, linear-gradient(var(--edge), var(--edge2)); }
.tw-card.plain::before { display: none; }
.tw-card h2, .tw-h { font-family: 'Titan One', 'Rubik', sans-serif; font-weight: 400; margin: 6px 0 12px; font-size: 1.6em; letter-spacing: 0.5px; color: var(--ink); }
.tw-card h3 { font-family: 'Titan One', sans-serif; font-weight: 400; margin: 10px 0 6px; font-size: 1.1em; }
.tw-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font: 700 1em 'Rubik', sans-serif; color: var(--ink); background: #fff;
  border: 3px solid var(--ink); border-radius: 14px; padding: 10px 18px; box-shadow: 0 4px 0 var(--ink); cursor: pointer; transition: transform 80ms, box-shadow 80ms, background 120ms; min-height: 44px; }
.tw-btn:hover, .tw-btn.focus { background: #fff3c4; transform: translateY(-2px); box-shadow: 0 6px 0 var(--ink); }
.tw-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.tw-btn.primary { background: var(--gold); }
.tw-btn.primary:hover, .tw-btn.primary.focus { background: #ffe27a; }
.tw-btn.red { background: #ff8a7a; } .tw-btn.blue { background: #8ac0ff; } .tw-btn.green { background: #9be36b; }
.tw-btn[disabled], .tw-btn.disabled { opacity: 0.45; pointer-events: none; filter: grayscale(0.6); }
.tw-btn.small { padding: 6px 12px; min-height: 34px; font-size: 0.9em; border-radius: 10px; box-shadow: 0 3px 0 var(--ink); }
.tw-btn.ghost { background: transparent; box-shadow: none; border-color: transparent; }
.tw-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tw-col { display: flex; flex-direction: column; gap: 10px; }
.tw-grow { flex: 1; }
.tw-muted { color: var(--mute); }
.tw-small { font-size: 0.85em; }
.tw-tag { display: inline-block; padding: 2px 8px; border-radius: 8px; border: 2px solid var(--ink); background: #fff; font-weight: 700; font-size: 0.8em; }
.tw-tag.red { background: #ffb0a6; } .tw-tag.blue { background: #b0d4ff; } .tw-tag.gold { background: var(--gold); } .tw-tag.green { background: #b8f09a; }

/* focus claw cursor (gamepad / keyboard navigation) */
.tw-cursor { position: absolute; width: 34px; height: 30px; pointer-events: none; z-index: 30; transition: left 120ms cubic-bezier(.3, 1.4, .5, 1), top 120ms cubic-bezier(.3, 1.4, .5, 1), opacity 120ms; opacity: 0; }
.tw-cursor.on { opacity: 1; }

/* loading */
.tw-loading { align-items: center; justify-content: center; flex-direction: column; gap: 22px; background: radial-gradient(ellipse at 50% 40%, #2a2050, #120e22 70%); color: #fff; }
.tw-loading .bar { position: relative; display: flex; gap: 10px; }
.tw-loading .seg { width: 70px; height: 18px; border: 3px solid #fff; border-radius: 9px; background: rgba(255, 255, 255, 0.08); position: relative; overflow: hidden; }
.tw-loading .seg.done { background: var(--gold); border-color: var(--gold); }
.tw-loading .seg.cur::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent); animation: tw-shine 900ms linear infinite; }
@keyframes tw-shine { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.tw-loading .tee { position: absolute; top: -62px; transition: left 300ms cubic-bezier(.3, 1.3, .5, 1); }
.tw-loading .step { font-weight: 600; opacity: 0.85; }
.tw-loading .tip { max-width: 560px; text-align: center; opacity: 0.75; min-height: 2.6em; }
.tw-word { font-family: 'Titan One', sans-serif; font-size: 72px; color: #fff; text-shadow: 0 5px 0 var(--ink), 4px 0 0 var(--ink), -4px 0 0 var(--ink), 0 -4px 0 var(--ink), 0 10px 24px rgba(0, 0, 0, 0.5); letter-spacing: 2px; line-height: 1; }
.tw-word span { color: var(--gold); }
.tw-err { background: var(--bad); padding: 14px 18px; border-radius: 12px; border: 3px solid #fff; max-width: 520px; }

/* title */
.tw-title { flex-direction: column; align-items: center; justify-content: space-between; padding: 8vh 0 9vh; }
.tw-title .tw-word { font-size: clamp(56px, 10vw, 120px); animation: tw-bob 3s ease-in-out infinite; position: relative; }
/* title diorama: a light sweep over the word mark, soft light beams and floating motes over the live scene */
.tw-title .tw-word::after { content: ''; position: absolute; inset: -10% -6%; background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.55) 48%, transparent 60%); mix-blend-mode: soft-light; animation: tw-sweep 5.5s ease-in-out infinite; pointer-events: none; }
@keyframes tw-sweep { 0%, 55% { transform: translateX(-70%); opacity: 0; } 62% { opacity: 1; } 100% { transform: translateX(70%); opacity: 0; } }
.tw-title::before { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(60% 40% at 50% 30%, rgba(255, 236, 190, 0.18), transparent 70%), repeating-linear-gradient(100deg, transparent 0 9%, rgba(255, 244, 214, 0.06) 10% 13%, transparent 14% 22%); animation: tw-beams 14s linear infinite; }
@keyframes tw-beams { from { background-position: 0 0, 0 0; } to { background-position: 0 0, 600px 0; } }
body.reduced .tw-title::before, body.reduced .tw-title .tw-word::after { animation: none; }
.tw-title .sub { font-family: 'Titan One', sans-serif; color: #fff; font-size: 26px; text-shadow: 0 3px 0 var(--ink); margin-top: 8px; text-align: center; }
.tw-title .press { font-family: 'Titan One', sans-serif; font-size: 28px; color: #fff; text-shadow: 0 3px 0 var(--ink); animation: tw-pulse 1.4s ease-in-out infinite; }
.tw-title .wip { position: absolute; right: 18px; bottom: 14px; color: rgba(255, 255, 255, 0.75); font-size: 13px; text-shadow: 0 1px 0 #000; }
@keyframes tw-bob { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-8px) rotate(1deg); } }
@keyframes tw-pulse { 0%, 100% { opacity: 0.55; transform: scale(0.97); } 50% { opacity: 1; transform: scale(1.03); } }

/* main menu */
.tw-main { align-items: stretch; padding: 4vh 0 4vh 4vw; gap: 3vw; }
.tw-main .left { display: flex; flex-direction: column; gap: 12px; width: min(380px, 40vw); justify-content: center; }
.tw-main .logo { margin-bottom: 8px; }
.tw-main .logo .tw-word { font-size: 54px; }
.tw-menuitem { display: flex; align-items: center; gap: 14px; padding: 12px 18px; border: 4px solid var(--ink); border-radius: 16px; background: var(--paper); box-shadow: 0 5px 0 var(--ink);
  font: 400 24px 'Titan One', sans-serif; cursor: pointer; transition: transform 100ms, background 120ms; color: var(--ink); text-align: left; }
.tw-menuitem small { display: block; font: 500 13px 'Rubik', sans-serif; color: var(--mute); }
.tw-menuitem:hover, .tw-menuitem.focus { transform: translateX(10px) rotate(-0.5deg); background: #fff3c4; }
.tw-menuitem .ico { width: 42px; height: 42px; flex: none; }
.tw-news { margin-top: 10px; font-size: 14px; }
.tw-news .item { padding: 6px 0; border-bottom: 2px dashed rgba(29, 26, 42, 0.15); }
.tw-profile { position: absolute; right: 3vw; bottom: 4vh; display: flex; gap: 12px; align-items: center; }
.tw-xpbar { width: 180px; height: 14px; border: 3px solid var(--ink); border-radius: 8px; background: #fff; overflow: hidden; }
.tw-xpbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #ff9a3a); }

/* generic panel screen */
.tw-panel { align-items: center; justify-content: center; padding: 3vh 3vw; }
.tw-panel > .tw-card { width: min(1100px, 94vw); max-height: 92vh; display: flex; flex-direction: column; }
.tw-panel .body { overflow: auto; flex: 1; padding-right: 6px; }
.tw-panel .foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.tw-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tw-tab { padding: 8px 14px; border: 3px solid var(--ink); border-radius: 12px 12px 4px 4px; background: var(--paper2); font-weight: 700; cursor: pointer; }
.tw-tab.on { background: var(--gold); }

/* setup */
.tw-maps { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.tw-mapcard { border: 3px solid var(--ink); border-radius: 14px; overflow: hidden; background: #fff; cursor: pointer; transition: transform 100ms; position: relative; }
.tw-mapcard:hover, .tw-mapcard.focus { transform: translateY(-3px) rotate(-0.5deg); }
.tw-mapcard.on { outline: 5px solid var(--gold); }
.tw-mapcard .pic { height: 92px; background-size: cover; background-position: center; }
.tw-mapcard .nm { font: 400 15px 'Titan One', sans-serif; padding: 6px 8px 2px; }
.tw-mapcard .md { font-size: 11px; padding: 0 8px 7px; color: var(--mute); }
.tw-opt { display: grid; grid-template-columns: 180px 1fr; gap: 8px 14px; align-items: center; }
.tw-opt label { font-weight: 700; }
.tw-seg { display: inline-flex; border: 3px solid var(--ink); border-radius: 12px; overflow: hidden; flex-wrap: wrap; }
.tw-seg button { border: none; border-right: 2px solid var(--ink); background: #fff; padding: 7px 12px; font: 600 0.92em 'Rubik', sans-serif; cursor: pointer; color: var(--ink); }
.tw-seg button:last-child { border-right: none; }
.tw-seg button.on { background: var(--gold); }
.tw-seg button:hover, .tw-seg button.focus { background: #fff3c4; }
.tw-seg button.on.focus { background: #ffe27a; }
/* the mode picker: a tidy grid instead of a long wrapped row (up to 13 modes on a map) */
.tw-seg.modes { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tw-seg.modes button { border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); margin: 0 -2px -2px 0; text-align: left; }
.tw-range { display: flex; gap: 10px; align-items: center; }
.tw-range input { width: 220px; accent-color: var(--ink); }
.tw-input { border: 3px solid var(--ink); border-radius: 10px; padding: 8px 12px; font: 600 1em 'Rubik', sans-serif; background: #fff; color: var(--ink); min-width: 0; }
.tw-input:focus { outline: 3px solid var(--gold); }
.tw-keyrow { display: grid; grid-template-columns: 1fr 110px 110px 120px; gap: 8px; align-items: center; padding: 3px 0; }
.tw-keyrow.head b { font-size: 12px; text-align: center; }
.tw-key.pad { display: flex; align-items: center; justify-content: center; min-height: 34px; }
/* gamepad glyphs (brief 4c): the face buttons in the colours of the pad family */
.tw-glyph { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 24px; padding: 0 7px; border-radius: 12px; border: 2px solid var(--ink); background: #3a3550; color: #fff; font: 700 12px Rubik, sans-serif; margin: 1px 2px; white-space: nowrap; }
.tw-glyph.none { background: transparent; color: var(--ink); border-style: dashed; }
.tw-glyph.xbox.PadA { background: #5fbf4a; } .tw-glyph.xbox.PadB { background: #e8483b; } .tw-glyph.xbox.PadX { background: #3b8be8; } .tw-glyph.xbox.PadY { background: #f2c230; color: var(--ink); }
.tw-glyph.ps.PadA { color: #9ec0ff; } .tw-glyph.ps.PadB { color: #ff97a3; } .tw-glyph.ps.PadX { color: #f0a8f8; } .tw-glyph.ps.PadY { color: #7fe0c4; }
.tw-glyph.PadA, .tw-glyph.PadB, .tw-glyph.PadX, .tw-glyph.PadY { width: 26px; padding: 0; border-radius: 50%; }
.tw-padhint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 34; pointer-events: none; font-weight: 700; font-size: 14px; color: #fff; text-shadow: 0 2px 0 var(--ink); opacity: 0; transition: opacity 400ms; }
.tw-padhint.on { opacity: 0.9; }
.tw-sticks { border: 3px solid var(--ink); border-radius: 10px; background: #fff; }
.tw-card.wide { width: min(1100px, 96vw); }
.tw-paddraw { width: 100%; height: auto; display: block; }
.tw-paddraw .body { fill: #f3e8d6; stroke: var(--ink); stroke-width: 4; }
.tw-paddraw .pt { fill: #d9cbb4; stroke: var(--ink); stroke-width: 3; }
.tw-paddraw .well { fill: #c9b9a0; stroke: var(--ink); stroke-width: 3; } .tw-paddraw .stick { fill: #3a3550; stroke: var(--ink); stroke-width: 3; }
.tw-paddraw .face { stroke: var(--ink); stroke-width: 3; } .tw-paddraw .fl { font: 700 15px Rubik, sans-serif; text-anchor: middle; fill: #1d1a2a; }
.tw-paddraw .lead { fill: none; stroke: #6a6278; stroke-width: 1.5; }
.tw-paddraw .lab { font: 600 15px Rubik, sans-serif; fill: var(--ink); } .tw-paddraw .lab.L { text-anchor: end; } .tw-paddraw .lab.R { text-anchor: start; } .tw-paddraw .lab.free { fill: #8a8298; }
.tw-key { border: 3px solid var(--ink); border-radius: 8px; padding: 4px 8px; background: #fff; font-weight: 700; text-align: center; cursor: pointer; }
.tw-key.wait { background: var(--gold); animation: tw-pulse 0.8s infinite; }

/* toasts and modals */
.tw-toasts { position: absolute; left: 50%; top: 12%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 35; pointer-events: none; }
.tw-toast { background: var(--paper); border: 3px solid var(--ink); border-radius: 12px; padding: 8px 14px; font-weight: 700; box-shadow: 0 4px 0 var(--ink); animation: tw-toast 3.2s ease both; }
@keyframes tw-toast { 0% { opacity: 0; transform: translateY(-12px) scale(0.9); } 8% { opacity: 1; transform: none; } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-6px); } }
.tw-modal { position: absolute; inset: 0; background: rgba(10, 6, 20, 0.55); display: flex; align-items: center; justify-content: center; z-index: 45; pointer-events: auto; }
.tw-modal .tw-card { max-width: 520px; }

/* HUD */
.tw-hud { position: absolute; inset: 0; pointer-events: none; font-family: 'Rubik', sans-serif; color: #fff; font-size: calc(16px * var(--ts)); --hs: 1; }
.tw-hud .safe { position: absolute; left: 5vw; right: 5vw; top: 5vh; bottom: 5vh; }
.tw-hud .health { position: absolute; left: 0; top: 0; display: flex; flex-direction: column; gap: 4px; transform: scale(var(--hs)); transform-origin: top left; }
.tw-hud .icons { display: flex; gap: 2px; }
.tw-hud .icons i { width: 22px; height: 22px; background-size: contain; background-repeat: no-repeat; background-position: center; opacity: 0.25; filter: grayscale(1); transition: opacity 120ms; }
.tw-hud .icons i.on { opacity: 1; filter: none; }
/* Classic: the original's empty hearts and shields are their own sprites, shown as they are */
.tw-hud .icons.classic i { opacity: 1; filter: none; }
/* Classic HUD: the original 0.7.5 layout and font; 1 unit = 1/300 of the screen height as in hud.cpp */
@font-face { font-family: 'TW Classic'; src: url('../assets/classic/datasrc/fonts/DejaVuSans.ttf') format('truetype'); font-display: swap; }
.tw-hud.classic { --u: calc(100vh / 300); font-family: 'TW Classic', 'DejaVu Sans', sans-serif; font-size: calc(7 * var(--u) * var(--ts)); }
.tw-hud.classic .safe { left: 0; right: 0; top: 0; bottom: 0; }
.tw-hud.classic .health { left: calc(5 * var(--u)); top: calc(5 * var(--u)); gap: calc(2 * var(--u)); transform: none; }
.tw-hud.classic .icons, .tw-hud.classic .ammo { gap: calc(2 * var(--u)); margin: 0; min-height: calc(10 * var(--u)); }
.tw-hud.classic .icons i, .tw-hud.classic .ammo i { width: calc(10 * var(--u)); height: calc(10 * var(--u)); transition: none; }
.tw-hud.classic .ammo i.off, .tw-hud.classic .weapons { display: none; }
.tw-hud.classic .top { top: calc(2 * var(--u)); gap: calc(1 * var(--u)); }
.tw-hud.classic .timer { font: 400 calc(10 * var(--u)) 'TW Classic', sans-serif; text-shadow: none; }
.tw-hud.classic .timer.low { color: #ff6060; animation: none; }
.tw-hud.classic .mode { font-weight: 400; text-shadow: 0 0 calc(1 * var(--u)) #000; }
.tw-hud.classic .teams { position: absolute; right: 0; top: calc(229 * var(--u)); display: flex; flex-direction: column; gap: calc(2 * var(--u)); align-items: flex-end; }
.tw-hud.classic .cbox { height: calc(18 * var(--u)); min-width: calc(36 * var(--u)); box-sizing: border-box; padding: 0 calc(4 * var(--u)); border-radius: calc(5 * var(--u)) 0 0 calc(5 * var(--u)); display: flex; align-items: center; justify-content: flex-end; gap: calc(3 * var(--u)); background: rgba(0, 0, 0, 0.25); }
.tw-hud.classic .cbox.r { background: rgba(255, 0, 0, 0.25); } .tw-hud.classic .cbox.b { background: rgba(0, 0, 255, 0.25); }
.tw-hud.classic .cbox.me { background: rgba(255, 255, 255, 0.25); }
.tw-hud.classic .cbox .n { font-size: calc(14 * var(--u)); min-width: calc(22 * var(--u)); text-align: center; }
.tw-hud.classic .cbox .flag { width: calc(8 * var(--u)); height: calc(16 * var(--u)); background-size: contain; background-repeat: no-repeat; background-position: center; }
.tw-hud.classic .cbox .carrier, .tw-hud.classic .cbox .nm { font-size: calc(8 * var(--u)); }
.tw-hud.classic .cbox b { font-weight: 400; font-size: calc(10 * var(--u)); }
.tw-hud.classic .scorebox { top: calc(229 * var(--u)); bottom: auto; gap: calc(2 * var(--u)); }
.tw-hud.classic .scorebox div.cbox { border: none; min-width: 0; font: inherit; padding: 0 calc(4 * var(--u)); }
.tw-hud.classic .feed { top: calc(3 * var(--u)); right: calc(5 * var(--u)); gap: calc(2 * var(--u)); }
.tw-hud.classic .feed div { background: none; padding: 0; border-radius: 0; font-weight: 400; gap: calc(3 * var(--u)); text-shadow: 0 0 calc(1 * var(--u)) #000, 0 0 calc(1 * var(--u)) #000; }
.tw-hud.classic .feed .me { background: none; text-decoration: underline; }
.tw-hud.classic .feed i { width: calc(24 * var(--u)); height: calc(9 * var(--u)); }
.tw-hud.classic .chat { left: calc(9 * var(--u)); bottom: calc(48 * var(--u)); width: calc(200 * var(--u)); gap: 0; }
.tw-hud.classic .chat .line { background: none; padding: 0; border-radius: 0; font-size: calc(6 * var(--u) * var(--ts)); text-shadow: 0 0 calc(0.8 * var(--u)) #000; }
.tw-hud.classic .chat .line.sys { color: #ffff80; }
.tw-hud.classic .chat .line.sys::before { content: '*** '; }
.tw-hud.classic .chat .line b { font-weight: 400; margin-right: calc(1 * var(--u)); }
.tw-hud.classic .big, .tw-hud.classic .announce, .tw-hud.classic .respawn { font-family: 'TW Classic', sans-serif; font-weight: 400; text-shadow: 0 0 calc(1.5 * var(--u)) #000, 0 0 calc(1.5 * var(--u)) #000; }
.tw-hud.classic .big { font-size: calc(24 * var(--u)); }
.tw-hud.classic .announce { font-size: calc(14 * var(--u)); }
.tw-hud.classic .respawn { font-size: calc(9 * var(--u)); }
.tw-hud.classic .tw-score table { background: rgba(0, 0, 0, 0.5); color: #fff; border: none; border-radius: calc(8 * var(--u)); box-shadow: none; }
.tw-hud.classic .tw-score th { font: 400 calc(9 * var(--u)) 'TW Classic', sans-serif; background: rgba(255, 255, 255, 0.08); color: #fff; }
.tw-hud.classic .tw-score th.red { background: rgba(255, 0, 0, 0.3); } .tw-hud.classic .tw-score th.blue { background: rgba(0, 0, 255, 0.3); }
.tw-hud.classic .tw-score td { font-weight: 400; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.tw-hud.classic .tw-score tr.me td { background: rgba(255, 255, 255, 0.18); }
.tw-hud .ammo { display: flex; gap: 2px; margin-top: 2px; align-items: center; }
.tw-hud .ammo i { width: 14px; height: 14px; background-size: contain; background-repeat: no-repeat; background-position: center; }
.tw-hud .ammo i.off { opacity: 0.25; }
.tw-hud .weapons { display: flex; gap: 6px; margin-top: 4px; }
.tw-hud .weapons i { width: 44px; height: 22px; background-size: contain; background-repeat: no-repeat; background-position: center; opacity: 0.35; }
.tw-hud .weapons i.on { opacity: 1; filter: drop-shadow(0 0 3px #fff); }
.tw-hud .weapons i.has { opacity: 0.7; }
.tw-hud .top { position: absolute; top: 0; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tw-hud .timer { font: 400 30px 'Titan One', sans-serif; text-shadow: 0 3px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink); }
.tw-hud .timer.low { color: #ff8a7a; animation: tw-pulse 1s infinite; }
.tw-hud .teams { display: flex; gap: 10px; align-items: center; }
.tw-hud .tscore { min-width: 64px; text-align: center; font: 400 26px 'Titan One', sans-serif; padding: 2px 12px; border: 3px solid var(--ink); border-radius: 12px; }
.tw-hud .tscore.r { background: var(--red); } .tw-hud .tscore.b { background: var(--blue); }
.tw-hud .flagst { display: flex; gap: 8px; }
.tw-hud .flagst span { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 3px solid var(--ink); border-radius: 8px; font-size: 16px; font-weight: 900; }
.tw-hud .mode { font-weight: 700; text-shadow: 0 2px 0 var(--ink); }
.tw-hud .feed { position: absolute; right: 0; top: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.tw-hud .feed div { background: rgba(20, 14, 34, 0.6); border-radius: 8px; padding: 3px 10px; font-weight: 700; display: flex; gap: 8px; align-items: center; animation: tw-feed 6s ease both; }
.tw-hud .feed .me { background: rgba(255, 210, 74, 0.35); }
.tw-hud .feed i { width: 34px; height: 16px; background-size: contain; background-repeat: no-repeat; background-position: center; }
@keyframes tw-feed { 0% { opacity: 0; transform: translateX(30px); } 4% { opacity: 1; transform: none; } 90% { opacity: 1; } 100% { opacity: 0; } }
.tw-hud .scorebox { position: absolute; right: 0; bottom: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.tw-hud .scorebox div { background: rgba(20, 14, 34, 0.62); border: 2px solid rgba(255, 255, 255, 0.25); border-radius: 10px; padding: 4px 12px; font: 400 20px 'Titan One', sans-serif; min-width: 170px; display: flex; justify-content: space-between; gap: 14px; }
.tw-hud .scorebox div.me { border-color: var(--gold); }
.tw-hud .center { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); text-align: center; }
.tw-hud .big { font: 400 64px 'Titan One', sans-serif; text-shadow: 0 5px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink); }
.tw-hud .announce { position: absolute; left: 50%; top: 18%; transform: translateX(-50%); font: 400 34px 'Titan One', sans-serif; text-shadow: 0 4px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink); text-align: center; white-space: nowrap; }
.tw-hud .announce.pop { animation: tw-ann 2.2s ease both; }
@keyframes tw-ann { 0% { opacity: 0; transform: translateX(-50%) scale(1.6); } 10% { opacity: 1; transform: translateX(-50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translateX(-50%) translateY(-14px); } }
.tw-hud .respawn { position: absolute; left: 50%; top: 58%; transform: translateX(-50%); font: 400 24px 'Titan One', sans-serif; text-shadow: 0 3px 0 var(--ink); text-align: center; }
.tw-hud .hint { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); background: rgba(20, 14, 34, 0.6); padding: 6px 14px; border-radius: 10px; font-weight: 700; }
.tw-hud .chat { position: absolute; left: 0; bottom: 0; width: min(520px, 40vw); display: flex; flex-direction: column; gap: 3px; }
.tw-hud .chat .line { background: rgba(20, 14, 34, 0.55); border-radius: 6px; padding: 3px 8px; font-size: 15px; transition: opacity 600ms; }
.tw-hud .chat .line b { margin-right: 6px; }
.tw-hud .chat .line.sys { color: #ffe27a; }
.tw-hud .chat .line.team b::before { content: '[T] '; color: #9be36b; }
.tw-hud .chat input { pointer-events: auto; border: 3px solid var(--gold); border-radius: 8px; background: rgba(20, 14, 34, 0.85); color: #fff; font: 600 15px 'Rubik', sans-serif; padding: 7px 10px; outline: none; }
.tw-hud .voicebadge { position: absolute; left: 0; top: 120px; display: flex; flex-direction: column; gap: 3px; }
.tw-hud .voicebadge div { background: rgba(20, 14, 34, 0.6); border-radius: 8px; padding: 2px 8px; font-weight: 700; font-size: 13px; }
.tw-hud .voicebadge div::before { content: '🔊 '; }
.tw-hud .net { position: absolute; right: 0; top: 160px; background: rgba(0, 0, 0, 0.55); padding: 6px 10px; border-radius: 8px; font: 12px/1.4 ui-monospace, monospace; white-space: pre; }
.tw-hud .station { position: absolute; left: 50%; top: 8%; transform: translateX(-50%); background: var(--paper); color: var(--ink); border: 4px solid var(--ink); border-radius: 14px; padding: 8px 16px; box-shadow: 0 4px 0 var(--ink); text-align: center; max-width: 620px; }
.tw-hud .station h4 { margin: 0 0 4px; font: 400 20px 'Titan One', sans-serif; }

/* wheels (emoticons, quick messages) */
.tw-wheel { position: absolute; left: 50%; top: 50%; width: 360px; height: 360px; transform: translate(-50%, -50%); pointer-events: none; }
.tw-wheel .slot { position: absolute; width: 74px; height: 74px; margin: -37px; border-radius: 50%; border: 3px solid var(--ink); background: rgba(255, 248, 236, 0.92); display: flex; align-items: center; justify-content: center; text-align: center; font: 700 12px 'Rubik', sans-serif; color: var(--ink); }
.tw-wheel .slot.on { background: var(--gold); transform: scale(1.15); }
.tw-wheel .slot img { width: 48px; height: 48px; }

/* scoreboard */
.tw-score { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: flex; gap: 14px; pointer-events: none; }
.tw-score table { border-collapse: collapse; background: rgba(255, 248, 236, 0.96); border: 4px solid var(--ink); border-radius: 14px; overflow: hidden; color: var(--ink); min-width: 380px; box-shadow: var(--shadow); }
.tw-score th { font: 400 16px 'Titan One', sans-serif; padding: 8px 10px; background: var(--paper2); text-align: left; }
.tw-score th.red { background: #ffb0a6; } .tw-score th.blue { background: #b0d4ff; }
.tw-score td { padding: 5px 10px; font-weight: 600; border-top: 2px solid rgba(29, 26, 42, 0.08); }
.tw-score tr.me td { background: #fff3c4; }
.tw-score td.n { text-align: right; font-variant-numeric: tabular-nums; }

/* lobby & hub */
.tw-hub { padding: 4vh 3vw; gap: 2vw; }
.tw-hub .side { width: min(460px, 46vw); display: flex; flex-direction: column; gap: 14px; }
.tw-codeinput { display: flex; gap: 6px; }
.tw-codeinput span { width: 44px; height: 54px; border: 3px solid var(--ink); border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center; font: 400 28px 'Titan One', sans-serif; }
.tw-rooms { display: flex; flex-direction: column; gap: 8px; max-height: 40vh; overflow: auto; }
.tw-room { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 8px 12px; border: 3px solid var(--ink); border-radius: 12px; background: #fff; cursor: pointer; }
.tw-room:hover, .tw-room.focus { background: #fff3c4; }
.tw-lobby { padding: 3vh 2vw; gap: 1.6vw; align-items: stretch; }
.tw-lobby .lcol { width: min(360px, 28vw); display: flex; flex-direction: column; gap: 12px; }
.tw-lobby .mid { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; pointer-events: none; }
.tw-lobby .code { font: 400 34px 'Titan One', sans-serif; letter-spacing: 4px; }
.tw-plates { position: absolute; inset: 0; pointer-events: none; }
.tw-plate { position: absolute; transform: translate(-50%, -100%); background: rgba(255, 248, 236, 0.95); border: 3px solid var(--ink); border-radius: 10px; padding: 3px 9px; font-weight: 800; font-size: 14px; color: var(--ink); white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tw-plate.ready { background: #b8f09a; }
.tw-plate .ping { font-weight: 600; font-size: 11px; color: var(--mute); }
.tw-plate[data-mic='talk'] { box-shadow: 0 0 0 3px var(--ok); }
.tw-chatpanel { display: flex; flex-direction: column; gap: 6px; }
.tw-chatlog { height: 200px; overflow: auto; background: #fff; border: 3px solid var(--ink); border-radius: 10px; padding: 6px 8px; font-size: 14px; }
.tw-chatlog .sys { color: #8a6a1a; font-style: italic; }
.tw-quick { display: flex; flex-wrap: wrap; gap: 4px; }
.tw-voicechip { cursor: pointer; }
.tw-countdown { font: 400 120px 'Titan One', sans-serif; color: #fff; text-shadow: 0 8px 0 var(--ink), 5px 0 0 var(--ink), -5px 0 0 var(--ink); animation: tw-ann 1s ease both; }

/* results */
.tw-results { padding: 3vh 3vw; flex-direction: column; align-items: center; gap: 1.6vh; }
.tw-results .head { font: 400 54px 'Titan One', sans-serif; color: #fff; text-shadow: 0 5px 0 var(--ink), 3px 0 0 var(--ink), -3px 0 0 var(--ink); }
.tw-results .tw-card { width: min(980px, 94vw); }
.tw-results .podium-space { flex: 1 1 auto; min-height: 120px; max-height: 40vh; display: flex; align-items: flex-end; }
.tw-results .podium-space .tw-podium { height: auto; width: 100%; }
.tw-results .head { font-size: clamp(30px, 6.4vh, 58px); line-height: 1.1; text-align: center; }
.tw-awards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.tw-award { border: 3px solid var(--ink); border-radius: 12px; padding: 8px 10px; background: #fff; animation: tw-award 500ms cubic-bezier(.3, 1.5, .5, 1) both; }
.tw-award b { font-family: 'Titan One', sans-serif; font-weight: 400; display: block; }
@keyframes tw-award { from { transform: scale(0.4) rotate(-6deg); opacity: 0; } to { transform: none; opacity: 1; } }

/* wardrobe */
.tw-ward { padding: 3vh 3vw; gap: 2vw; align-items: stretch; }
.tw-ward .tw-card { width: min(560px, 48vw); display: flex; flex-direction: column; }
.tw-parts { display: grid; grid-template-columns: repeat(auto-fill, minmax(82px, 1fr)); gap: 8px; overflow: auto; max-height: 46vh; }
.tw-part { border: 3px solid var(--ink); border-radius: 12px; background: #fff; height: 82px; display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.tw-part.on { background: var(--gold); }
.tw-part.locked { opacity: 0.45; }
.tw-part.locked::after { content: '🔒'; position: absolute; right: 4px; bottom: 2px; font-size: 14px; }
.tw-part canvas { width: 70px; height: 70px; }
.tw-swatch { width: 30px; height: 30px; border: 3px solid var(--ink); border-radius: 8px; cursor: pointer; }

/* credits */
.tw-credits p { margin: 6px 0; line-height: 1.45; }
.tw-credits h3 { margin-top: 14px; }

/* crosshair cursor hidden in match */
body.in-match #app canvas { cursor: none; }

/* Touch controls stay at the screen edges and never cover the aim point. */
.tw-touch { position:fixed; inset:0; z-index:45; pointer-events:none; }
.tw-touch[hidden] { display:none; }
.tw-touch button { position:absolute; width:58px; height:58px; border-radius:50%; border:2px solid #ffffff99; background:#14293899; color:white; font-size:26px; pointer-events:auto; touch-action:none; user-select:none; }
.tw-touch .move,.tw-touch .aim { width:110px; height:110px; bottom:max(18px,env(safe-area-inset-bottom)); }
.tw-touch .move { left:max(18px,env(safe-area-inset-left)); }
.tw-touch .aim { right:max(18px,env(safe-area-inset-right)); }
.tw-touch .jump { right:145px; bottom:26px; }
.tw-touch .hook { right:145px; bottom:98px; }
.tw-touch .next { left:145px; bottom:26px; }
.tw-touch .pause { right:18px; top:90px; }
