/* Sticker Fangis – Cartoon-Look für Lobby und Overlays */
:root {
  --ink: #3b2a4d;
  --cream: #fff6e6;
  --paper: #ffffff;
  --pink: #ff8fab;
  --red: #ff4d6d;
  --yellow: #ffe066;
  --mint: #8ce99a;
  --green: #51cf66;
  --blue: #74c0fc;
  --lav: #b197fc;
  --muted: #7a6a8a;
  --radius: 22px;
  --shadow: 5px 5px 0 var(--ink);
  --font: "Fredoka", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background-color: var(--cream);
  background-image:
    radial-gradient(circle, rgba(255, 143, 171, 0.22) 2.5px, transparent 3px),
    radial-gradient(circle, rgba(116, 192, 252, 0.18) 2.5px, transparent 3px);
  background-size: 34px 34px, 34px 34px;
  background-position: 0 0, 17px 17px;
  overflow-x: hidden;
}
button, input, select { font-family: inherit; color: inherit; }
kbd {
  display: inline-block; padding: 0 6px; min-width: 20px; text-align: center;
  border: 2px solid var(--ink); border-bottom-width: 3px; border-radius: 7px;
  background: #fff; font-family: inherit; font-size: 0.8em; font-weight: 600; line-height: 1.4;
}
.hidden { display: none !important; }

/* ---------- Lobby ---------- */
#lobby { max-width: 1320px; margin: 0 auto; padding: 18px 16px 28px; }

.logo { position: relative; text-align: center; padding: 8px 0 18px; }
.logo-title {
  margin: 0; font-size: clamp(42px, 7vw, 84px); font-weight: 700; line-height: 1; letter-spacing: 1px;
}
.logo-title .ch {
  display: inline-block;
  color: var(--c);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 0 0 #fff, 4px 5px 0 var(--ink);
  transform: rotate(var(--r));
  animation: wob 2.6s ease-in-out infinite;
  animation-delay: var(--d);
  padding: 0 1px;
}
.logo-title .sp { display: inline-block; width: 0.35em; }
@keyframes wob {
  0%, 100% { transform: rotate(var(--r)) translateY(0); }
  50% { transform: rotate(calc(var(--r) * -1)) translateY(-5px); }
}
.logo-sub { margin: 10px 0 0; font-size: 18px; font-weight: 500; color: var(--muted); }
.icon-btn {
  width: 46px; height: 46px; border-radius: 50%; border: 3px solid var(--ink); background: #fff;
  box-shadow: 3px 3px 0 var(--ink); font-size: 20px; cursor: pointer; transition: transform .12s, box-shadow .12s;
}
.icon-btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); }
.icon-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.mute { position: absolute; right: 0; top: 10px; }

