/* Nach R'lyeh – Spielansicht. Mobile first: iPhone im Hochformat.
   Aufbau: Kopfzeile oben, Spielfeld mit Uebersichtsleiste, Faehigkeiten
   unten in Daumenreichweite. Alles unter .rs-wurzel. */

.rs-wurzel {
  --rs-grund: #07090a;
  --rs-flaeche: #15121a;
  --rs-flaeche2: #1d1924;
  --rs-rand: #342c3c;
  --rs-text: #ece6d2;
  --rs-leise: #9c95a6;
  --rs-akzent: #8cbf6e;
  --rs-glut: #e0703a;
  --rs-klar: #f4f1e6;
  --rs-verstoert: #a8f080;
  --rs-wahnsinnig: #d49cff;
  --rs-warn: #ff5a3c;

  position: fixed;
  inset: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  background: var(--rs-grund);
  color: var(--rs-text);
  font: 13px/1.25 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  overscroll-behavior: none;
}
.rs-wurzel *, .rs-wurzel *::before, .rs-wurzel *::after { box-sizing: border-box; }
.rs-wurzel [hidden] { display: none !important; }
.rs-wurzel[data-welt="2"] { --rs-akzent: #3fc0aa; --rs-glut: #e8a040; --rs-grund: #03100f; }
.rs-wurzel[data-welt="3"] { --rs-akzent: #e874bc; --rs-glut: #ffb060; --rs-grund: #0e0718; }
.rs-wurzel[data-welt="4"] { --rs-akzent: #7a88ff; --rs-glut: #ff9a50; --rs-grund: #030309; }
.rs-wurzel[data-welt="5"] { --rs-akzent: #9ad84a; --rs-glut: #ff4a30; --rs-grund: #0c0408; }

.rs-icon {
  width: 16px;
  height: 16px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  flex: none;
  display: block;
}

.rs-wurzel button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.rs-wurzel button:focus { outline: none; }
.rs-wurzel button:focus-visible { outline: 2px solid var(--rs-akzent); outline-offset: 1px; }

/* ------------------------------------------------------------ Kopfzeile */
.rs-kopf {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(4px + env(safe-area-inset-top)) 6px 4px 8px;
  background: linear-gradient(#141019, #0d0b11);
  border-bottom: 1px solid var(--rs-rand);
}
.rs-werte {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.rs-zeile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 18px;
}
.rs-wert {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  min-width: 0;
}
.rs-zahl { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.rs-klein { color: var(--rs-leise); font-size: 12px; }
.rs-balken {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 7px;
  border-radius: 4px;
  background: #2a2233;
  overflow: hidden;
  flex: none;
}
.rs-balken i {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: var(--rs-akzent);
  transition: transform 0.25s linear;
}
.rs-quote i { background: var(--rs-klar); }
.rs-erreicht .rs-zahl { color: var(--rs-akzent); }
.rs-erreicht .rs-quote i { background: var(--rs-akzent); }
.rs-wahn .rs-balken i { background: linear-gradient(90deg, #9fe07a, #c48cff 60%, #ff4ad0); }
.rs-wahn.rs-hoch .rs-balken { box-shadow: 0 0 6px #c48cff; }
.rs-zeit.rs-warnung .rs-zahl { color: var(--rs-warn); animation: rs-puls 1s ease-in-out infinite; }
@keyframes rs-puls { 50% { opacity: 0.45; } }

.rs-knoepfe { flex: none; display: flex; gap: 4px; }
.rs-knopf {
  position: relative;
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--rs-flaeche2);
  border: 1px solid var(--rs-rand);
}
.rs-knopf .rs-icon { width: 32px; height: 32px; }
.rs-knopf.rs-an { background: #26301f; border-color: var(--rs-akzent); }
.rs-knopf:active { transform: translateY(1px); }
.rs-marke {
  position: absolute;
  right: 2px;
  bottom: 1px;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: var(--rs-text);
  text-shadow: 0 0 2px #000, 0 0 2px #000;
}
.rs-striche { display: grid; gap: 4px; }
.rs-striche i { display: block; width: 20px; height: 3px; border-radius: 2px; background: var(--rs-text); }

.rs-erwachen {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 8px 3px;
  background: #1a0710;
  border-bottom: 1px solid #4a1426;
}
.rs-erwachen .rs-balken { flex: 1; width: auto; height: 6px; }
.rs-erwachen .rs-balken i { background: linear-gradient(90deg, #7a1a32, #ff4a30); }
.rs-erwachen.rs-hoch .rs-klein { color: var(--rs-warn); animation: rs-puls 0.8s ease-in-out infinite; }

/* ------------------------------------------------------------ Spielfeld */
.rs-mitte {
  flex: 1;
  min-height: 0;
  display: flex;
  position: relative;
}
.rs-feld {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  touch-action: none;
}
.rs-leinwand {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}
.rs-feld.rs-zieht .rs-leinwand { cursor: grabbing; }
.rs-uebersicht {
  position: relative;
  flex: 0 0 26px;
  width: 26px;
  border-left: 1px solid var(--rs-rand);
  background: #050407;
  touch-action: none;
}
.rs-uebersicht canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.rs-ebene {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.rs-blase {
  --rand: rgba(244, 241, 230, 0.6);
  --spitze: 20px;
  position: absolute;
  left: 0;
  top: 0;
  max-width: 150px;
  padding: 2px 6px 3px;
  font-size: 12px;
  line-height: 1.2;
  color: var(--rs-klar);
  background: rgba(10, 8, 14, 0.72);
  border: 1px solid var(--rand);
  border-radius: 7px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
  will-change: transform, opacity;
  white-space: normal;
}
.rs-blase.rs-an { opacity: 1; }
/* Spitze zur sprechenden Seele: ein kleines Dreieck am Rand */
.rs-blase::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  background: rgba(10, 8, 14, 0.9);
  border: 1px solid var(--rand);
  border-top: 0;
  border-left: 0;
}
.rs-blase[data-seite="oben"]::after { left: calc(var(--spitze) - 4px); bottom: -4px; transform: rotate(45deg); }
.rs-blase[data-seite="rechts"]::after { left: -4px; top: calc(var(--spitze) - 4px); transform: rotate(135deg); }
.rs-blase[data-seite="links"]::after { right: -4px; top: calc(var(--spitze) - 4px); transform: rotate(-45deg); }
.rs-blase[data-stufe="verstoert"] { --rand: rgba(168, 240, 128, 0.7); color: var(--rs-verstoert); }
.rs-blase[data-stufe="wahnsinnig"] { --rand: rgba(212, 156, 255, 0.75); color: var(--rs-wahnsinnig); font-style: italic; }
.rs-ablehnung {
  position: absolute;
  left: 0;
  top: 0;
  padding: 6px 10px;
  font-size: 13px;
  color: #ffe4dc;
  background: rgba(58, 10, 16, 0.94);
  border: 1px solid #ff6a50;
  border-radius: 9px;
}

.rs-status {
  position: absolute;
  top: 6px;
  left: 6px;
  right: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  pointer-events: none;
}
.rs-chip {
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  background: rgba(10, 8, 14, 0.82);
  border: 1px solid var(--rs-rand);
}
.rs-chip-pause { border-color: var(--rs-text); }
.rs-chip-ruhe { color: #ffd9a0; border-color: var(--rs-glut); }
.rs-chip-quote { color: var(--rs-akzent); border-color: var(--rs-akzent); }

.rs-meldung {
  position: absolute;
  left: 50%;
  top: 36px;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 7px 12px;
  text-align: center;
  font-size: 13px;
  background: rgba(12, 10, 18, 0.92);
  border: 1px solid var(--rs-rand);
  border-radius: 10px;
  pointer-events: none;
}
.rs-hinweis {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 20px);
  max-width: 520px;
  bottom: 10px;
  min-height: 44px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  text-align: left;
  font-size: 14px;
  line-height: 1.3;
  background: rgba(14, 11, 20, 0.94);
  border: 1px solid var(--rs-akzent);
  border-radius: 12px;
}
.rs-hinweis strong { color: var(--rs-akzent); font-size: 13px; }

/* ------------------------------------------------------------ Leiste */
.rs-leiste {
  flex: none;
  display: flex;
  justify-content: center;
  gap: 2px;
  padding: 5px 4px calc(5px + env(safe-area-inset-bottom));
  background: linear-gradient(#0d0b11, #141019);
  border-top: 1px solid var(--rs-rand);
}
.rs-leiste[data-anzahl="0"] { display: none; }
.rs-faehigkeit {
  position: relative;
  flex: 1 1 0;
  min-width: 44px;
  max-width: 76px;
  height: 60px;
  padding: 3px 0 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  border-radius: 10px;
  background: var(--rs-flaeche);
  border: 1px solid var(--rs-rand);
}
.rs-faehigkeit .rs-icon { width: 32px; height: 32px; }
.rs-kurz {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  font-size: min(11px, 2.65vw);
  line-height: 1;
  letter-spacing: -0.2px;
  color: var(--rs-leise);
}
.rs-rest {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 17px;
  padding: 1px 3px;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  font-variant-numeric: tabular-nums;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.7);
}
.rs-faehigkeit.rs-gewaehlt {
  background: #28341f;
  border-color: var(--rs-akzent);
  box-shadow: inset 0 0 0 1px var(--rs-akzent), 0 0 10px rgba(140, 191, 110, 0.45);
  transform: translateY(-3px);
}
.rs-faehigkeit.rs-gewaehlt .rs-kurz { color: var(--rs-text); font-weight: 700; }
.rs-faehigkeit.rs-gewaehlt .rs-rest { background: var(--rs-akzent); color: #0b0d08; }
.rs-faehigkeit.rs-leer { opacity: 0.38; filter: grayscale(1); }

/* ------------------------------------------------------------ Menue */
.rs-menue {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(3, 2, 6, 0.7);
}
.rs-karte {
  width: min(340px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 16px;
  background: #120f16;
  border: 1px solid var(--rs-rand);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  touch-action: pan-y;
}
.rs-titel { margin: 0 0 12px; font-size: 17px; font-weight: 700; color: var(--rs-akzent); }
.rs-liste, .rs-frage-knoepfe { display: flex; flex-direction: column; gap: 8px; }
.rs-punkt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  font-size: 16px;
  text-align: left;
  border-radius: 10px;
  background: var(--rs-flaeche2);
  border: 1px solid var(--rs-rand);
}
.rs-punkt .rs-icon, .rs-icon-platz { width: 32px; height: 32px; flex: none; }
.rs-punkt.rs-haupt { border-color: var(--rs-akzent); }
.rs-punkt.rs-gefahr { border-color: var(--rs-warn); color: #ffd0c4; justify-content: center; }
.rs-frage p { margin: 0 0 14px; font-size: 15px; line-height: 1.4; }
.rs-frage-knoepfe .rs-punkt { justify-content: center; }

/* ------------------------------------------------------------ Querformat, Desktop */
@media (orientation: landscape) and (max-height: 500px) {
  .rs-kopf { padding-top: calc(2px + env(safe-area-inset-top)); padding-bottom: 2px; }
  .rs-zeile { gap: 14px; }
  .rs-werte { flex-direction: row; gap: 16px; align-items: center; }
  .rs-faehigkeit { height: 52px; }
  .rs-faehigkeit .rs-icon { width: 28px; height: 28px; }
  .rs-hinweis { font-size: 13px; padding: 6px 10px; bottom: 6px; }
  .rs-leiste { padding-top: 3px; padding-bottom: calc(3px + env(safe-area-inset-bottom)); }
}
@media (min-width: 700px) {
  .rs-balken { width: 72px; }
  .rs-uebersicht { flex-basis: 34px; width: 34px; }
  .rs-kurz { font-size: 12px; }
  .rs-faehigkeit { max-width: 88px; height: 64px; }
}
@media (hover: hover) {
  .rs-knopf:hover, .rs-faehigkeit:hover, .rs-punkt:hover { border-color: var(--rs-leise); }
}
