/* Hearthstone Drinking Game - PWA-Styling (mobile-first, Hochformat). */
:root {
  --bg: #17171b;
  --panel: #24242b;
  --panel2: #2e2e37;
  --gold: #c8a24a;
  --gold-2: #e6c877;
  --text: #f0ece2;
  --muted: #9a958a;
  --accent: #3aa0d8;
  --danger: #c0503f;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }

.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 0.9rem; padding-top: max(0.55rem, env(safe-area-inset-top));
  border-bottom: 2px solid var(--gold); background: var(--panel); position: sticky; top: 0; z-index: 10;
}
.app-title { font-size: 0.95rem; margin: 0; color: var(--gold); letter-spacing: .02em; }
.lang-switch { display: flex; gap: .25rem; }
.lang-btn { background: transparent; color: var(--muted); border: 1px solid var(--muted);
  border-radius: 6px; padding: .2rem .5rem; font-size: .8rem; cursor: pointer; }
.lang-btn.active { color: var(--bg); background: var(--gold); border-color: var(--gold); }

.app-main { padding: 1rem; max-width: 1120px; margin: 0 auto; }

/* Buttons & Inputs */
.btn { display: inline-block; border: 1px solid var(--gold); background: var(--panel2);
  color: var(--text); padding: .6rem 1rem; border-radius: var(--radius); font-size: 1rem;
  cursor: pointer; text-align: center; }