.lobby-grid {
  display: grid; gap: 24px;
  grid-template-columns: minmax(300px, 1.05fr) minmax(320px, 1.2fr) minmax(280px, 0.9fr);
  align-items: start;
}
.card {
  background: var(--paper); border: 3px solid var(--ink); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 18px 16px; position: relative;
}
.card::before { /* Klebestreifen */
  content: ""; position: absolute; top: -13px; left: 50%; width: 84px; height: 24px;
  transform: translateX(-50%) rotate(-3deg);
  background: rgba(255, 224, 102, 0.75); border: 2px dashed rgba(59, 42, 77, 0.25); border-radius: 4px;
}
.tilt-l { transform: rotate(-0.6deg); }
.tilt-r { transform: rotate(0.5deg); }
.tilt-l2 { transform: rotate(-0.35deg); }
.card h2 { margin: 0 0 12px; font-size: 26px; font-weight: 700; }
.card h3 { margin: 14px 0 8px; font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.chip {
  font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px;
  border: 2px solid var(--ink); background: #f3eefa;
}
.chip.on { background: var(--mint); }

/* Spielerliste */
.player-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.player {
  display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center;
  padding: 8px; border: 2.5px solid var(--ink); border-radius: 16px; background: #fffaf2;
  animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.avatar-wrap { position: relative; width: 52px; height: 52px; }
.avatar { width: 52px; height: 52px; cursor: pointer; display: block; transition: transform .15s; }
.avatar:hover { transform: scale(1.08) rotate(-4deg); }
.acc-btn {
  position: absolute; right: -4px; bottom: -4px; width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--ink); background: #fff; font-size: 11px; cursor: pointer; padding: 0; line-height: 1;
}
.player-fields { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.player-fields input, .player-fields select {
  width: 100%; border: 2.5px solid var(--ink); border-radius: 10px; padding: 5px 9px; font-size: 15px;
  background: #fff; outline: none; min-width: 0;
}
.player-fields input { font-weight: 600; }
.player-fields input:focus, .player-fields select:focus { box-shadow: 0 0 0 3px var(--yellow); }
.player-fields select.dup { background: #ffe3e8; border-color: var(--red); }
.rm-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff;
  cursor: pointer; font-size: 15px; font-weight: 700; transition: background .15s, transform .15s;
}
.rm-btn:hover { background: #ffd6de; transform: rotate(90deg); }

.btn {
  border: 3px solid var(--ink); border-radius: 16px; background: #fff; padding: 10px 18px;
  font-size: 17px; font-weight: 600; cursor: pointer; box-shadow: 4px 4px 0 var(--ink);
  transition: transform .12s, box-shadow .12s, background .15s;
}
.btn:hover { transform: translate(-1px, -1px); box-shadow: 5px 5px 0 var(--ink); }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: 4px 4px 0 var(--ink); }
.btn-add { width: 100%; margin-top: 12px; background: #f3eefa; border-style: dashed; }
.btn-add:hover { background: #e9e0f7; }
.btn-primary { background: var(--yellow); }
.btn kbd { margin-left: 6px; }

.hint { font-size: 13.5px; color: var(--muted); margin: 12px 0 0; line-height: 1.5; }
.hint.small { font-size: 12.5px; }

/* Level-Auswahl */
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.level {
  border: 3px solid var(--ink); border-radius: 14px; background: #fff; padding: 5px 5px 7px; cursor: pointer;
  text-align: center; transition: transform .15s, box-shadow .15s, background .15s; box-shadow: 3px 3px 0 var(--ink);
}
.level:hover { transform: translateY(-3px) rotate(-1deg); }
.level canvas { width: 100%; aspect-ratio: 16 / 9; display: block; border-radius: 9px; border: 2px solid var(--ink); }
.level b { display: block; font-size: 15px; margin-top: 5px; }
.level span { font-size: 12px; color: var(--muted); font-weight: 500; }
.level.sel { background: var(--yellow); transform: translateY(-3px) rotate(-1deg); box-shadow: 5px 5px 0 var(--ink); }
.level-desc { margin: 10px 2px 0; font-size: 14px; color: var(--muted); min-height: 40px; }

.setup-row { display: grid; grid-template-columns: 1fr 1.3fr; gap: 14px; }
.count-badge {
  display: inline-grid; place-items: center; min-width: 30px; height: 26px; padding: 0 6px; border-radius: 99px;
  background: var(--blue); border: 2px solid var(--ink); font-size: 14px; font-weight: 700;
}
input[type=range] { width: 100%; accent-color: var(--pink); height: 28px; cursor: pointer; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  border: 2.5px solid var(--ink); background: #fff; border-radius: 12px; padding: 6px 11px; font-size: 14px;
  font-weight: 600; cursor: pointer; transition: background .15s, transform .12s;
}
.seg button:hover { transform: translateY(-1px); }
.seg button.on { background: var(--pink); box-shadow: 2px 2px 0 var(--ink); }
.seg-sm button { padding: 3px 8px; font-size: 12.5px; border-radius: 10px; }

/* Rangliste */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow: auto; }
.rank-list li {
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 12px; background: #fffaf2; border: 2px solid rgba(59, 42, 77, .15);
}
.rank-list li .pos {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  border: 2px solid var(--ink); background: #fff; font-weight: 700; font-size: 13px;
}
.rank-list li:nth-child(1) .pos { background: #ffd43b; }
.rank-list li:nth-child(2) .pos { background: #dee2e6; }
.rank-list li:nth-child(3) .pos { background: #ffc078; }
.rank-list .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .meta { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.rank-list .pts { font-weight: 700; font-size: 16px; }
.rank-list li.rank-empty { display: block; color: var(--muted); font-size: 14px; padding: 10px 8px; }

/* Footer */
.lobby-footer { display: flex; gap: 24px; align-items: flex-start; justify-content: space-between; margin-top: 26px; flex-wrap: wrap; }
.howto {
  flex: 1 1 420px; background: #fff; border: 3px solid var(--ink); border-radius: 18px; padding: 10px 16px;
  box-shadow: 4px 4px 0 var(--ink);
}
.howto summary { cursor: pointer; font-weight: 700; font-size: 17px; }
.howto ul { margin: 8px 0 4px; padding-left: 20px; line-height: 1.6; font-size: 14.5px; }
.start-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; margin-left: auto; }
.summary { font-weight: 600; color: var(--muted); text-align: right; }
.summary .warn { color: var(--red); }
.btn-start {
  font-size: 34px; font-weight: 700; padding: 14px 54px; border-radius: 24px; background: var(--mint);
  box-shadow: 6px 6px 0 var(--ink); animation: breathe 2.2s ease-in-out infinite;
}
.btn-start:hover { background: #a6f0b2; }
@keyframes breathe { 0%, 100% { scale: 1; } 50% { scale: 1.04; } }

/* ---------- Spiel ---------- */
#game { position: fixed; inset: 0; display: grid; place-items: center; }
#cv {
  display: block; border-radius: 18px; border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink);
  background: #9bd56c;
}
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(59, 42, 77, 0.35); backdrop-filter: blur(2px); padding: 16px;
}
.panel {
  background: #fff; border: 4px solid var(--ink); border-radius: 26px; box-shadow: 8px 8px 0 var(--ink);
  padding: 24px 28px; text-align: center; animation: pop .3s ease-out; max-width: 100%;
}
.panel h2 { margin: 0 0 6px; font-size: 40px; }
.panel .row { display: flex; gap: 14px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.panel-results { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; }
.res-sub { margin: 0 0 14px; color: var(--muted); font-weight: 500; }
.res-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; text-align: left; }
.res-list li {
  display: grid; grid-template-columns: 34px 44px 1fr auto; gap: 10px; align-items: center;
  padding: 6px 10px; border: 2.5px solid var(--ink); border-radius: 14px; background: #fffaf2;
  animation: pop .3s ease-out both;
}
.res-list li.first { background: #fff3bf; }
.res-list .pos { font-weight: 700; font-size: 20px; text-align: center; }
.res-list canvas { width: 44px; height: 44px; }
.res-list .nm { font-weight: 700; font-size: 17px; }
.res-list .meta { display: block; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.res-list .pts { font-weight: 700; font-size: 22px; }
.res-list .new {
  display: inline-block; margin-left: 6px; font-size: 11px; padding: 1px 7px; border-radius: 99px;
  background: var(--pink); border: 2px solid var(--ink); vertical-align: middle;
}

@media (max-width: 1100px) {
  .lobby-grid { grid-template-columns: 1fr 1fr; }
  .card-ranks { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .tilt-l, .tilt-r, .tilt-l2 { transform: none; }
  .setup-row { grid-template-columns: 1fr; }
  .start-wrap { align-items: stretch; width: 100%; }
  .summary { text-align: center; }
  .mute { position: static; margin-top: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
