* { box-sizing: border-box; }

:root {
  --bg: #0b1026;
  --glass: rgba(16, 22, 52, .72);
  --glass-2: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .16);
  --text: #f6f8ff;
  --muted: #b3bde0;
  --accent: #ffd23f;
  --accent-2: #ff7a1e;
  --pink: #ff3df2;
  --cyan: #35f0ff;
  --accent-text: #201400;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--text);
  overscroll-behavior: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

#app {
  position: fixed; inset: 0; pointer-events: none;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#app > * { pointer-events: auto; }

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 8px; left: 8px;
  padding: 8px 10px 6px; font-size: 13px; min-width: 190px;
  background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
#hud-info { white-space: nowrap; color: var(--muted); padding: 0 4px 5px; }
#hud-info b { color: var(--accent); font-weight: 900; letter-spacing: .02em; }
#board { font-size: 13px; }
#board th { font-size: 10px; padding: 1px 6px; text-transform: uppercase; letter-spacing: .06em; }
#board td { padding: 3px 6px; border-top: 1px solid rgba(255, 255, 255, .09); }
#board td:nth-child(1) { width: 14px; padding-right: 0; color: var(--accent); text-align: center; }
#board th:nth-child(2), #board td:nth-child(2) { text-align: left; white-space: nowrap; max-width: 150px; overflow: hidden; text-overflow: ellipsis; }
#board td i { box-shadow: 0 0 8px currentColor; }
#board tr.turn td { background: rgba(255, 210, 63, .16); font-weight: 900; }
#board tr.turn td:nth-child(2) { color: #fff; }
#board tr.done td { color: var(--muted); }
#board tr.off td { opacity: .45; }
#cam {
  position: absolute; top: 8px; right: 8px; display: flex; gap: 5px; align-items: center; flex-wrap: wrap; justify-content: flex-end;
  padding: 6px; background: var(--glass); border: 1px solid var(--line); border-radius: 14px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
}
#cam button.on { background: linear-gradient(180deg, #ffe36a, #ff9a1e); color: var(--accent-text); }

#banner {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px);
  padding: 7px 18px; border-radius: 99px; font-size: 15px; font-weight: 800;
  pointer-events: none; white-space: nowrap; text-shadow: 0 0 14px currentColor;
}

#power {
  position: absolute; left: 50%; bottom: 92px; transform: translateX(-50%);
  width: min(300px, 60vw); height: 16px; border-radius: 99px; padding: 3px;
  background: rgba(0, 0, 0, .55); border: 1px solid var(--line); pointer-events: none;
}
#power i { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, #3ee66b, #ffe14d, #ff3b3b); background-size: 300px 100%; box-shadow: 0 0 12px rgba(255, 220, 90, .8); }

/* ---------- Power-Ups ---------- */
#inv {
  position: absolute; left: 8px; right: 8px; bottom: 8px;
  display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap;
  min-height: 56px; pointer-events: none;
}
#inv > * { pointer-events: auto; }
#inv .hint { color: #fff; font-size: 13px; background: var(--glass); padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); }
#inv .state { font-size: 13px; font-weight: 700; padding: 6px 12px; border-radius: 99px; background: rgba(40, 190, 120, .85); box-shadow: 0 0 16px rgba(60, 230, 150, .6); animation: pulse 1.2s infinite; }
#inv .state.bad { background: rgba(210, 40, 80, .88); box-shadow: 0 0 16px rgba(255, 60, 100, .6); }
.pu {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; gap: 1px;
  min-width: 76px; padding: 6px 10px 5px; font-size: 11px; font-weight: 800; border-radius: 14px;
  background: linear-gradient(180deg, rgba(60, 70, 140, .92), rgba(24, 28, 70, .92));
  border: 1px solid rgba(255, 255, 255, .28); box-shadow: 0 6px 18px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .25);
  animation: drop .35s cubic-bezier(.2, 1.6, .4, 1);
}
.pu span { font-size: 24px; line-height: 1.1; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .5)); }
.pu.attack { background: linear-gradient(180deg, rgba(190, 40, 90, .95), rgba(80, 14, 50, .95)); }
.pu kbd { position: absolute; top: 2px; left: 6px; font: 700 10px system-ui; opacity: .6; }
.pu:hover { transform: translateY(-4px) scale(1.05); }
@keyframes drop { from { transform: translateY(30px) scale(.6); opacity: 0; } }
@keyframes pulse { 50% { transform: scale(1.05); } }

