/* Speicherschlacht: Handy, Beamer, Steuerung. Alle Klassen mit sl-. */
:root {
  --sl-b: #2563eb; --sl-o: #ea580c; --sl-b-soft: #dbeafe; --sl-o-soft: #ffedd5; --sl-junk: #6b7280;
  /* Teamfarben als Schrift (Kontrast ≥ 4,5 : 1 auf Karte) und als Banner mit weißer Schrift */
  --sl-b-text: #1d4ed8; --sl-o-text: #c2410c; --sl-o-strong: #c2410c; --sl-empty: #cfc9ba;
}
@media (prefers-color-scheme: dark) {
  :root { --sl-b-text: #7cb2ff; --sl-o-text: #fb9a52; --sl-empty: #5a564b; }
}

/* --------------------------------------------------------------- Handy */
body.schlacht.sl-team-b { background: var(--sl-b-soft); }
body.schlacht.sl-team-o { background: var(--sl-o-soft); }
@media (prefers-color-scheme: dark) {
  body.schlacht.sl-team-b { background: #0f1d3d; }
  body.schlacht.sl-team-o { background: #3a1a08; }
}
.sl-banner {
  display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; margin: 0 0 10px; border-radius: 12px;
  background: var(--surface-2); color: var(--text); font-size: 15px;
}
body.sl-team-b .sl-banner { background: var(--sl-b); color: #fff; }
body.sl-team-o .sl-banner { background: var(--sl-o-strong); color: #fff; }
.sl-teamname { font-weight: 800; font-size: 19px; white-space: nowrap; }
.sl-me { flex: 1; opacity: .9; font-size: 13px; white-space: nowrap; }
.sl-banner .sl-time { font-family: var(--mono); font-weight: 800; font-size: 19px; font-variant-numeric: tabular-nums; }
body.schlacht .card h1 { font-size: 20px; margin: 0 0 8px; }
.sl-meta { margin: 0 0 6px; font-size: 15px; color: var(--muted); }
.sl-meta b { color: var(--text); }
.sl-code {
  font-family: var(--mono); font-size: 14px; line-height: 1.45; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; white-space: pre; overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.sl-facts { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.sl-facts li { font-family: var(--mono); font-size: 13px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); }
.sl-send:disabled { background: var(--surface-2); border-color: var(--line); color: var(--muted); }
.sl-prompt { font-size: 17px; font-weight: 600; margin: 0 0 4px; }
.sl-skip { display: block; margin-top: 6px; }
body.sl-docked .phone { padding-bottom: 290px; }
body.sl-docked .foot { display: none; }
.sl-dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 18px rgba(0, 0, 0, .08);
}
.sl-dock-in { max-width: 528px; margin: 0 auto; }
.sl-inrow { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.sl-addr { font-family: var(--mono); font-size: 34px; font-weight: 800; letter-spacing: .06em; min-width: 3.4ch; }
.sl-0x { color: var(--muted); font-size: 15px; margin-right: 6px; }
.sl-addr.empty { color: var(--line); }
.sl-send { margin-left: auto; min-width: 130px; }
body.sl-team-b .sl-send:not(:disabled) { background: var(--sl-b); border-color: var(--sl-b); color: #fff; }
body.sl-team-o .sl-send:not(:disabled) { background: var(--sl-o); border-color: var(--sl-o); color: #fff; }
.sl-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sl-key {
  font-family: var(--mono); font-size: 22px; font-weight: 700; padding: 9px 0; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); touch-action: manipulation;
}
.sl-key:active { transform: scale(.95); }
.sl-key:disabled { opacity: .35; }
.sl-del { font-family: var(--sans); grid-row: 4; grid-column: 3; }
.sl-zero { grid-row: 4; grid-column: 2; }
.sl-fb {
  position: fixed; left: 12px; right: 12px; top: 64px; z-index: 40; max-width: 528px; margin: 0 auto;
  background: #111; color: #eee; border: 3px solid var(--bad); border-radius: 14px; padding: 14px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35); animation: sl-shake .4s ease-out;
}
.sl-fb p { margin: 6px 0 0; font-size: 16px; }
.sl-fb-h { display: block; font-family: var(--mono); color: #f87171; font-size: 16px; }
.sl-fb code { font-family: var(--mono); font-weight: 800; font-size: 20px; }
.sl-fb code.ok { color: #4ade80; }
.sl-fb-tag { color: #fbbf24; font-weight: 600; }
.sl-fb-core, .sl-fb-n { color: #aaa; font-size: 14px !important; }
@keyframes sl-shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(8px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(5px); } }
.sl-flash {
  position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 40; background: var(--ok); color: #fff;
  font-weight: 800; font-size: 17px; padding: 7px 16px; border-radius: 999px; animation: sl-flash 1.1s ease-out forwards;
  pointer-events: none; white-space: nowrap;
}
/* grün mit weißem Rand und unter der Kopfzeile, sonst verschwindet er in der gleichfarbigen Teamfarbe */
.sl-flash { top: 128px; border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .25); }
/* schmale Handys: umbrechen statt über den Rand laufen */
.sl-flash { width: max-content; max-width: calc(100vw - 24px); white-space: normal; text-align: center; }
.sl-flash.leak { background: #374151; border-color: #fbbf24; animation-duration: 1.6s; }
/* nur ein- und ausblenden, keine Bewegung: ein Hinweis, kein Ereignis */
@keyframes sl-flash { 0% { opacity: 0; } 12% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }


/* Wahl-Aufgaben: Lücke im Code, Knöpfe statt Tastatur */
.sl-gap {
  display: inline-block; min-width: 1.4em; padding: 0 .25em; margin: 0 1px; border-radius: 5px; text-align: center;
  background: #fde68a; color: #111; font-weight: 800; outline: 2px dashed #d97706; outline-offset: -1px;
}
body.sl-docked.sl-dock-wahl .phone { padding-bottom: 230px; }
.sl-choices.sig { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sl-choices.lines { display: grid; gap: 6px; }
.sl-opt {
  font-family: var(--mono); font-weight: 800; border-radius: 12px; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--text); touch-action: manipulation;
}
.sl-choices.sig .sl-opt { font-size: 30px; padding: 18px 0; }
.sl-choices.sig .sl-opt:last-child { font-family: var(--sans); font-size: 20px; }
.sl-choices.lines .sl-opt { font-size: 15px; padding: 11px 12px; text-align: left; white-space: nowrap; overflow-x: auto; }
.sl-opt:active { transform: scale(.97); }
.sl-opt:disabled { opacity: .35; }
body.sl-team-b .sl-opt:not(:disabled) { border-color: var(--sl-b); }
body.sl-team-o .sl-opt:not(:disabled) { border-color: var(--sl-o); }
.sl-fb code.long { font-size: 15px; }
.sl-fb-ex { color: #ddd; }
.sl-fb-go { margin-top: 12px; width: 100%; }

/* Online (/aufgabe/<name>): gemeinsames Spielfeld unter der Aufgabe, Teamfarbe wie im Hörsaal (sl-team-b/o) */
.sl-stand { font-size: 17px; }
.sl-online-now { margin: 0 0 8px; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sl-banner { flex-wrap: wrap; }
.sl-tools { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.sl-sound {
  font: inherit; font-size: 12px; font-weight: 600; color: inherit; background: rgba(255, 255, 255, .22);
  border: 1px solid currentColor; border-radius: 99px; padding: 2px 10px; cursor: pointer;
}
.sl-sound[aria-pressed="false"] { background: transparent; }
.sl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); animation: sl-pulse 2s ease-in-out infinite; }
@keyframes sl-pulse { 50% { opacity: .35; } }
.sl-heaps { margin: 0 0 8px; display: grid; grid-template-columns: auto 1fr auto auto; gap: 4px 8px; align-items: center; }
.sl-heaps > p { grid-column: 1 / -1; margin: 0; }
.sl-hp-help {
  grid-column: 4; grid-row: 1 / 3; width: 24px; height: 24px; padding: 0; border-radius: 50%; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line);
}
.sl-hp-text { grid-column: 1 / -1; }
.sl-hp-text p { margin: 0 0 6px; }
.sl-hp-core-info { margin-top: 4px; }
.sl-hp-core-info summary { cursor: pointer; font-weight: 600; color: var(--text); }
.sl-hp-core-info p { margin: 6px 0 0 14px; }
.sl-hp-help[aria-expanded="true"] { color: var(--text); border-color: var(--text); }
/* sl-hp, nicht sl-heap/sl-core: die Namen hat der Beamer (weiter unten), seine Regeln stehen später und gewannen hier */
.sl-hp { display: contents; font-size: 13px; }
.sl-hp-n { font-weight: 700; white-space: nowrap; }
.sl-hp.b .sl-hp-n { color: var(--sl-b-text); }
.sl-hp.o .sl-hp-n { color: var(--sl-o-text); }
.sl-hp.mine .sl-hp-n { text-decoration: underline; }
.sl-hp-s { display: flex; gap: 3px; align-items: flex-end; }
.sl-hp-core { flex: 1; max-width: 22px; height: 16px; border-radius: 3px; background: var(--surface-2); border: 1px dashed var(--sl-empty); }
.sl-hp-core.on { background: #374151; border: 1px solid #9ca3af; }
.sl-hp.b .sl-hp-core.on { box-shadow: inset 0 3px 0 var(--sl-b); }
.sl-hp.o .sl-hp-core.on { box-shadow: inset 0 3px 0 var(--sl-o); }
.sl-hp-s.hot .sl-hp-core.on { background: #b91c1c; animation: sl-pulse 1s ease-in-out infinite; }
.sl-hp-c { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.sl-kbd, .sl-deskhint { display: none; }
/* Lesezeit (erste 2 s einer Aufgabe): Eingabe gedämpft, dazu ein kurzer Hinweis */
.sl-readhint { margin: 0 0 6px; font-size: 13px; color: var(--muted); }
.sl-dock:not(.reading) .sl-readhint { display: none; }
.sl-dock.reading .sl-opt, .sl-dock.reading .sl-key, .sl-dock.reading .sl-send { opacity: .55; }
.sl-st-b { color: var(--sl-b-text); }
.sl-st-o { color: var(--sl-o-text); }
.sl-mem { margin-top: 10px; }
.sl-mem-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.sl-mem-grid { display: grid; gap: 2px; }
.sl-m { display: block; aspect-ratio: 2 / 1; border-radius: 2px; background: var(--surface-2); border: 1px solid var(--sl-empty); }
.sl-m.own-b { background: var(--sl-b); border-color: var(--sl-b); }
.sl-m.own-o { background: var(--sl-o); border-color: var(--sl-o); }
/* Aufblitzen geänderter Bytes: wächst leicht und trägt kurz einen dünnen Ring (eigene weiß, fremde rot, verlorene
   eigene weiß mit rotem Schein, Müll gelb) mit schwachem Schein; dezent, damit das Feld bei viel Betrieb nicht flimmert */
.sl-m.flash { position: relative; z-index: 2; animation: sl-cell .9s ease-out; }
.sl-m.flash-own { --ring: #fff; --glow: rgba(255, 255, 255, .5); }
.sl-m.flash-enemy { --ring: #ef4444; --glow: rgba(239, 68, 68, .5); animation-duration: 1s; }
.sl-m.flash-enemy.lost { --ring: #fff; --glow: rgba(239, 68, 68, .75); animation-duration: 1.2s; }
.sl-m.flash-junk { --ring: #fbbf24; --glow: rgba(251, 191, 36, .5); }
@keyframes sl-cell {
  0% { transform: scale(1.3); box-shadow: 0 0 0 2px var(--ring), 0 0 6px 2px var(--glow); }
  35% { transform: scale(1.1); box-shadow: 0 0 0 2px var(--ring), 0 0 4px 1px var(--glow); }
  100% { transform: none; box-shadow: 0 0 0 0 transparent, 0 0 0 0 transparent; }
}
/* die ganze Karte: ein dünner Rand, der kurz aufleuchtet, statt eines breiten Glühens */
.sl-mem.pulse-own { animation: sl-memflash .5s ease-out; --pulse: rgba(34, 197, 94, .7); }
.sl-mem.pulse-enemy { animation: sl-memflash .6s ease-out; --pulse: rgba(239, 68, 68, .7); }
.sl-mem.pulse-lost { animation: sl-memflash .8s ease-out; --pulse: rgba(239, 68, 68, .9); }
@keyframes sl-memflash {
  0% { box-shadow: 0 0 0 2px var(--pulse); }
  100% { box-shadow: 0 0 0 2px transparent; }
}
.sl-stand.bump { display: inline-block; animation: sl-bump .4s ease-out; }
@keyframes sl-bump { 0% { transform: scale(1.1); } 100% { transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sl-m.flash { animation: none; box-shadow: 0 0 0 2px var(--ring); }
  .sl-mem.pulse-own, .sl-mem.pulse-enemy, .sl-mem.pulse-lost, .sl-stand.bump { animation: none; }
}
.sl-m.junk { background: repeating-linear-gradient(45deg, var(--sl-junk) 0 3px, #4b5160 3px 6px); }

/* -------------------------------------------------------------- Beamer */
.sl-b { height: 100%; display: flex; flex-direction: column; gap: 1.5vh; min-height: 0; }
.sl-head { display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; gap: 2vw; }
.sl-team { display: flex; align-items: baseline; gap: 1vw; font-size: 3vh; font-weight: 700; }
.sl-t-b { color: var(--sl-b); }
.sl-t-o { color: var(--sl-o); justify-content: flex-end; }
.sl-sc { font-family: var(--mono); font-size: 7vh; line-height: 1; font-variant-numeric: tabular-nums; }
.sl-mid { display: flex; flex-direction: column; align-items: center; gap: .8vh; }
.sl-bar { width: 100%; height: 2.4vh; border-radius: 99px; background: #343b4a; display: flex; justify-content: space-between; overflow: hidden; }
.sl-bar i { display: block; height: 100%; transition: width .4s ease; }
.sl-bar-b { background: var(--sl-b); }
.sl-bar-o { background: var(--sl-o); }
.sl-time { font-family: var(--mono); font-size: 5vh; font-weight: 800; font-variant-numeric: tabular-nums; }
.sl-time.hot { color: var(--bad); animation: sl-hot 1s ease-in-out infinite; }
@keyframes sl-hot { 50% { opacity: .45; } }
.sl-arena { flex: 1; min-height: 0; display: flex; gap: 1vw; justify-content: center; align-items: stretch; }
.sl-boardbox { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.sl-decl { font-family: var(--mono); font-size: 2.2vh; color: var(--muted); margin-bottom: 8px; }
.sl-blocks { display: flex; gap: 24px; align-items: flex-start; }
.sl-grid { display: grid; gap: 2px; }
.sl-lab { display: flex; align-items: center; justify-content: center; font-family: var(--mono); color: var(--muted); }
.sl-row { justify-content: flex-end; padding-right: .4em; font-size: .85em; }
.sl-c { background: #343b4a; border-radius: 2px; transition: background-color .35s ease; }
.sl-c.own-b { background: var(--sl-b); }
.sl-c.own-o { background: var(--sl-o); }
.sl-c.junk { background: repeating-linear-gradient(45deg, var(--sl-junk) 0 3px, #4b5160 3px 6px); }
.sl-c.pop { animation: sl-pop .6s ease-out; }
.sl-c.leak { animation: sl-leak 1.5s ease-out; }
@keyframes sl-pop { 0% { transform: scale(1.6); filter: brightness(1.8); } 100% { transform: none; filter: none; } }
@keyframes sl-leak { 0%, 30%, 60% { outline: 4px solid #fbbf24; transform: scale(1.3); } 15%, 45%, 100% { outline: 0 solid transparent; transform: none; } }

.sl-heap { width: 11vw; flex: none; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; position: relative; --cw: 2.5vw; --ch: 2.1vw; }
.sl-pile-cap { font-family: var(--mono); color: var(--muted); font-size: 2vh; margin-bottom: auto; padding-top: 2vh; }
.sl-pile { position: relative; width: 100%; height: calc(4 * var(--ch) + 1vh); }
.sl-pile.tip { animation: sl-tip 1.1s ease-in forwards; }
@keyframes sl-tip { 0% { transform: none; } 30% { transform: rotate(-8deg); } 100% { transform: translateY(40%) rotate(25deg) scale(.6); opacity: 0; } }
.sl-core {
  position: absolute; width: calc(var(--cw) - 4px); height: calc(var(--ch) - 4px); border-radius: 4px;
  background: linear-gradient(#5b6170, #3a3f4b); border: 2px solid #23262e; transform: rotate(var(--rot));
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 0 #15171c;
}
.sl-core span { font-family: var(--mono); font-size: 1.3vh; color: #c9ccd3; }
.sl-h-b .sl-core { border-color: var(--sl-b); }
.sl-h-o .sl-core { border-color: var(--sl-o); }
.sl-core.drop { animation: sl-drop .55s cubic-bezier(.3, 0, .6, 1.4); }
@keyframes sl-drop { 0% { transform: translateY(-40vh) rotate(0); } 80% { transform: translateY(0) rotate(var(--rot)); } 90% { transform: translateY(-6px) rotate(var(--rot)); } 100% { transform: rotate(var(--rot)); } }
.sl-pile-n { font-size: 2vh; color: var(--muted); margin-top: 1vh; text-align: center; }
.sl-leak-tag {
  position: absolute; top: 30%; left: 50%; transform: translateX(-50%); white-space: nowrap; font-weight: 800; font-size: 2.6vh;
  color: #111; background: #fbbf24; padding: .5vh 1vw; border-radius: 99px; animation: sl-in .3s ease-out;
}
@keyframes sl-in { from { opacity: 0; transform: translate(-50%, -10px); } to { opacity: 1; transform: translateX(-50%); } }

.sl-result { width: 34vw; flex: none; display: flex; flex-direction: column; gap: 1.2vh; overflow: auto; }
.sl-win { font-size: 4.5vh; font-weight: 800; display: flex; flex-direction: column; }
.sl-win.w-b { color: var(--sl-b); }
.sl-win.w-o { color: var(--sl-o); }
.sl-win small { font-size: 2.2vh; color: var(--muted); font-weight: 500; }
.sl-cap { font-size: 1.8vh; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.sl-st { background: var(--surface); border-radius: 1.2vh; padding: .8vh 1vw; }
.sl-st-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 2.2vh; }
.sl-st-h b { color: var(--ok); font-size: 2.8vh; }
.sl-st-bar { height: 1vh; background: #232835; border-radius: 99px; overflow: hidden; margin: .5vh 0; }
.sl-st-bar i { display: block; height: 100%; background: var(--ok); }
.sl-st-tags { list-style: none; margin: .4vh 0 0; padding: 0; font-size: 1.8vh; }
.sl-st-tags li { display: flex; justify-content: space-between; gap: 1vw; color: var(--accent); }
.sl-st-tags b { color: var(--muted); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .sl-c, .sl-c.pop, .sl-c.leak, .sl-core.drop, .sl-pile.tip, .sl-time.hot, .sl-fb { animation: none; transition: none; }
}

/* ----------------------------------------------------------- Steuerung */
.sl-a-stats { display: grid; gap: 6px; }
.sl-a-st { display: grid; gap: 2px; padding: 6px 10px; border-radius: 8px; background: var(--surface-2); font-size: 14px; }
.sl-a-st .small:empty { display: none; }
.sl-a-dur { display: grid; gap: 4px; margin-bottom: 10px; }
.sl-a-dur .btns { align-items: center; }
.sl-a-min { width: 5.5em; font-size: 16px; padding: 6px 8px; }
.sl-gap.line { min-width: 16em; text-align: left; }
.sl-a-dur input.sl-a-min { width: 6em; flex: none; display: inline-block; margin: 0; }

/* Desktop (Maus und Tastatur, breit), Hörsaal und online: breitere Spalte, Eingabe unter der Aufgabe statt am Rand, kein
 * Ziffernblock zum Antippen, Tastenschilder. Online zusätzlich zweispaltig (Aufgabe links, Feld rechts). */
@media (min-width: 900px) and (hover: hover) and (pointer: fine) {
  body.schlacht .top, body.schlacht #app.phone, body.schlacht .who { max-width: 760px; }
  body.sl-online .top, body.sl-online #app.phone, body.sl-online .who { max-width: 1040px; }
  body.sl-online #app.phone {
    display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto auto 1fr; gap: 0 18px;
    align-items: start; padding-bottom: 40px;
  }
  body.sl-online .sl-banner { grid-column: 1 / -1; }
  body.sl-online .sl-card { grid-column: 1; grid-row: 2; }
  body.sl-online .sl-mem { grid-column: 2; grid-row: 2 / span 2; margin-top: 0; position: sticky; top: 12px; }
  body.sl-online .sl-dock { grid-column: 1; grid-row: 3; align-self: start; }
  body.schlacht .sl-dock {
    position: static; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: none; padding: 14px 18px;
    margin-bottom: 14px;
  }
  body.schlacht .sl-dock-in { max-width: none; }
  body.schlacht.sl-docked .phone, body.schlacht.sl-docked.sl-dock-wahl .phone { padding-bottom: 40px; }
  body.schlacht .sl-keys { display: none; }
  body.schlacht .sl-addr { font-size: 44px; }
  body.schlacht .sl-deskhint { display: block; margin: 8px 0 0; font-size: 13px; color: var(--muted); }
  body.schlacht .sl-choices.sig .sl-opt { font-size: 30px; padding: 14px 0; }
  body.schlacht .sl-opt { position: relative; }
  body.schlacht .sl-kbd {
    display: block; position: absolute; top: 4px; right: 8px; font-family: var(--mono); font-size: 12px; font-weight: 600;
    color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; background: var(--surface);
  }
  body.schlacht .sl-fb { top: 128px; max-width: 640px; }
}
