:root {
  --ink: #23204f;
  --muted: #6c6993;
  --soft: #efeefb;
  --soft-d: #d3d0ee;
  --line: #d6d3ec;
  --purple: #6a4cff;
  --purple-d: #4b2fd6;
  --blue: #2f6bff;
  --red: #e5383b;
  --red-soft: #ffe1e1;
  --green: #2fbf71;
  --yellow: #ffc83d;
  --focus: #ffc83d;
  --sel: #ffe682;
  --peer: #ebf1ff;
  --same: #c9dbff;
  --shade: #e1dfeb;
  --hint: #ff9f1c;
  --font: 'Trebuchet MS', 'Arial Rounded MT Bold', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
body {
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 255, 255, .32) 0 70px, transparent 71px),
    radial-gradient(circle at 88% 18%, rgba(255, 255, 255, .2) 0 110px, transparent 111px),
    radial-gradient(circle at 80% 92%, rgba(255, 255, 255, .16) 0 90px, transparent 91px),
    linear-gradient(160deg, #86b6ff 0%, #9d8bff 55%, #c09cff 100%);
}

.i { width: 1em; height: 1em; fill: currentColor; display: inline-block; vertical-align: middle; flex: none; }

/* ---------- Spielfeld-Aufbau ---------- */

#game {
  position: fixed;
  inset: 0;
  display: none;
  margin: 0 auto;
  max-width: 640px;
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  gap: 10px;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  grid-template-areas: "bar" "board" "tip" "tools" "pad";
}
body.playing #game { display: grid; }
#game .side { display: contents; }
.bar { grid-area: bar; }
.board-wrap { grid-area: board; }
.tip { grid-area: tip; }
.tools { grid-area: tools; }
.pad { grid-area: pad; }

@media (min-aspect-ratio: 5/4) {
  #game {
    max-width: 1400px;
    column-gap: clamp(14px, 3vw, 40px);
    grid-template-columns: minmax(0, 1fr) clamp(290px, 40vw, 440px);
    grid-template-rows: minmax(0, 1fr) auto auto minmax(0, 1fr);
    grid-template-areas: "board ." "board bar" "board side" "board .";
    row-gap: clamp(8px, 2vh, 18px);
  }
  #game .side {
    grid-area: side;
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 2vh, 18px);
    min-height: 0;
  }
}

/* ---------- Kopfzeile ---------- */

.bar { display: flex; align-items: center; gap: 8px; container-type: inline-size; }
.chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 42px;
  padding: 0 13px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .94);
  font-weight: 900;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 0 rgba(35, 32, 79, .16);
}
.chip .i { font-size: 21px; color: var(--purple); }
.chip.mode { flex: 1 1 0; justify-content: center; gap: 7px; min-width: 0; white-space: nowrap; overflow: hidden; }
.chip.mode .stars-mini { height: 13px; }
.chip.mode .stars-mini i { width: 13px; height: 13px; }
.chip.mode .mode-name { font-size: 14px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
@container (max-width: 470px) { .chip.mode .mode-name { display: none; } }
.chip.hearts { gap: 2px; }
.chip.hearts .i.full { color: #ff4d6d; }
.chip.hearts .i.lost { color: #d9d6e6; }
.chip.errs .i { color: var(--muted); }
.chip.errs.some { color: var(--red); }
.chip.errs.some .i { color: var(--red); }
.chip .float {
  position: absolute;
  right: -6px;
  top: calc(100% - 4px);
  z-index: 5;
  padding: 1px 7px;
  border-radius: 999px;
  background: #fff;
  color: #c42a30;
  font-size: 14px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .2);
  animation: floatUp 1.3s ease-out forwards;
  pointer-events: none;
}

/* ---------- Brett ---------- */

.board-wrap { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; }
.board {
  --cell: 40px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), 1fr);
  grid-template-rows: repeat(var(--n), 1fr);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 8px 0 rgba(35, 32, 79, .28), 0 20px 44px rgba(20, 10, 80, .28);
  touch-action: manipulation;
}
#game.won .board { animation: boardWin 1.2s ease-out; }

.cell {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  transition: background-color .12s;
}
.cell.bR { border-right: 3px solid var(--ink); }
.cell.bB { border-bottom: 3px solid var(--ink); }
.cell.eR { border-right: 0; }
.cell.eB { border-bottom: 0; }