/* ---------- Buttons und Felder ---------- */
button {
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--glass-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 14px; font-weight: 700; transition: transform .12s, background .15s, box-shadow .15s;
}
button:hover { background: rgba(255, 255, 255, .16); transform: translateY(-1px); }
button:active { transform: translateY(1px) scale(.98); }
button:disabled { opacity: .5; cursor: default; }
button.primary {
  background: linear-gradient(180deg, #ffe36a, #ffb21f 60%, #ff8a1e); border-color: #ffe9a0; color: var(--accent-text);
  box-shadow: 0 6px 22px rgba(255, 160, 30, .5), inset 0 1px 0 rgba(255, 255, 255, .7); text-shadow: 0 1px 0 rgba(255, 255, 255, .4);
}
button.primary:hover { background: linear-gradient(180deg, #fff09a, #ffc23f 60%, #ff9a2e); box-shadow: 0 8px 30px rgba(255, 170, 40, .75), inset 0 1px 0 rgba(255, 255, 255, .7); }
button.big { padding: 15px 16px; font-size: 18px; font-weight: 900; letter-spacing: .02em; }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.small { padding: 5px 11px; font-size: 13px; border-radius: 10px; }
button.icon { padding: 5px 9px; }

input:not([type=range]):not([type=checkbox]) {
  font: inherit; color: var(--text); width: 100%;
  background: rgba(0, 0, 0, .35); border: 1px solid var(--line); border-radius: 14px;
  padding: 11px 12px; -webkit-user-select: text; user-select: text;
}
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }

/* ---------- Bildschirme ---------- */
.screen {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(8, 10, 30, .25), rgba(8, 10, 30, .7));
  padding: 16px; overflow: auto;
}
.screen.side { background: none; align-items: flex-end; justify-content: flex-end; pointer-events: none; }
.screen.side .card { pointer-events: auto; }
.card {
  width: min(420px, 100%); margin: auto;
  background: var(--glass); border: 1px solid var(--line); border-radius: 26px;
  backdrop-filter: blur(18px) saturate(1.4); -webkit-backdrop-filter: blur(18px) saturate(1.4);
  padding: 24px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .18);
  animation: rise .35s cubic-bezier(.2, 1.3, .4, 1);
}
.card.wide { width: min(560px, 100%); margin: 0; max-height: min(64vh, 560px); }
@keyframes rise { from { transform: translateY(24px) scale(.96); opacity: 0; } }

h1, h2 { margin: 0; text-align: center; }
h2 { font-size: 24px; font-weight: 900; }
.logo {
  font-size: clamp(34px, 9vw, 46px); font-weight: 900; line-height: .95; letter-spacing: .02em;
  background: linear-gradient(180deg, #fff, #cfe6ff); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .35)) drop-shadow(0 0 24px rgba(90, 200, 255, .55));
}
.logo span { display: block; font-size: .9em; -webkit-text-fill-color: initial; animation: bob 2.4s ease-in-out infinite; }
.logo b {
  display: block; font-size: 1.25em;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--pink), var(--cyan), var(--accent)); background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: slide 6s linear infinite;
}
@keyframes bob { 50% { transform: translateY(-6px) rotate(-6deg); } }
@keyframes slide { to { background-position: 300% 0; } }

