/* Snake: Menüs, Anzeige und Steuerknöpfe. Das Spielfeld selbst zeichnet zeichnen.js. */
:root {
  --display: 'Baloo 2', 'Trebuchet MS', sans-serif; --text: 'Nunito', system-ui, sans-serif;
  --grund: #160f33; --karte1: #2e2166; --karte2: #1d1545; --rand: #5a46b8; --ink: #f6f2ff; --ink2: #bdb3ea;
  --gruen: #3ee08a; --pink: #ff5fb7; --gelb: #ffd23f; --blau: #4fa8ff;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--grund); color: var(--ink); font-family: var(--text); overflow: hidden; position: fixed; inset: 0;
  overscroll-behavior: none; touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
canvas#feld { position: fixed; inset: 0; width: 100vw; height: 100dvh; display: block; touch-action: none; }
.versteckt { display: none !important; }

.schicht {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: radial-gradient(ellipse at center, rgba(30, 20, 70, .55), rgba(8, 5, 22, .88)); touch-action: pan-y;
}
#menue { background: radial-gradient(ellipse at 50% 20%, rgba(80, 60, 180, .35), rgba(8, 5, 22, .8)); }
.karte {
  width: min(440px, 100%); background: linear-gradient(170deg, var(--karte1), var(--karte2)); border: 2px solid var(--rand); border-radius: 26px;
  padding: 20px 18px 16px; text-align: center; box-shadow: 0 18px 50px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
  animation: auf .45s cubic-bezier(.2, .8, .2, 1);
}
.karte.breit { width: min(620px, 100%); }
@keyframes auf { from { transform: translateY(14px) scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
h1, h2 { font-family: var(--display); font-weight: 800; margin: 0 0 6px; line-height: 1.05; }
h1 { font-size: clamp(2.2rem, 10vw, 3rem); color: var(--gruen); text-shadow: 0 3px 0 #0d5a33, 0 0 22px rgba(62, 224, 138, .35); }
h1 span:not(.schlangen-logo) { color: var(--pink); text-shadow: 0 3px 0 #7a1650; }
.schlangen-logo { display: inline-block; animation: wackel 2.4s ease-in-out infinite; }
@keyframes wackel { 0%, 100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg) translateY(-2px); } }
h2 { font-size: 1.8rem; color: var(--gelb); }
.unter { margin: 0 0 12px; color: var(--ink2); line-height: 1.4; font-size: .95rem; }
.klein { margin: 6px 0 8px; font-size: .86rem; color: var(--ink2); }
.fehler { color: #ff8fa3; min-height: 0; margin: 4px 0; font-weight: 700; }
.knopf {
  border: none; border-radius: 16px; background: linear-gradient(135deg, #3ee08a, #9cf06a); color: #0b3a20; font-family: var(--display); font-weight: 800;
  font-size: 1.15rem; padding: 12px 18px; box-shadow: 0 6px 0 #158a4c, 0 10px 20px rgba(0, 0, 0, .3); cursor: pointer; transition: transform .1s, box-shadow .1s;
}
.knopf:active { transform: translateY(4px); box-shadow: 0 2px 0 #158a4c; }
.knopf:disabled { opacity: .5; }
.knopf.gross { display: block; width: 100%; font-size: 1.3rem; padding: 13px; margin-top: 12px; }
.knopf.zweit { background: linear-gradient(135deg, #ff5fb7, #ff9fd4); color: #4a0b2c; box-shadow: 0 6px 0 #a82a70, 0 10px 20px rgba(0, 0, 0, .3); }
.link { background: none; border: none; color: var(--ink2); font: inherit; text-decoration: underline; cursor: pointer; margin-top: 10px; }
.zurueck { display: inline-block; margin-top: 12px; color: var(--ink2); }

.modi { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 10px; }
.modi button { border: 2px solid var(--rand); background: rgba(0, 0, 0, .22); color: var(--ink); border-radius: 18px; padding: 10px 4px 8px; cursor: pointer; display: grid; gap: 2px; font-family: var(--display); }
.modi button b { font-size: 1.6rem; }
.modi button span { font-weight: 800; font-size: 1rem; }
.modi button small { font-family: var(--text); font-size: .72rem; color: var(--ink2); }
.modi button.aktiv { background: linear-gradient(160deg, rgba(62, 224, 138, .3), rgba(62, 224, 138, .08)); border-color: var(--gruen); box-shadow: 0 0 0 2px rgba(62, 224, 138, .25); }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0; text-align: left; }
.opt > span { font-weight: 800; font-size: .92rem; color: var(--ink2); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chips button { border: 2px solid var(--rand); background: rgba(0, 0, 0, .2); color: var(--ink); border-radius: 999px; padding: 6px 11px; font-family: var(--display); font-weight: 800; font-size: .92rem; cursor: pointer; }
.chips button.aktiv { background: var(--gelb); color: #2b2000; border-color: var(--gelb); }
.chips button:disabled { opacity: .45; }
.chips.gross { justify-content: center; margin: 4px 0 8px; }
.chips.gross button { padding: 9px 12px; }
.namen { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
.namen label { display: flex; align-items: center; gap: 6px; background: rgba(0, 0, 0, .2); border-radius: 12px; padding: 4px 8px; border: 2px solid currentColor; }
.namen input, .name-feld input { flex: 1; min-width: 0; background: none; border: none; color: var(--ink); font: 700 1rem var(--text); outline: none; padding: 4px 0; }
.punkt { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.name-feld { display: flex; align-items: center; gap: 8px; margin: 8px 0; font-weight: 800; font-size: .9rem; color: var(--ink2); background: rgba(0, 0, 0, .2); border-radius: 12px; padding: 4px 10px; }
.lobby { background: rgba(0, 0, 0, .2); border-radius: 14px; padding: 8px 10px; text-align: left; }
.lobby ul { list-style: none; margin: 4px 0; padding: 0; }
.lobby li { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-weight: 700; }
.regeln { text-align: left; margin-top: 12px; font-size: .86rem; color: var(--ink2); }
.regeln summary { cursor: pointer; font-weight: 800; color: var(--ink); }
.regeln ul { padding-left: 18px; line-height: 1.45; }
.schalter { display: flex; gap: 10px; justify-content: center; margin: 12px 0 4px; }
.rund { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--rand); background: rgba(0, 0, 0, .35); color: var(--ink); font-size: 1.2rem; display: inline-grid; place-items: center; cursor: pointer; padding: 0; }
.rund.aus { opacity: .4; }
.pause { position: fixed; z-index: 6; top: max(6px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); width: 38px; height: 38px; font-size: 1rem; opacity: .8; }

/* Level-Auswahl */
.welt { margin: 10px 0 14px; text-align: left; }
.welt h3 { font-family: var(--display); margin: 0 0 6px; font-size: 1.2rem; }
.welt h3 small { font-family: var(--text); font-weight: 400; color: var(--ink2); font-size: .8rem; margin-left: 6px; }
.level-reihe { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.level-reihe button { border: 2px solid var(--rand); background: rgba(0, 0, 0, .25); color: var(--ink); border-radius: 16px; padding: 8px 4px; cursor: pointer; font-family: var(--display); display: grid; gap: 1px; }
.level-reihe button b { font-size: 1.3rem; }
.level-reihe button span { font-size: .78rem; font-weight: 800; line-height: 1.1; }
.level-reihe button i { font-style: normal; font-size: .82rem; letter-spacing: 1px; color: var(--gelb); }
.level-reihe button:disabled { opacity: .4; }
.level-reihe button.neu { border-color: var(--gruen); box-shadow: 0 0 0 2px rgba(62, 224, 138, .3); }

/* Ende */
.pokal { font-size: 3rem; animation: wackel 1.8s ease-in-out infinite; }
.stand { color: var(--ink2); margin: 2px 0 8px; }
.level-sterne { font-size: 2.2rem; letter-spacing: 6px; min-height: 0; }
.level-sterne span { display: inline-block; animation: plopp .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.level-sterne span.grau { filter: grayscale(1) opacity(.35); }
@keyframes plopp { from { transform: scale(0); } to { transform: scale(1); } }
.rangliste { list-style: none; margin: 6px 0; padding: 0; text-align: left; }
.rangliste li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; margin: 5px 0; border-radius: 12px; background: rgba(0, 0, 0, .25); border-left: 6px solid var(--f, #fff); font-weight: 800; animation: auf .4s both; }
.rangliste li span:nth-child(2) { flex: 1; }
.rangliste li small { display: block; font-weight: 400; color: var(--ink2); font-size: .78rem; }
.sterne-ergebnis { text-align: left; margin: 8px 0; }
.sterne-zeile { background: rgba(255, 210, 63, .1); border: 1px solid rgba(255, 210, 63, .3); border-radius: 12px; padding: 6px 10px; margin: 5px 0; font-size: .9rem; }
.sterne-zeile small { display: block; color: var(--ink2); }
.sterne-plus { color: var(--gelb); font-weight: 900; }
.sterne-auf { background: var(--gruen); color: #0b3a20; border-radius: 999px; padding: 1px 8px; font-weight: 900; font-size: .78rem; }
.sterne-abz { background: rgba(255, 255, 255, .12); border-radius: 999px; padding: 1px 8px; font-size: .8rem; }
.sterne-hinweis { color: var(--ink2); font-size: .85rem; }

/* Anzeige oben */
.hud { position: fixed; z-index: 5; left: 0; right: 0; top: 0; padding: max(4px, env(safe-area-inset-top)) 52px 4px max(6px, env(safe-area-inset-left)); display: flex; align-items: center; gap: 8px; pointer-events: none; }
.hud-reihe { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.hud-chip { display: flex; align-items: center; gap: 5px; background: rgba(0, 0, 0, .45); border-radius: 999px; padding: 3px 9px 3px 4px; font-weight: 800; font-size: .86rem; border: 2px solid var(--f); }
.hud-chip .punkt { width: 14px; height: 14px; background: var(--f); }
.hud-chip.raus { opacity: .4; text-decoration: line-through; }
.hud-chip b { font-family: var(--display); font-size: 1rem; }
.hud-chip .eff { font-size: .8rem; }
.hud-mitte { background: rgba(0, 0, 0, .45); border-radius: 999px; padding: 3px 12px; font-family: var(--display); font-weight: 800; font-size: 1.05rem; white-space: nowrap; }
.hud-mitte.knapp { color: #ff8fa3; animation: puls 1s infinite; }
@keyframes puls { 50% { transform: scale(1.08); } }

/* Steuerknöpfe: allein/online unten, zu mehreren je Platz am Rand */
.steuer { position: fixed; z-index: 5; left: 0; right: 0; bottom: max(8px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: center; padding: 0 14px; pointer-events: none; }
.steuer button, .pad button { pointer-events: auto; width: 72px; height: 72px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .5); background: rgba(0, 0, 0, .35); color: #fff; font-size: 2rem; font-weight: 900; touch-action: none; }
.steuer button:active, .pad button.gedrueckt { transform: scale(.92); background: rgba(255, 255, 255, .25); }
.steuer button, .pad button { display: grid; place-items: center; padding: 0; }
.steuer button svg, .pad button svg { width: 58%; height: 58%; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.steuer-tipp { color: rgba(255, 255, 255, .5); font-size: .8rem; font-weight: 700; }
.pads { position: fixed; inset: 0; z-index: 5; pointer-events: none; }
.pad { position: absolute; display: flex; align-items: center; gap: clamp(4px, 1.6vw, 10px); padding: 6px clamp(4px, 1.6vw, 10px); pointer-events: none; }
.pad button { flex: none; width: clamp(46px, 14vw, 64px); height: clamp(46px, 14vw, 64px); font-size: clamp(1.5rem, 6.5vw, 2rem); border-color: var(--f); background: color-mix(in srgb, var(--f) 30%, rgba(0, 0, 0, .4)); }
.pad .pad-name { font-family: var(--display); font-weight: 800; color: var(--f); font-size: clamp(.75rem, 3.2vw, .95rem); line-height: 1.15; text-shadow: 0 2px 0 rgba(0, 0, 0, .5); min-width: 0; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pad.unten { bottom: max(6px, env(safe-area-inset-bottom)); }
.pad.oben { top: max(6px, env(safe-area-inset-top)); transform: rotate(180deg); }
.pad.links { left: max(6px, env(safe-area-inset-left)); }
.pad.rechts { right: max(6px, env(safe-area-inset-right)); }
/* Zwei Plätze an einem Rand teilen sich die Breite */
.pad.links, .pad.rechts { max-width: calc(50% - 10px); }
/* translate wirkt im Bildschirm, nicht in der Drehung: auch oben nach links verschieben */
.pad.mitte { left: 50%; translate: -50% 0; }
.pause.seitlich { top: calc(50% - 16px); width: 32px; height: 32px; font-size: .85rem; opacity: .6; }

.ansage { position: fixed; z-index: 7; inset: 0; display: grid; place-items: center; pointer-events: none; font-family: var(--display); font-weight: 800; text-align: center; }
.ansage div { font-size: clamp(2rem, 9vw, 4rem); color: #fff; text-shadow: 0 4px 0 rgba(0, 0, 0, .45), 0 0 30px rgba(255, 255, 255, .25); animation: plopp .35s cubic-bezier(.2, 1.6, .4, 1); }
.ansage small { display: block; font-size: clamp(1rem, 4vw, 1.4rem); color: var(--gelb); }
.hud.seitlich { top: 50%; bottom: auto; right: auto; left: max(4px, env(safe-area-inset-left)); transform: translateY(-50%); padding: 0; }
.hud.seitlich .hud-reihe { display: none; }
/* Schmale Handys: nichts darf die Karte breiter als den Bildschirm machen, und seitlich scrollt nie etwas */
.schicht { grid-template-columns: minmax(0, 1fr); justify-items: center; overflow-x: hidden; overflow-x: clip; overscroll-behavior: none; }
.namen label { min-width: 0; }
.namen input, .name-feld input { width: 100%; }
.karte { max-width: 100%; min-width: 0; }
.opt { flex-wrap: wrap; }
.opt .chips { flex: 1 1 auto; min-width: 0; }
.modi { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.modi button small { overflow-wrap: anywhere; }
.level-reihe { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.level-reihe button span { overflow-wrap: anywhere; hyphens: auto; font-size: .72rem; }
.chips.gross button { flex: 1 1 140px; }
.namen { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 380px) { .level-reihe { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