.cell .v {
  position: relative;
  z-index: 2;
  font-size: calc(var(--cell) * .62);
  font-weight: 800;
  line-height: 1;
}
.board[data-size="4"] .cell .v { font-size: calc(var(--cell) * .5); }
.cell.given .v { color: var(--ink); font-weight: 900; }
.cell.user .v { color: var(--blue); }
.cell.hinted .v { color: #8a3ff0; }

.cell .n {
  position: absolute;
  inset: 2px;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(var(--bc), 1fr);
  grid-auto-rows: 1fr;
  pointer-events: none;
}
.cell .n span {
  display: grid;
  place-items: center;
  font-size: calc(var(--cell) * .26);
  font-weight: 800;
  line-height: 1;
  color: #7d79a6;
}
.board[data-size="4"] .cell .n span { font-size: calc(var(--cell) * .19); }
.cell .n span.hl { place-self: center; width: 1.45em; height: 1.45em; border-radius: 50%; background: var(--blue); color: #fff; }

.cell .fx { position: absolute; inset: 0; z-index: 1; pointer-events: none; }

/* Hervorhebungen – spätere Regeln gewinnen */
.cell.peer { background: var(--peer); }
.cell.shadow { background: var(--shade); }
.cell.shadow.empty { background: repeating-linear-gradient(135deg, #e4e2ee 0 5px, #d9d6e6 5px 10px); }
.cell.shadow .v { opacity: .5; }
.cell.same { background: var(--same); }
.cell.same .v { color: #1747c8; }
.cell.same.given .v { color: #10236e; }
.cell.conflict { background: #ffd9d9; }
.cell.conflict.given .v { color: #b3141a; }
.cell.wrong { background: var(--red-soft); }
.cell.wrong .v { color: var(--red); }
.cell.sel { background: var(--sel); }
.cell.sel::before {
  content: '';
  position: absolute;
  inset: 1px;
  z-index: 3;
  border: 3px solid var(--purple);
  border-radius: 6px;
  pointer-events: none;
}
.cell.sel.wrong { background: #ffd0b8; }

/* Tipp-Markierungen */
.cell.h-x::after {
  content: '✕';
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  font-size: calc(var(--cell) * .48);
  font-weight: 900;
  color: rgba(229, 56, 59, .55);
  pointer-events: none;
}
.cell.h-ring .v { border-radius: 50%; box-shadow: 0 0 0 3px var(--hint); padding: .06em .26em; animation: ring 1s ease-in-out infinite alternate; }
.cell.h-target::after, .cell.h-bad::after {
  content: '';
  position: absolute;
  inset: 2px;
  z-index: 3;
  border: 4px solid var(--hint);
  border-radius: 8px;
  animation: pulse .9s ease-in-out infinite alternate;
  pointer-events: none;
}
.cell.h-bad::after { border-color: var(--red); }
.cell.h-done .fx { background: rgba(255, 200, 61, .45); animation: glowFade 2.5s ease-out forwards; }

.marks { position: absolute; inset: 0; z-index: 4; pointer-events: none; }
.frame {
  position: absolute;
  border: 4px solid var(--hint);
  border-radius: 10px;
  box-shadow: 0 0 0 3px rgba(255, 159, 28, .25), inset 0 0 0 2px rgba(255, 255, 255, .7);
  animation: framePulse 1.1s ease-in-out infinite alternate;
}
.frame.hint-soft { border-width: 3px; border-color: rgba(255, 159, 28, .5); box-shadow: none; animation: none; }
.frame.done-frame { border-color: var(--green); box-shadow: 0 0 18px rgba(47, 191, 113, .8); animation: doneFrame 1.15s ease-out forwards; }

/* Animationen an den Feldern */
.fx.wave { animation: wave .75s ease-out var(--d, 0ms) both; }
.fx.glow { animation: glow 1s ease-out; }
.fx.flash { animation: flash .45s ease-out; }
.fx.bad { animation: bad .45s ease-out; }
.v.pop { animation: pop .35s cubic-bezier(.2, 1.6, .4, 1); }
.v.shake { animation: shake .4s ease; }

/* ---------- Zahlen-Auswahl am Feld ---------- */

.picker {
  --key: 56px;
  position: absolute;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--key));
  gap: 6px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 0 0 4px var(--purple), 0 14px 34px rgba(20, 10, 80, .4);
  animation: pop .18s ease-out;
}
.pk {
  width: var(--key);
  height: var(--key);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: var(--soft);
  font: inherit;
  font-size: calc(var(--key) * .52);
  font-weight: 900;
  color: var(--ink);
  cursor: pointer;
  transition: transform .08s;
}
.pk.no, .pk.done { opacity: .32; }
.pk.cur { opacity: 1; background: var(--purple); color: #fff; transform: scale(1.08); box-shadow: 0 0 0 3px var(--focus); }
.pk.cur.no { background: #a99bd8; }
.picker.notes .pk { font-size: calc(var(--key) * .36); color: var(--muted); }
.picker.notes .pk.cur { color: #fff; }

/* ---------- Eule ---------- */

.tip { display: flex; align-items: center; gap: 8px; min-height: 64px; }
.owl { width: 58px; height: 58px; flex: none; }
.owl-svg { width: 100%; height: 100%; display: block; overflow: visible; }
.owl .owl-svg { animation: bob 3.2s ease-in-out infinite; }
.owl-svg .happy-eyes, .owl-svg .brows { display: none; }
.happy .owl-svg .pupils { display: none; }
.happy .owl-svg .happy-eyes { display: inline; }
.think .owl-svg .brows, .sad .owl-svg .brows { display: inline; }
.sad .owl-svg .brows { transform: rotate(180deg); transform-box: fill-box; transform-origin: center; }
.owl-svg .pupils { transform-box: fill-box; transform-origin: center; animation: blink 4.5s infinite; }
.owl.happy .owl-svg { animation: hop .5s ease-in-out 2; }

.bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 52px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0 4px;
  padding: 8px 14px;
  border-radius: 16px;
  background: #fff;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  box-shadow: 0 4px 0 rgba(35, 32, 79, .16);
}
.bubble::before {
  content: '';
  position: absolute;
  left: -9px;
  top: 50%;
  margin-top: -9px;
  border: 9px solid transparent;
  border-left: 0;
  border-right-color: #fff;
}
.bubble > span { display: block; }
.bubble.pop { animation: bubble .3s cubic-bezier(.2, 1.4, .4, 1); }
.bubble .d, .lead .d {
  display: inline-grid;
  place-items: center;
  min-width: 1.45em;
  height: 1.45em;
  padding: 0 .25em;
  border-radius: 7px;
  background: var(--purple);
  color: #fff;
  line-height: 1;
}

/* ---------- Werkzeuge ---------- */

.tools { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.tool {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 8px 2px 7px;
  border: 0;
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 5px 0 #cbc3ef;
  cursor: pointer;
  transition: transform .08s;
}
.tool > span:not(.kb):not(.gp) { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool .i { font-size: 27px; }
.tool:active { transform: translateY(3px); box-shadow: 0 2px 0 #cbc3ef; }
.tool:disabled { opacity: .45; cursor: default; transform: none; }
.tool.on { background: var(--purple); color: #fff; box-shadow: 0 5px 0 var(--purple-d); }
.tool.pop { animation: pop .3s ease-out; }
.tool .pill { position: absolute; top: 4px; right: 4px; padding: 1px 5px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 9px; }
.tool.on .pill { background: var(--yellow); color: #3a2a00; }
.tool.tip-tool { background: #fff3cf; box-shadow: 0 5px 0 #efd37f; }
.tool.tip-tool .i { color: #eea100; }
.tool:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; }

.tool .kb, .tool .gp {
  display: none;
  position: absolute;
  top: -7px;
  left: -3px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #2b2b3d;
  color: #fff;
  font-size: 10px;
  line-height: 20px;
  font-weight: 900;
  text-align: center;
}
body.dev-keys .tool .kb, body.dev-pad .tool .gp { display: block; }
.tool .gp.g-b { background: #e5383b; }
.tool .gp.g-x { background: #2f7dff; }
.tool .gp.g-y { background: #eea100; }

.tool.round { flex: none; flex-direction: row; width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.tool.round .i { font-size: 24px; }

/* ---------- Zahlenfeld ---------- */

.pad { --cols: 9; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 6px; }
.pad[data-size="4"] { --cols: 4; }
.key {
  position: relative;
  display: grid;
  place-items: center;
  height: clamp(46px, 7.5vh, 66px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  box-shadow: 0 5px 0 #cbc3ef;
  cursor: pointer;
  transition: transform .08s, opacity .15s;
}
.key b { font-size: clamp(24px, 4.2vh, 34px); font-weight: 900; line-height: 1; }
.pad[data-size="4"] .key b { font-size: clamp(28px, 5vh, 40px); }
.key small { position: absolute; top: 3px; right: 6px; font-size: 11px; font-weight: 800; color: var(--muted); }
.key .done-i { display: none; position: absolute; top: 3px; right: 4px; font-size: 14px; color: var(--green); }
.key:active { transform: translateY(3px); box-shadow: 0 2px 0 #cbc3ef; }
.key.on { background: var(--same); box-shadow: 0 5px 0 #9fb8f0; }
.key.no { opacity: .36; }
.key.done { background: #dff7ea; box-shadow: 0 5px 0 #a6e3c2; }
.key.done b { color: #1d8a50; }
.key.done .done-i { display: block; }
.key.cheer { animation: cheer .85s ease-out; }
.pad.notes .key { background: #f4f0ff; }
.pad.notes .key b { font-size: clamp(17px, 2.8vh, 24px); color: #6c58c9; }
.pad.notes .key::before { content: '✎'; position: absolute; left: 6px; top: 3px; font-size: 12px; color: #9b8be0; }

@media (min-aspect-ratio: 5/4) {
  .pad { --cols: 3; }
  .pad[data-size="4"] { --cols: 2; }
  .key { height: clamp(44px, 9.5vh, 80px); }
  .key b { font-size: clamp(24px, 5vh, 40px); }
  .pad[data-size="4"] .key { height: clamp(56px, 13vh, 110px); }
  .pad[data-size="4"] .key b { font-size: clamp(30px, 7vh, 54px); }
}

/* ---------- Menüs ---------- */

#ui { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
.screen {
  position: absolute;
  inset: 0;
  display: none;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  overflow: auto;
  pointer-events: auto;
}
.screen.active { display: flex; animation: fade .25s ease-out; }
.screen.dim { background: rgba(26, 22, 70, .5); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

.panel {
  width: min(480px, 100%);
  margin: auto;
  padding: 22px 24px 18px;
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 0 0 6px rgba(255, 255, 255, .35), 0 24px 60px rgba(10, 8, 40, .35);
  text-align: center;
  animation: pop .3s cubic-bezier(.2, 1.4, .4, 1);
}
.panel.wide { width: min(780px, 100%); }
.panel.start { width: min(580px, 100%); }
.panel > .btn { margin-top: 12px; }

.title { margin: 4px 0 12px; font-size: clamp(24px, 5vw, 32px); line-height: 1.15; }
.title.small { font-size: 24px; }
.lead { margin: 8px 0 12px; font-size: 17px; font-weight: 700; line-height: 1.45; color: var(--ink); }
.lead.small { font-size: 15px; color: var(--muted); }
.sub { margin: 18px 0 8px; font-size: 18px; text-align: left; }
.sub-note { margin: -4px 0 12px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-weight: 700; }
.label { margin: 14px 0 6px; text-align: left; font-size: 13px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.head { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 12px; }
.head .title { margin: 0; }
.head-i { font-size: 34px; color: var(--purple); }
.head-icon { font-size: 52px; line-height: 1; color: var(--purple); }
.head-icon.warn { color: #f08c00; }

/* Knöpfe */
.focusable { outline: 4px solid transparent; outline-offset: 3px; }
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 12px 16px;
  border: 0;
  border-radius: 18px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.15;
  box-shadow: 0 5px 0 var(--soft-d);
  cursor: pointer;
  transition: transform .12s ease, outline-color .12s ease;
}
.btn .i { font-size: 1.3em; }
.btn.primary { background: var(--green); color: #fff; box-shadow: 0 5px 0 #1d8a50; font-size: 22px; }
.btn.big { padding: 16px; font-size: 26px; }
.btn.danger { background: #ffe3e3; color: #c42a30; box-shadow: 0 5px 0 #f2b8b8; }
.btn.small { width: auto; flex: none; flex-direction: column; gap: 2px; padding: 8px 12px; font-size: 13px; }
.btn.small .i { font-size: 24px; }
.btn:active, .btn.pressed { transform: translateY(3px); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.btn-row.three { grid-template-columns: 1fr 1fr 1fr; }
.btn-row:has(> [hidden]) { grid-template-columns: 1fr; }
.btn.icon-line { margin-top: 12px; font-size: 16px; padding: 9px; }

body.dev-keys .focusable.focused, body.dev-pad .focusable.focused, .focusable:focus-visible { outline-color: var(--focus); }
body.dev-keys .btn.focused, body.dev-pad .btn.focused { transform: translateY(-2px) scale(1.03); }
body.dev-mouse .btn:hover, body.dev-mouse .seg-btn:hover, body.dev-mouse .opt:hover { filter: brightness(1.03); transform: translateY(-1px); }

/* Start */
.hello { display: flex; align-items: center; gap: 14px; text-align: left; }
.hello-text { flex: 1; min-width: 0; }
.hello h1 { margin: 0; font-size: clamp(21px, 4.6vw, 28px); line-height: 1.15; overflow-wrap: anywhere; }
.hello p { margin: 3px 0 0; font-size: 15px; font-weight: 700; color: var(--muted); }
.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--av, #eee);
  font-size: 26px;
  line-height: 1;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .08);
}
.avatar.big { width: 66px; height: 66px; font-size: 40px; }
.avatar.small { width: 30px; height: 30px; font-size: 18px; }
.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0 0; }
.q { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 4px; border-radius: 14px; background: var(--soft); }
.q .i { font-size: 20px; color: var(--purple); }
.q b { font-size: 20px; }
.q span { font-size: 12px; font-weight: 700; color: var(--muted); }
.btn.resume { flex-wrap: wrap; margin-top: 14px; background: #fff3cf; box-shadow: 0 5px 0 #efd37f; font-size: 21px; }
.btn.resume small { flex-basis: 100%; font-size: 14px; color: var(--muted); }
.mode-best { min-height: 1.4em; margin: 12px 0 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.mode-best .i { color: var(--purple); }
.mode-best b { color: var(--ink); }
.icon-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.btn.icon { flex-direction: column; gap: 4px; padding: 10px 4px; font-size: 13px; }
.btn.icon .i { font-size: 28px; color: var(--purple); }

.seg { display: grid; gap: 8px; }
.seg.two { grid-template-columns: 1fr 1fr; }
.seg.four { grid-template-columns: repeat(4, 1fr); }
.seg-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  padding: 10px 6px;
  border: 3px solid transparent;
  border-radius: 16px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  box-shadow: 0 4px 0 var(--soft-d);
  cursor: pointer;
  transition: transform .12s ease, outline-color .12s ease;
}
.seg-btn b { font-size: 16px; }
.seg-btn small { font-size: 12px; font-weight: 700; color: var(--muted); }
.seg-btn.on { border-color: var(--purple); background: #ece6ff; box-shadow: 0 4px 0 #b9a8ff; }
.seg.tabs { margin: 8px 0; }
.seg.tabs .seg-btn { padding: 8px 4px; font-size: 15px; font-weight: 800; }
.mini { width: 42px; height: 42px; stroke: var(--ink); fill: none; }
.stars-mini { display: flex; gap: 2px; height: 14px; }
.stars-mini i {
  width: 14px;
  height: 14px;
  background: var(--yellow);
  clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}

.legal { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.legal a { color: inherit; }
.legal a:focus-visible { outline: 3px solid var(--focus); border-radius: 4px; }

/* Name */
.owl-head { width: 86px; height: 86px; margin: -4px auto 2px; }
.owl-head .owl-svg { animation: bob 3.2s ease-in-out infinite; }
.name-input {
  width: 100%;
  padding: 12px;
  border: 3px solid var(--line);
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 28px;
  font-weight: 800;
  text-align: center;
  -webkit-user-select: text;
  user-select: text;
}
.name-input:focus, .name-input.focused { border-color: var(--purple); outline: none; }
.msg { min-height: 1.3em; margin: 8px 0 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.msg.bad { color: #c42a30; }
.animals { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.animal {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  padding: 0;
  border: 3px solid transparent;
  border-radius: 50%;
  background: var(--av);
  font-size: clamp(22px, 5vw, 30px);
  cursor: pointer;
  transition: transform .12s;
}
.animal.on { border-color: var(--purple); transform: scale(1.1); box-shadow: 0 4px 10px rgba(106, 76, 255, .35); }
.osk { display: none; gap: 6px; margin-top: 14px; }
body.dev-pad .osk { display: grid; }
.osk-row { display: flex; justify-content: center; gap: 5px; }
.k {
  flex: 1;
  max-width: 44px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  box-shadow: 0 3px 0 var(--soft-d);
  cursor: pointer;
}
.k.wide { flex: 2; max-width: none; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 15px; }

/* Spieler */
.player-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border: 3px solid transparent;
  border-radius: 18px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  box-shadow: 0 4px 0 var(--soft-d);
  cursor: pointer;
}
.player-card.on { border-color: var(--purple); }
.player-card .avatar { width: 58px; height: 58px; font-size: 34px; }
.player-card b { font-size: 18px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.player-card small { font-weight: 700; color: var(--muted); }

/* Statistik */
.tiles { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-bottom: 8px; }
.tile { padding: 10px 4px; border-radius: 14px; background: var(--soft); }
.tile b { display: block; font-size: 24px; }
.tile span { font-size: 12px; font-weight: 800; color: var(--muted); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 8px 6px; border-bottom: 2px solid var(--soft); text-align: center; }
.table thead th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.table tbody th { text-align: left; white-space: nowrap; }
.table td.none { font-weight: 600; font-style: italic; color: var(--muted); }
.history { margin: 0 0 6px; padding: 0; list-style: none; text-align: left; }
.history li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 12px; font-size: 15px; font-weight: 700; }
.history li:nth-child(odd) { background: var(--soft); }
.history .when { width: 4.5em; color: var(--muted); font-size: 13px; }
.history .what { flex: 1; min-width: 0; }
.history .res { font-variant-numeric: tabular-nums; }
.history .lost .res, .history li.lost .res { color: var(--muted); font-weight: 600; }
.history li.empty { justify-content: center; color: var(--muted); background: none; }
.st { color: #f5b000; letter-spacing: -1px; font-style: normal; }
.st i { color: #d9d6ea; font-style: normal; }

/* Bestenliste */
.scores { margin: 12px 0 0; padding: 0; list-style: none; text-align: left; }
.scores li { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; padding: 8px 12px; border-radius: 14px; background: var(--soft); font-weight: 800; }
.scores li.me { background: #ece6ff; box-shadow: inset 0 0 0 3px var(--purple); }
.scores .rank { width: 1.8em; font-size: 20px; text-align: center; }
.scores .who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 17px; }
.scores .time { font-size: 20px; font-variant-numeric: tabular-nums; }
.scores .when { width: 4.6em; font-size: 12px; color: var(--muted); text-align: right; }
.scores li.empty { justify-content: center; padding: 20px; text-align: center; font-weight: 700; color: var(--muted); background: none; }

/* Einstellungen */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 10px 10px 12px;
  border: 0;
  border-radius: 16px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.opt.off { opacity: .55; }
.opt-icon { display: flex; font-size: 28px; color: var(--purple); }
.opt-text { flex: 1; min-width: 0; }
.opt-text b { display: block; font-size: 15px; }
.opt-text small { display: block; font-size: 12px; font-weight: 700; line-height: 1.25; color: var(--muted); }
.opt-val { display: flex; align-items: center; }
.opt-val b { min-width: 6.4em; padding: 6px 4px; border-radius: 10px; background: #fff; font-size: 14px; text-align: center; }
.arr { display: flex; padding: 2px; font-size: 24px; color: var(--muted); }

/* Pause */
.pause-info { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin: 8px 0 4px; font-size: 18px; font-weight: 800; }
.pause-info .i { margin-right: 4px; color: var(--purple); }

/* Gewonnen */
.won .owl-head { width: 100px; height: 100px; }
.won .owl-head .owl-svg { animation: hop .6s ease-in-out infinite alternate; }
.stars { display: flex; justify-content: center; gap: 6px; margin: 2px 0; font-size: 64px; line-height: 1; }
.star { display: inline-flex; color: #dcd9ef; }
.star.on { color: var(--yellow); filter: drop-shadow(0 4px 0 #d08a00); animation: starPop .55s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: calc(.35s + var(--i) * .26s); }
.won-time { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 42px; font-weight: 900; font-variant-numeric: tabular-nums; }
.won-time .i { color: var(--purple); }
.ribbon {
  display: inline-block;
  margin: 6px 0 0;
  padding: 6px 20px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ff5fae, #ffb02e);
  color: #fff;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .12);
  animation: ribbon .8s 1.1s cubic-bezier(.2, 1.6, .4, 1) both;
}
.won-info { margin: 8px 0 4px; font-weight: 700; line-height: 1.5; color: var(--muted); }
.won-info b { color: var(--ink); }
.btn.level-up { margin-top: 10px; background: #fff3cf; box-shadow: 0 5px 0 #efd37f; }
.btn.level-up .i { color: #eea100; }

/* So geht's */
.rules { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 10px 0 6px; }
.rule { margin: 0; }
.ex { display: grid; grid-template-columns: repeat(4, 1fr); grid-auto-rows: 1fr; max-width: 150px; aspect-ratio: 1; margin: 0 auto; border: 3px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.ex span { display: grid; place-items: center; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 20px; font-weight: 900; color: var(--blue); }
.ex span.on { background: #fff0bd; }
.ex span.bR { border-right: 3px solid var(--ink); }
.ex span.bB { border-bottom: 3px solid var(--ink); }
.ex span:nth-child(4n) { border-right: 0; }
.ex span:nth-child(n+13) { border-bottom: 0; }
.rule figcaption { margin-top: 6px; font-size: 15px; font-weight: 700; }
.ctrl-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; text-align: left; }
.ctrl { padding: 10px 12px; border-radius: 16px; background: var(--soft); }
.ctrl h3 { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 15px; }
.ctrl h3 .i { font-size: 22px; color: var(--purple); }
.ctrl p { margin: 0; font-size: 13.5px; font-weight: 600; line-height: 1.7; }
.ctrl-grid.helps .ctrl { background: #fff7e0; }

/* Tasten-Hinweise */
.hints { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; margin: 14px 0 0; font-size: 14px; font-weight: 700; color: var(--muted); }
.hints:empty { display: none; }
.hints .i { font-size: 22px; }
.hints .hint-ok { color: var(--green); }
.hints .sep { width: 10px; }
.g {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 4px;
  border-radius: 999px;
  background: #2b2b3d;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  vertical-align: middle;
}
.g-a { background: #3cb043; }
.g-b { background: #e5383b; }
.g-x { background: #2f7dff; }
.g-y { background: #eea100; }
.g-lb { border-radius: 7px; }
kbd {
  display: inline-block;
  min-width: 24px;
  padding: 1px 6px;
  border: 2px solid #c9c6e8;
  border-bottom-width: 4px;
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
}

/* Meldungen */
#fx { position: fixed; inset: 0; z-index: 30; width: 100vw; height: 100vh; pointer-events: none; }
#toast {
  position: fixed;
  left: 50%;
  top: 16px;
  z-index: 40;
  max-width: calc(100vw - 32px);
  padding: 10px 22px;
  border-radius: 999px;
  background: #fff;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(10, 8, 40, .3);
  transform: translate(-50%, -160%);
  visibility: hidden;
  transition: transform .3s cubic-bezier(.2, 1.3, .4, 1), visibility 0s linear .3s;
  pointer-events: none;
}
#toast.show { transform: translate(-50%, 0); visibility: visible; transition-delay: 0s; }
.noscript { position: fixed; inset: 0; display: grid; place-items: center; margin: 0; background: #fff; font-size: 22px; font-weight: 800; }

/* ---------- Kleine Bildschirme ---------- */

@media (max-width: 640px) {
  .settings { grid-template-columns: 1fr; }
  .btn-row.three { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(3, 1fr); }
  .ctrl-grid { grid-template-columns: 1fr; }
  .panel { padding: 18px 16px 16px; }
}
@media (max-width: 480px) {
  .seg.four { grid-template-columns: 1fr 1fr; }
  .quick { grid-template-columns: repeat(2, 1fr); }
  .icon-row { grid-template-columns: repeat(2, 1fr); }
  .table { font-size: 13px; }
  .rules { gap: 8px; }
  .ex span { font-size: 15px; }
  .rule figcaption { font-size: 13px; }
  .tools { gap: 6px; }
  .tool { font-size: 10px; letter-spacing: -.3px; padding: 7px 1px 6px; }
  .tool .i { font-size: 24px; }
  .bubble { font-size: 14px; padding: 6px 12px; }
  .owl { width: 48px; height: 48px; }
  .chip { height: 38px; padding: 0 10px; font-size: 15px; }
  .tool.round { width: 40px; height: 40px; }
  .stars { font-size: 52px; }
  .won-time { font-size: 34px; }
}
@media (max-width: 420px) and (max-aspect-ratio: 5/4) {
  .pad:not([data-size="4"]) .key small { display: none; }
}
@media (max-width: 340px) {
  .tool > span:not(.kb):not(.gp) { display: none; }
}
/* Handy quer und niedrige Fenster */
@media (min-aspect-ratio: 5/4) and (max-height: 520px) {
  #game { gap: 6px; }
  .chip { height: 34px; font-size: 14px; padding: 0 9px; }
  .chip .i { font-size: 17px; }
  .tool.round { width: 34px; height: 34px; }
  .tip { min-height: 0; }
  .owl { width: 40px; height: 40px; }
  .bubble { min-height: 40px; font-size: 13px; line-height: 1.3; padding: 5px 10px; }
  .tools { gap: 6px; }
  .tool { padding: 5px 1px; font-size: 10px; letter-spacing: -.3px; box-shadow: 0 3px 0 #cbc3ef; }
  .tool .i { font-size: 21px; }
  .key { height: clamp(34px, 11vh, 52px); box-shadow: 0 3px 0 #cbc3ef; }
  .key b { font-size: clamp(18px, 6vh, 28px); }
  .pad[data-size="4"] .key { height: clamp(40px, 15vh, 70px); }
}
/* Hochkant mit wenig Höhe: Eule kleiner */
@media (max-aspect-ratio: 5/4) and (max-height: 640px) {
  .tip { min-height: 0; }
  .owl { width: 40px; height: 40px; }
  .bubble { min-height: 38px; font-size: 13px; line-height: 1.3; padding: 5px 10px; }
  .key { height: 42px; }
}

/* ---------- Animationen ---------- */

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.4); opacity: .2; } }
@keyframes bubble { from { transform: scale(.92); opacity: .4; } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }
@keyframes wave {
  0% { background: rgba(255, 200, 61, 0); transform: scale(1); }
  35% { background: rgba(255, 200, 61, .8); transform: scale(.92); }
  100% { background: rgba(255, 200, 61, 0); transform: scale(1); }
}
@keyframes glow {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(47, 191, 113, 0); }
  40% { box-shadow: inset 0 0 0 4px rgba(47, 191, 113, .9); background: rgba(47, 191, 113, .18); }
}
@keyframes flash { 0% { background: rgba(106, 76, 255, .35); } 100% { background: rgba(106, 76, 255, 0); } }
@keyframes bad { 0% { background: rgba(229, 56, 59, .4); } 100% { background: rgba(229, 56, 59, 0); } }
@keyframes glowFade { to { background: rgba(255, 200, 61, 0); } }
@keyframes pulse { from { transform: scale(1); opacity: 1; } to { transform: scale(.88); opacity: .55; } }
@keyframes ring { to { box-shadow: 0 0 0 5px rgba(255, 159, 28, .45); } }
@keyframes framePulse { to { box-shadow: 0 0 0 7px rgba(255, 159, 28, .12), inset 0 0 0 2px rgba(255, 255, 255, .7); } }
@keyframes doneFrame { 0% { opacity: 0; transform: scale(1.06); } 25% { opacity: 1; transform: scale(1); } 100% { opacity: 0; } }
@keyframes cheer {
  30% { transform: scale(1.25) rotate(-6deg); }
  60% { transform: scale(.95) rotate(4deg); }
}
@keyframes boardWin {
  30% { transform: scale(1.03) rotate(-1deg); }
  60% { transform: scale(.99) rotate(.6deg); }
}
@keyframes floatUp { from { transform: translateY(-8px); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(14px); opacity: 0; } }
@keyframes bob { 50% { transform: translateY(-3px) rotate(-2deg); } }
@keyframes hop { 50% { transform: translateY(-8px) scale(1.04); } }
@keyframes blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }
@keyframes starPop { from { transform: scale(0) rotate(-40deg); } }
@keyframes ribbon { from { transform: scale(0) rotate(-10deg); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; animation-delay: 0s !important; transition: none !important; }
}