.btn.primary { background: var(--gold); color: #1a1a1a; font-weight: 600; border-color: var(--gold); }
.btn.ghost { background: transparent; border-color: var(--muted); color: var(--muted); }
.btn.big { font-size: 1.15rem; padding: .7rem 1.6rem; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.selected { outline: 3px solid var(--accent); }
.inp { display: block; width: 100%; margin: .3rem 0 .9rem; padding: .6rem .7rem;
  background: var(--panel2); border: 1px solid var(--muted); border-radius: 8px; color: var(--text); font-size: 1rem; }
.code-inp { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-size: 1.4rem; }
label { font-size: .9rem; color: var(--muted); }

.card { background: var(--panel); border: 1px solid #3a3a44; border-radius: var(--radius);
  padding: 1.1rem; text-align: center; max-width: 540px; margin-inline: auto; }
.card h2 { color: var(--gold); margin-top: .2rem; }
.menu { display: flex; flex-direction: column; gap: .6rem; margin-top: 1rem; }
.hint { color: var(--muted); font-size: .9rem; }

.code { color: var(--gold-2); font-weight: 700; letter-spacing: .25em; cursor: pointer;
  border-bottom: 1px dashed var(--muted); }
.roster { list-style: none; padding: 0; margin: .5rem 0; }
.roster li { padding: .45rem; border-bottom: 1px solid #3a3a44; display: flex; align-items: center; }
.you { color: var(--accent); font-size: .85rem; margin-left: .35rem; }
.pfp { width: 26px; height: 26px; border-radius: 50%; margin-right: .45rem;
  border: 1px solid var(--muted); object-fit: cover; background: #0006; }

/* Figuren-Wahl */
.pfp-avatar { position: relative; padding: 0; background: none; border: none; cursor: pointer; line-height: 0; }
.pfp-avatar .pfp { border-color: var(--gold); }
.pfp-edit { position: absolute; right: 2px; bottom: -2px; font-size: 11px; background: var(--gold);
  color: #1a1a1a; border-radius: 50%; width: 15px; height: 15px; display: flex; align-items: center; justify-content: center; }
.rn { margin-left: .1rem; }
.name-edit { background: none; border: none; color: var(--text); font: inherit; cursor: pointer;
  padding: 0; border-bottom: 1px dashed var(--muted); }
.li-right { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.ready-badge { color: #4caf50; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.wait-badge { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.kick-x { background: transparent; border: 1px solid var(--muted); color: var(--muted);
  border-radius: 6px; width: 24px; height: 24px; line-height: 1; cursor: pointer; font-size: .8rem; }
.kick-x:hover { border-color: var(--danger); color: var(--danger); }
.pfp-row { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; margin: .5rem 0; }
.pfp-btn { padding: 2px; background: var(--panel2); border: 2px solid transparent;
  border-radius: 8px; cursor: pointer; line-height: 0; }
.pfp-btn img { width: 42px; height: 42px; border-radius: 6px; object-fit: cover; display: block; }
.pfp-btn.sel { border-color: var(--gold); }
.pfp-btn:disabled { opacity: .28; cursor: default; }

/* Spielansicht */
.game { display: flex; flex-direction: column; gap: .8rem; }
.board-wrap { width: 100%; }
.board { position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius); overflow: hidden; }
.board-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.tokens { position: absolute; inset: 0; }
.token { position: absolute; width: 7.5%; height: auto; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 4px rgba(0,0,0,.7); background: #0008;
  transition-property: left, top; transition-timing-function: linear; transition-duration: 140ms; }
.token.active { border-color: var(--gold-2); box-shadow: 0 0 0 2px var(--gold), 0 0 8px var(--gold); z-index: 3; }
.token.moving { z-index: 4; }
/* Echter Teleport (Mirror Image, zurück zum Start): Aufblitzen statt Laufen.
   Kein transform animieren - das trägt bereits die Positionierung. */
.token.teleport { transition-duration: 0ms; animation: tp .32s ease; }
@keyframes tp {
  0%   { opacity: .15; box-shadow: 0 0 0 0 var(--accent); }
  55%  { opacity: 1;   box-shadow: 0 0 14px 6px var(--accent); }
  100% { opacity: 1;   box-shadow: 0 0 4px rgba(0,0,0,.7); }
}
@media (prefers-reduced-motion: reduce) {
  .token { transition-duration: 0ms !important; }
  .token.teleport { animation: none; }
}
.caldot { position: absolute; transform: translate(-50%,-50%); font-size: 10px; font-weight: 700;
  color: #fff; background: #e0392bcc; border-radius: 50%; width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center; }

.hud { display: flex; flex-direction: column; gap: .7rem; }
.turn { text-align: center; font-size: 1.05rem; padding: .5rem; border-radius: 8px; background: var(--panel2); }
.turn.me { background: var(--gold); color: #1a1a1a; font-weight: 700; }

.seatbar { display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center; }
.chip { font-size: .8rem; padding: .2rem .5rem; border-radius: 999px; background: var(--panel2); border: 1px solid #3a3a44; }
.chip.active { border-color: var(--gold); color: var(--gold-2); }
.conn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .35rem;
  vertical-align: middle; }
.conn-dot.on { background: #4caf50; }
.conn-dot.off { background: var(--muted); }
.hud-row { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: center; }

.controls { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.controls.hint { color: var(--muted); }
.die { width: 64px; height: 64px; image-rendering: auto; }
.die.rolling { filter: blur(1px); }
.dialog { background: var(--panel2); border: 1px solid var(--gold); border-radius: var(--radius); padding: .8rem; width: 100%; }
.dialog-field { color: var(--gold-2); font-weight: 600; margin: 0 0 .5rem; }
.dialog-hint { color: var(--muted); font-size: .9rem; margin: .2rem 0 .4rem; }
.branches { list-style: none; padding: 0; margin: 0 0 .4rem; text-align: left; width: 100%; }
.branches li { padding: .25rem 0; border-bottom: 1px solid #3a3a44; }
.branches b { color: var(--gold-2); margin-right: .3rem; }

/* Verteilen-Stepper */
.dist-remaining { color: var(--gold-2); font-weight: 600; margin: .2rem 0 .5rem; }
.dist-row { display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  width: 100%; padding: .25rem 0; border-bottom: 1px solid #3a3a44; }
.dist-name { flex: 1; text-align: left; }
.stepper { display: flex; align-items: center; gap: .5rem; }
.stp { padding: .2rem .7rem; font-size: 1.2rem; line-height: 1; min-width: 40px; }
.stp-c { min-width: 1.5rem; text-align: center; font-weight: 700; }

/* Regelübersicht (Modal) */
.rules-all { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow-y: auto;
  text-align: left; }
.rules-all li { padding: .4rem .2rem; border-bottom: 1px solid #3a3a44; font-size: .9rem; }
.rules-all b { color: var(--gold-2); }
.picks { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: .5rem 0; }
.seat-pick { padding: .5rem .8rem; }

.panel { background: var(--panel); border: 1px solid #3a3a44; border-radius: var(--radius); padding: .6rem .8rem; }
.panel h4 { margin: .1rem 0 .4rem; color: var(--gold); font-size: .9rem; }
.panel ul { list-style: none; padding: 0; margin: 0; }
.panel li { overflow-wrap: anywhere; }
.panel.rules li { padding: .3rem 0; border-bottom: 1px solid #3a3a44; font-size: .9rem;
  display: flex; gap: .5rem; align-items: flex-start; justify-content: space-between; }
.rule-x { flex: 0 0 auto; background: transparent; border: 1px solid var(--muted);
  color: var(--muted); border-radius: 6px; width: 26px; height: 26px; line-height: 1;
  cursor: pointer; font-size: .85rem; }
.rule-x:hover { border-color: var(--danger); color: var(--danger); }
.panel.log li { padding: .2rem 0; font-size: .85rem; color: #d6d1c6; border-bottom: 1px solid #2c2c34; }

/* Verbindungs-Banner (Spiel ist server-gebunden) */
#conn { position: fixed; left: 0; right: 0; top: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  background: var(--danger); color: #fff; font-size: .9rem;
  padding: .5rem .8rem; padding-top: max(.5rem, env(safe-area-inset-top)); }
#conn .dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; animation: blink 1.2s infinite; }
@keyframes blink { 0%,100% { opacity: 1 } 50% { opacity: .25 } }
.conn-retry { background: #fff2; color: #fff; border: 1px solid #fff8;
  border-radius: 6px; padding: .15rem .5rem; font-size: .85rem; cursor: pointer; }

/* Modal-Overlay (Figuren-Picker) */
#modal { position: fixed; inset: 0; z-index: 65; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: #000a; opacity: 0; pointer-events: none; transition: opacity .15s; }
#modal.show { opacity: 1; pointer-events: auto; }
.modal-card { background: var(--panel); border: 1px solid var(--gold); border-radius: var(--radius);
  padding: 1rem; max-width: 92%; text-align: center; box-shadow: 0 12px 44px #000b; }
.modal-card h3 { color: var(--gold); margin-top: .2rem; }

/* Toast */
#toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%) translateY(2rem);
  background: #000d; color: #fff; padding: .6rem 1rem; border-radius: 999px; font-size: .9rem;
  opacity: 0; transition: all .25s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Ansage-Overlay für Gruppen-/Fremd-Aktionen (z. B. "Alle leeren ihr Glas!") */
#announce { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center;
  justify-content: center; padding: 1rem; opacity: 0; pointer-events: none; transition: opacity .18s; }
#announce.show { opacity: 1; pointer-events: auto; }
.ann-card { display: flex; align-items: center; gap: .8rem; max-width: 90%;
  background: rgba(20,20,26,.94); border: 2px solid var(--gold); border-radius: 16px;
  padding: 1rem 1.4rem; box-shadow: 0 12px 44px #000b; animation: annpop .22s ease; }
.ann-ico { font-size: 2.1rem; line-height: 1; }
.ann-txt { font-size: 1.35rem; font-weight: 700; color: var(--text); }
.ann-card { flex-wrap: wrap; justify-content: center; }
.ann-card.big { border-color: var(--gold-2); }
.ann-card.big .ann-txt { font-size: 1.7rem; color: var(--gold-2); }
.ann-close { flex: 0 0 100%; margin-top: .3rem; background: var(--gold); color: #1a1a1a;
  border: none; border-radius: 8px; padding: .5rem 1rem; font-size: 1rem; font-weight: 600; cursor: pointer; }
.btn.small { padding: .35rem .7rem; font-size: .85rem; align-self: center; }
@keyframes annpop { 0% { transform: scale(.82); opacity: .3 } 100% { transform: scale(1); opacity: 1 } }
@media (prefers-reduced-motion: reduce) { .ann-card { animation: none; } }

/* Ab Tablet/Desktop: grosses, zentriertes Board neben dem HUD */
@media (min-width: 820px) {
  .game { display: grid; grid-template-columns: minmax(360px, 620px) minmax(280px, 1fr);
    gap: 1.4rem; align-items: start; }
  .board-wrap { position: sticky; top: 1rem; }
  /* Board bleibt quadratisch und passt immer auf den Bildschirm (Höhe begrenzt) */
  .board { max-width: min(100%, 74vh); margin-inline: auto; }
}