.sub { margin: 0; text-align: center; color: var(--muted); font-size: 14px; }
.foot { margin: 2px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.error { margin: 0; text-align: center; color: #ff9a9a; font-size: 14px; min-height: 1em; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 700; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); }
.row { display: flex; gap: 8px; }
.row input { flex: 1; text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 800; }
.row input.plain { text-transform: none; letter-spacing: 0; text-align: left; }
.row.three button { flex: 1; padding: 10px 4px; font-size: 13px; }
.seg button { flex: 1; }
.seg button.on { background: linear-gradient(180deg, #ffe36a, #ff9a1e); border-color: #ffe9a0; color: var(--accent-text); }
details { font-size: 14px; color: var(--muted); }
summary { cursor: pointer; padding: 4px 0 8px; }

.profile-chip { display: flex; align-items: center; gap: 12px; text-align: left; padding: 10px 14px; }
.profile-chip .ava { font-size: 30px; filter: drop-shadow(0 0 10px rgba(255, 255, 255, .5)); }
.profile-chip div { flex: 1; min-width: 0; }
.profile-chip strong { display: block; font-size: 17px; }
.profile-chip small { color: var(--muted); font-weight: 600; }
.profile-chip em { font-style: normal; color: var(--muted); font-size: 13px; }

#profile-list, #local-names { display: flex; flex-direction: column; gap: 8px; }
#profile-list button { display: flex; justify-content: space-between; align-items: center; text-align: left; }
#profile-list button.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
#profile-list small { color: var(--muted); font-weight: 600; }
#lobby-code { color: var(--accent); letter-spacing: .15em; }
#lobby-players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#lobby-players li { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; background: rgba(0, 0, 0, .3); }
#lobby-players i { width: 12px; height: 12px; border-radius: 50%; }
#lobby-players small { color: var(--muted); margin-left: auto; }

table { width: 100%; border-collapse: collapse; font-size: 15px; }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-align: right; padding: 4px 6px; }
th:first-child, td:first-child { text-align: left; }
td { padding: 7px 6px; text-align: right; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
td i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 7px; }
tr.win td { font-weight: 900; color: var(--accent); text-shadow: 0 0 14px rgba(255, 210, 63, .6); }
#stats-table td:last-child { font-weight: 800; }
#scores-unlocks { display: flex; flex-direction: column; gap: 6px; }
.unlock { padding: 8px 12px; border-radius: 12px; font-weight: 800; font-size: 14px; background: linear-gradient(90deg, rgba(255, 210, 63, .28), rgba(255, 61, 242, .22)); border: 1px solid rgba(255, 210, 63, .6); animation: rise .5s both; }
.code { font-family: ui-monospace, monospace; letter-spacing: .12em; font-size: 17px; }

/* ---------- Spind ---------- */
.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; flex: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { white-space: nowrap; padding: 7px 12px; font-size: 13px; border-radius: 99px; }
.tabs button.on { background: linear-gradient(180deg, #ffe36a, #ff9a1e); color: var(--accent-text); border-color: #ffe9a0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; overflow-y: auto; min-height: 0; padding: 2px; }
.item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 6px 8px; border-radius: 16px; font-size: 13px; position: relative; overflow: hidden; }
.item span { font-size: 30px; line-height: 1.15; }
.item small { color: var(--muted); font-weight: 600; font-size: 11px; text-align: center; }
.item.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent), 0 0 22px rgba(255, 210, 63, .45); }
.item.locked { opacity: .75; }
.item.locked span { filter: grayscale(1) brightness(.6); }
.item u { position: absolute; left: 0; bottom: 0; height: 4px; background: linear-gradient(90deg, var(--cyan), var(--pink)); }

/* ---------- Power-Up-Schalter ---------- */
.card.settings { width: min(640px, 100%); max-height: 94vh; }
.pu-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pu-head small { color: var(--muted); margin-right: auto; }
#pu-toggles { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 6px; overflow-y: auto; min-height: 90px; padding: 2px; }
.tog { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-size: 12px; text-align: left; border-radius: 10px; opacity: .45; filter: grayscale(1); }
.tog span { font-size: 17px; }
.tog.on { opacity: 1; filter: none; background: rgba(60, 200, 130, .25); border-color: rgba(90, 230, 160, .7); }
.tog.on.attack { background: rgba(220, 60, 100, .25); border-color: rgba(255, 110, 140, .7); }

/* ---------- Meldungen ---------- */
#toasts {
  position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center;
  z-index: 20; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(10px);
  padding: 9px 16px; border-radius: 14px; font-size: 14px; font-weight: 700; text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: pop .3s cubic-bezier(.2, 1.6, .4, 1);
}
.toast.gold { border-color: var(--accent); box-shadow: 0 0 24px rgba(255, 210, 63, .5); }
@keyframes pop { from { transform: translateY(12px) scale(.8); opacity: 0; } }

/* ---------- Kino-Effekte ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 5; overflow: hidden; }
#fx .bar { position: absolute; left: 0; right: 0; height: 11vh; background: #000; transition: transform .35s ease; }
#fx .bar.top { top: 0; transform: translateY(-100%); }
#fx .bar.bottom { bottom: 0; transform: translateY(100%); }
#fx.lb .bar { transform: none; }
#scope {
  position: absolute; inset: 0; opacity: 0; transition: opacity .2s;
  background:
    linear-gradient(#ff2030, #ff2030) center / 2px 100% no-repeat,
    linear-gradient(#ff2030, #ff2030) center / 100% 2px no-repeat,
    radial-gradient(circle at center, transparent 0 4vmin, rgba(255, 32, 48, .9) 4vmin calc(4vmin + 2px), transparent calc(4vmin + 2px) 30vmin, rgba(0, 0, 0, .0) 30vmin, #000 31vmin);
}
#fx.scope #scope { opacity: 1; }
#flash { position: absolute; inset: 0; opacity: 0; }
#ink { position: absolute; inset: 0; opacity: 0; transition: opacity .4s; }
#ink.on { opacity: 1; }
#ink i { position: absolute; border-radius: 47% 53% 60% 40% / 45% 55% 45% 55%; background: radial-gradient(circle at 40% 35%, #2a2440, #07060d 70%); box-shadow: 0 0 40px 20px #07060d; }
#ink i:nth-child(1) { left: 8%; top: 12%; width: 34vmin; height: 30vmin; }
#ink i:nth-child(2) { right: 6%; top: 20%; width: 40vmin; height: 36vmin; }
#ink i:nth-child(3) { left: 30%; top: 38%; width: 44vmin; height: 34vmin; }
#ink i:nth-child(4) { left: 4%; bottom: 14%; width: 30vmin; height: 28vmin; }
#ink i:nth-child(5) { right: 14%; bottom: 10%; width: 36vmin; height: 30vmin; }
#ink i:nth-child(6) { left: 48%; top: 4%; width: 24vmin; height: 22vmin; }
#bigtext {
  position: absolute; left: 0; right: 0; top: 30%; text-align: center; opacity: 0;
  font-size: clamp(54px, 15vw, 170px); font-weight: 900; font-style: italic; letter-spacing: .02em; line-height: 1;
  color: #fff; -webkit-text-stroke: 3px #1a0a3a;
  text-shadow: 0 6px 0 #1a0a3a, 0 0 40px var(--pink), 0 0 90px var(--cyan);
}
#bigtext.small { font-size: clamp(34px, 8vw, 84px); top: 18%; }
#bigtext.gold { text-shadow: 0 6px 0 #5a3000, 0 0 40px var(--accent), 0 0 90px var(--accent-2); -webkit-text-stroke-color: #5a3000; color: #fff3b0; }
#bigtext.show { animation: slam 2.2s cubic-bezier(.2, 1.4, .3, 1) both; }
@keyframes slam {
  0% { transform: scale(4) rotate(-12deg); opacity: 0; }
  14% { transform: scale(1) rotate(-4deg); opacity: 1; }
  20% { transform: scale(1.12) rotate(-4deg); }
  26%, 80% { transform: scale(1) rotate(-4deg); opacity: 1; }
  100% { transform: scale(1.5) rotate(-4deg); opacity: 0; }
}

@media (max-height: 460px) {
  #hud { padding: 4px 6px; top: 4px; left: 4px; }
  #board, #hud-info { font-size: 11px; }
  #board td { padding: 1px 5px; }
  #cam { top: 4px; right: 4px; padding: 3px; }
  #banner { top: 6px; font-size: 13px; padding: 4px 12px; }
  .pu { min-width: 62px; padding: 3px 8px; font-size: 10px; }
  .pu span { font-size: 19px; }
  #power { bottom: 70px; }
  .card { padding: 14px; gap: 8px; }
  .logo { font-size: 28px; }
  .logo span { display: none; }
}
@media (max-width: 700px) {
  .screen.side { justify-content: center; }
  .card.wide { max-height: 52vh; }
}
@media (prefers-reduced-motion: reduce) {
  .toast, .card, .pu, .logo span, .logo b, #inv .state { animation: none; }
}
