/* ============================================================
   Dice Duel - modernes, minimalistisches Game-UI
   Animationen laufen ausschliesslich ueber transform/opacity.
   ============================================================ */

:root {
  --bg: #0b0d12;
  --bg-soft: #10141d;
  --surface: #151a25;
  --surface-2: #1b2130;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #eef1f8;
  --muted: #8e97ad;
  --accent: #6c5cff;
  --accent-2: #2ee6c5;
  --gold: #ffc857;
  --pink: #ff5d8f;
  --good: #38d39f;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 18px 40px rgba(0, 0, 0, .45);
  --ease: cubic-bezier(.22, .8, .3, 1);
  --sp: clamp(12px, 2.2vw, 20px);
}

* { box-sizing: border-box; }

/* [hidden] muss auch bei display:grid/flex greifen. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  background-image:
    radial-gradient(720px 480px at 12% -8%, rgba(108, 92, 255, .20), transparent 60%),
    radial-gradient(680px 460px at 92% 0%, rgba(46, 230, 197, .12), transparent 60%);
  background-attachment: fixed;
}

h1, h2, h3, .num, .brand__name, .roomcode, .target__value {
  font-family: "Space Grotesk", Inter, system-ui, sans-serif;
}

.muted { color: var(--muted); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }

/* ------------------------------------------------------------ Screens */
.screen { display: none; min-height: 100dvh; }
.screen.is-active { display: block; }
.screen--center.is-active {
  display: grid;
  place-items: center;
  padding: var(--sp);
}
.screen.is-active > * { animation: screenIn .32s var(--ease) both; }

@keyframes screenIn {
  from { opacity: 0; transform: translate3d(0, 14px, 0); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- Card */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(20px, 3vw, 30px);
}

/* ----------------------------------------------------------- Erklaerung */
.tip {
  position: fixed; top: 0; left: 0; z-index: 90;
  max-width: min(280px, calc(100vw - 20px));
  display: grid; gap: 3px;
  padding: 10px 13px; border-radius: 12px;
  background: rgba(27, 33, 48, .98);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  font-size: 12.5px; line-height: 1.45; color: var(--muted);
  pointer-events: none;
  opacity: 0; transform-origin: center bottom;
  transition: opacity .14s var(--ease);
  will-change: transform, opacity;
}
.tip.is-on { opacity: 1; }
.tip b { color: var(--text); font-size: 13px; font-weight: 600; }

/* --------------------------------------------------------------- Home */
.home { width: min(440px, 100%); display: grid; gap: 22px; }
.home__head { text-align: center; display: grid; gap: 12px; justify-items: center; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand__name { margin: 0; font-size: clamp(30px, 6vw, 40px); letter-spacing: -.02em; }
.brand__mark {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--accent), #8f7bff);
  box-shadow: 0 8px 22px rgba(108, 92, 255, .45);
  display: inline-block;
  animation: markFloat 4s ease-in-out infinite;
}
.brand__mark--sm { width: 28px; height: 28px; border-radius: 9px; animation: none; }
.brand__mark i {
  position: absolute; width: 7px; height: 7px; border-radius: 50%; background: #fff;
}
.brand__mark--sm i { width: 5px; height: 5px; }
.brand__mark i:nth-child(1) { top: 22%; left: 22%; transform: translate(-50%, -50%); }
.brand__mark i:nth-child(2) { top: 50%; left: 50%; transform: translate(-50%, -50%); }
.brand__mark i:nth-child(3) { top: 78%; left: 78%; transform: translate(-50%, -50%); }

@keyframes markFloat {
  0%, 100% { transform: translate3d(0, 0, 0) rotate(0); }
  50%      { transform: translate3d(0, -5px, 0) rotate(6deg); }
}

.home__tagline { margin: 0; color: var(--muted); line-height: 1.6; font-size: 15px; }
.home__card { display: grid; gap: 14px; }
.field { display: grid; gap: 7px; }
.field__label { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

.input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  outline: none;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(108, 92, 255, .18); }
.input--code { letter-spacing: .3em; text-transform: uppercase; font-family: "Space Grotesk", monospace; }

.divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--line); }

.form-error { min-height: 18px; margin: 0; color: var(--pink); font-size: 13px; }

/* -------------------------------------------------------------- Button */
.btn {
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-weight: 600;
  letter-spacing: .01em;
  background: var(--surface-2);
  border: 1px solid var(--line);
  transition: transform .14s var(--ease), background .18s var(--ease), border-color .18s var(--ease), opacity .18s var(--ease);
  will-change: transform;
}
.btn:hover { border-color: var(--line-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn--lg { padding: 15px 20px; font-size: 16px; }
.btn--primary {
  background: linear-gradient(135deg, var(--accent), #8b78ff);
  border-color: transparent;
  box-shadow: 0 10px 26px rgba(108, 92, 255, .35);
}
.btn--primary:hover:not(:disabled) { filter: brightness(1.07); }
.btn--ghost { background: rgba(255,255,255,.03); }
.btn--quiet { background: none; border-color: transparent; color: var(--muted); }
.btn--quiet:hover { color: var(--text); }
.btn--shop {
  background: linear-gradient(135deg, rgba(255,200,87,.16), rgba(255,200,87,.06));
  border-color: rgba(255, 200, 87, .35);
  color: var(--gold);
  padding: 10px 16px;
}
.btn--roll {
  background: linear-gradient(135deg, var(--accent-2), #3ad0ff);
  color: #06231f;
  border-color: transparent;
  font-size: 16px;
  padding: 16px 30px;
  box-shadow: 0 12px 30px rgba(46, 230, 197, .28);
  min-width: 160px;
}
.btn--roll:disabled { box-shadow: none; }

/* -------------------------------------------------------------- Lobby */
.lobby { width: min(420px, 100%); display: grid; gap: 18px; text-align: center; justify-items: center; }
.lobby__hint { margin: 0; color: var(--muted); font-size: 14px; }
.roomcode {
  font-size: clamp(38px, 11vw, 56px);
  letter-spacing: .16em;
  font-weight: 700;
  padding: 10px 18px 10px 26px;
  border-radius: var(--radius);
  border: 1px dashed var(--line-strong);
  background: rgba(108, 92, 255, .08);
  transition: transform .16s var(--ease), background .2s var(--ease);
}
.roomcode:active { transform: scale(.97); }
.roomcode.is-copied { background: rgba(46, 230, 197, .16); }
.lobby__players { display: grid; gap: 8px; width: 100%; }
.lobby__player {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px;
  background: rgba(255,255,255,.02); color: var(--muted);
}
.lobby__player.is-ready { color: var(--text); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.is-ready .dot { background: var(--good); box-shadow: 0 0 0 4px rgba(56, 211, 159, .16); }
.lobby__wait { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--accent);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.5); opacity: .45; }
}

/* ------------------------------------------------------------- Topbar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px var(--sp);
  background: rgba(11, 13, 18, .82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar__left, .topbar__mid, .topbar__right { display: flex; align-items: center; gap: 10px; }
.topbar__title { font-weight: 600; letter-spacing: -.01em; }
.chip {
  display: inline-flex; align-items: baseline; gap: 5px;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 13px; font-size: 13px; background: rgba(255,255,255,.03);
}
.chip__sub { color: var(--muted); font-size: 12px; }
.chip--code { letter-spacing: .18em; font-family: "Space Grotesk", monospace; font-weight: 600; transition: transform .14s var(--ease); }
.chip--code:active { transform: scale(.95); }
.chip--code.is-copied { border-color: var(--accent-2); color: var(--accent-2); }

/* -------------------------------------------------------------- Board */
.board {
  max-width: 1180px; margin: 0 auto;
  padding: var(--sp);
  display: grid; gap: var(--sp);
}

/* ------------------------------------------------------------ Players */
.players { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp); }

.pcard {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  padding: 14px 16px;
  display: grid; gap: 10px;
  transition: border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease);
  overflow: hidden;
}
.pcard::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(135deg, rgba(108,92,255,.16), transparent 55%);
  opacity: 0; transition: opacity .3s var(--ease); pointer-events: none;
}
.pcard.is-active { border-color: rgba(108, 92, 255, .55); box-shadow: 0 0 0 1px rgba(108,92,255,.25), 0 14px 34px rgba(108,92,255,.16); }
.pcard.is-active::before { opacity: 1; }
.pcard.is-you .pcard__name::after {
  content: "DU"; margin-left: 8px; font-size: 10px; letter-spacing: .1em;
  color: var(--accent-2); border: 1px solid rgba(46,230,197,.4); border-radius: 6px; padding: 2px 5px;
  vertical-align: middle;
}
.pcard__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.pcard__name { font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.pcard__name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pcard__turnbadge {
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--accent); border: 1px solid rgba(108,92,255,.45); border-radius: 999px; padding: 3px 8px;
  opacity: 0; transform: translate3d(0,-3px,0); transition: opacity .22s var(--ease), transform .22s var(--ease);
}
.pcard.is-active .pcard__turnbadge { opacity: 1; transform: none; }
.pcard__stats { display: flex; gap: 18px; align-items: baseline; }
.stat { display: grid; gap: 2px; }
.stat__label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.stat__value { font-family: "Space Grotesk", sans-serif; font-size: clamp(20px, 3.4vw, 26px); font-weight: 700; line-height: 1; }
.stat__value.is-money { color: var(--gold); }
.stat--bump { animation: bump .42s var(--ease); }
@keyframes bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.streak {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--gold);
  border: 1px solid rgba(255, 200, 87, .35); border-radius: 999px; padding: 4px 10px;
  background: rgba(255, 200, 87, .08);
  opacity: 0; transform: scale(.9); transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.streak.is-on { opacity: 1; transform: none; animation: streakPop .4s var(--ease); }
.streak.is-hot { color: #fff; background: linear-gradient(135deg, var(--pink), var(--gold)); border-color: transparent; }
@keyframes streakPop {
  0%   { transform: scale(.7); }
  55%  { transform: scale(1.14); }
  100% { transform: scale(1); }
}

.pcard__potions { display: flex; flex-wrap: wrap; gap: 5px; min-height: 22px; }
.pcard__potions:empty { min-height: 0; }
.potion-chip {
  font-size: 11px; border-radius: 7px; padding: 3px 7px;
  background: rgba(46, 230, 197, .1); border: 1px solid rgba(46, 230, 197, .28); color: var(--accent-2);
  animation: chipIn .3s var(--ease) both;
}
@keyframes chipIn {
  from { opacity: 0; transform: scale(.8); }
  to   { opacity: 1; transform: none; }
}
.pcard__dicecount { font-size: 11px; color: var(--muted); }

/* -------------------------------------------------------------- Stage */
.stage {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(21,26,37,.9), rgba(16,20,29,.9));
  padding: clamp(16px, 2.6vw, 26px);
  display: grid; gap: clamp(16px, 2.4vw, 24px);
}
/* Eine Zeile sagt, wer dran ist und was zu tun ist. */
.stage__head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 16px 8px 8px;
  background: rgba(255,255,255,.02);
  transition: border-color .25s var(--ease), background .25s var(--ease);
}
.stage__head.is-you {
  border-color: rgba(46, 230, 197, .38);
  background: linear-gradient(90deg, rgba(46,230,197,.12), rgba(46,230,197,.02));
}
.turn-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; flex: none;
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 13px;
  background: linear-gradient(145deg, var(--accent), #8f7bff); color: #fff;
}
.stage__head.is-you .turn-avatar { background: linear-gradient(145deg, var(--accent-2), #3ad0ff); color: #06231f; }
.turn-line { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.stage__head.is-you .turn-line { color: var(--accent-2); }
.turn-line.is-switch { animation: switchIn .4s var(--ease); }
.turn-step { color: var(--muted); font-size: 14px; }
.stage__head.is-you .turn-step { color: var(--text); }
@keyframes switchIn {
  from { opacity: 0; transform: translate3d(10px, 0, 0); }
  to   { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------ Targets */
.targets { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 1.6vw, 16px); }

.target {
  position: relative;
  aspect-ratio: 1 / 0.88;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface-2), rgba(21,26,37,.6));
  display: grid; place-items: center; gap: 2px;
  padding: 6px 4px 22px;
  transition: transform .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease), opacity .2s var(--ease);
  will-change: transform;
  animation: targetIn .34s var(--ease) both;
  overflow: hidden;
}
@keyframes targetIn {
  from { opacity: 0; transform: translate3d(0, 12px, 0) scale(.94); }
  to   { opacity: 1; transform: none; }
}
.target__value { font-size: clamp(30px, 7vw, 52px); font-weight: 700; line-height: 1; }
.target__tag {
  position: absolute; bottom: 8px; left: 4px; right: 4px;
  font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.target.is-selectable { cursor: pointer; border-color: rgba(108, 92, 255, .35); }
.target.is-selectable:hover { transform: translate3d(0, -4px, 0); }
/* Atmender Glow - animiert nur opacity, bleibt also billig. */
.target.is-selectable::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 26px rgba(108, 92, 255, .38);
  animation: breathe 1.9s ease-in-out infinite;
}
.target.is-selectable:hover::before { animation-duration: 1.1s; }
@keyframes breathe {
  0%, 100% { opacity: .3; }
  50%      { opacity: 1; }
}
.target.is-picked {
  border-color: var(--accent); color: #fff;
  box-shadow: 0 0 0 1px var(--accent), 0 16px 34px rgba(108,92,255,.3);
  transform: translate3d(0, -4px, 0);
}
.target.is-picked .target__tag { color: var(--accent); }
.target.is-locked { opacity: .34; }
.target.is-locked .target__value { text-decoration: line-through; text-decoration-thickness: 2px; }
.target.is-enchanted {
  border-color: rgba(255, 200, 87, .42);
  background:
    radial-gradient(120% 80% at 50% -20%, rgba(255, 200, 87, .16), transparent 62%),
    linear-gradient(180deg, var(--surface-2), rgba(21,26,37,.6));
  box-shadow: inset 0 0 24px rgba(255, 200, 87, .07);
}
.target.is-enchanted .target__value {
  background: linear-gradient(135deg, var(--gold), #fff1c2);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.target.is-enchanted::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 100%;
  background: linear-gradient(115deg, transparent 38%, rgba(255, 236, 190, .13) 50%, transparent 62%);
  transform: translate3d(-120%, 0, 0);
  animation: sheen 3.6s ease-in-out infinite;
  pointer-events: none;
}
@keyframes sheen {
  0%, 55% { transform: translate3d(-120%, 0, 0); }
  100%    { transform: translate3d(120%, 0, 0); }
}
.target.is-enchanted .target__tag { color: var(--gold); }

/* ---------------------------------------------------------- Roll stage */
.rollstage { display: grid; gap: 14px; justify-items: center; min-height: 122px; align-content: center; }

.dicecubes { display: flex; gap: 14px; justify-content: center; min-height: 64px; align-items: center; }
.cube {
  width: 62px; height: 62px; border-radius: 16px;
  background: linear-gradient(160deg, #ffffff, #dfe3f2);
  color: #12151f;
  display: grid; place-items: center;
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 28px;
  box-shadow: 0 12px 26px rgba(0,0,0,.4), inset 0 -3px 0 rgba(0,0,0,.09);
  will-change: transform;
}
.cube--special { background: linear-gradient(160deg, #ffe9ae, #ffc857); }
.cube.is-rolling { animation: tumble .52s var(--ease); }
@keyframes tumble {
  0%   { transform: translate3d(0,0,0) rotate(0) scale(1); }
  25%  { transform: translate3d(0,-16px,0) rotate(-18deg) scale(1.06); }
  55%  { transform: translate3d(0,4px,0) rotate(14deg) scale(.96); }
  80%  { transform: translate3d(0,-4px,0) rotate(-6deg) scale(1.02); }
  100% { transform: none; }
}
.cube__note {
  position: absolute; margin-top: 74px; font-size: 10px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--accent-2);
}
.cube-wrap { position: relative; display: grid; place-items: center; }

.rollresult { display: grid; gap: 8px; justify-items: center; animation: resultIn .3s var(--ease) both; }
@keyframes resultIn {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to   { opacity: 1; transform: none; }
}
.rollresult__total {
  font-family: "Space Grotesk", sans-serif; font-size: clamp(34px, 7vw, 46px); font-weight: 700; line-height: 1;
}
.rollresult__label { font-size: 14px; font-weight: 600; letter-spacing: .02em; }
.rollresult.is-perfect .rollresult__total {
  background: linear-gradient(135deg, #ffe9a8, var(--gold) 55%, #ffa63d);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: perfectPop .5s var(--ease);
}
@keyframes perfectPop {
  0%   { transform: scale(.7); }
  50%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}
.rollresult__gains { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.gain {
  font-weight: 700; font-size: 14px; border-radius: 999px; padding: 5px 12px;
  border: 1px solid var(--line); background: rgba(255,255,255,.03);
  animation: gainIn .34s var(--ease) both;
}
.gain--points { color: var(--accent-2); border-color: rgba(46,230,197,.3); }
.gain--money { color: var(--gold); border-color: rgba(255,200,87,.3); animation-delay: .06s; }
@keyframes gainIn {
  from { opacity: 0; transform: translate3d(0, 10px, 0) scale(.9); }
  to   { opacity: 1; transform: none; }
}
.rollresult__effects { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: 640px; }
.effect {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 7px; padding: 3px 8px;
  animation: chipIn .3s var(--ease) both;
}
.effect b { color: var(--text); font-weight: 600; }

/* Kurzer Perfect-Blitz, keine Dauerpartikel. */
.flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 60;
  background: radial-gradient(420px 320px at 50% 46%, rgba(255,200,87,.34), transparent 70%);
  animation: flashOut .5s var(--ease) forwards;
}
@keyframes flashOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.spark {
  position: fixed; z-index: 61; width: 8px; height: 8px; border-radius: 50%;
  pointer-events: none; will-change: transform, opacity;
  animation: sparkOut .62s var(--ease) forwards;
}
@keyframes sparkOut {
  from { transform: translate3d(0,0,0) scale(1); opacity: 1; }
  to   { transform: translate3d(var(--dx), var(--dy), 0) scale(.2); opacity: 0; }
}

/* ---------------------------------------------------------- Actionbar */
.actionbar {
  display: flex; gap: var(--sp); align-items: flex-end; justify-content: space-between;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  padding: 14px 16px;
  flex-wrap: wrap;
}
.actionbar__dice { flex: 1 1 320px; display: grid; gap: 10px; align-content: start; }
.actionbar__title {
  font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.dice-hint {
  font-family: "Space Grotesk", sans-serif; letter-spacing: 0;
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 11px;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.dice-hint.is-live { color: var(--accent-2); border-color: rgba(46, 230, 197, .4); }
.tip-hint {
  font-size: 10px; letter-spacing: .04em; text-transform: none; color: var(--muted); opacity: .7;
  border: 1px dashed var(--line-strong); border-radius: 999px; padding: 2px 8px;
}
.dicetray { display: flex; gap: 9px; flex-wrap: wrap; }

.die-btn {
  position: relative;
  min-width: 74px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  padding: 9px 11px;
  display: grid; gap: 3px; justify-items: start;
  transition: transform .14s var(--ease), border-color .18s var(--ease), background .18s var(--ease);
  will-change: transform;
}
.die-btn:hover:not(:disabled) { transform: translate3d(0,-3px,0); border-color: var(--line-strong); }
.die-btn:disabled { opacity: .45; cursor: not-allowed; }
.die-btn__icon {
  font-family: "Space Grotesk", sans-serif; font-weight: 700; font-size: 15px;
}
.die-btn__name { font-size: 11px; color: var(--muted); white-space: nowrap; }
.die-btn.is-selected {
  border-color: var(--accent-2);
  background: linear-gradient(160deg, rgba(46,230,197,.16), rgba(46,230,197,.04));
  box-shadow: 0 0 0 1px rgba(46,230,197,.4);
}
.die-btn.is-selected .die-btn__name { color: var(--accent-2); }
.die-btn__order {
  position: absolute; top: -7px; right: -7px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--accent-2); color: #06231f;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
  animation: chipIn .2s var(--ease) both;
}

/* ---------------------------------------------------------------- Log */
.log {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(255,255,255,.015);
  padding: 12px 14px;
  max-height: 148px; overflow-y: auto;
  display: grid; gap: 6px;
  font-size: 12.5px; color: var(--muted);
  scrollbar-width: thin;
}
.log__row { animation: logIn .26s var(--ease) both; }
.log__row b { color: var(--text); font-weight: 600; }
.log__row.is-p0 b { color: #9b8cff; }
.log__row.is-p1 b { color: var(--accent-2); }
@keyframes logIn {
  from { opacity: 0; transform: translate3d(-6px, 0, 0); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- Shop */
.shop { position: fixed; inset: 0; z-index: 40; }
.shop__backdrop {
  position: absolute; inset: 0; background: rgba(5, 7, 11, .6);
  backdrop-filter: blur(3px);
  animation: fadeIn .22s var(--ease) both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.shop__panel {
  position: absolute; top: 0; right: 0; height: 100%;
  width: min(460px, 100%);
  background: linear-gradient(180deg, var(--surface), var(--bg-soft));
  border-left: 1px solid var(--line);
  display: grid; grid-template-rows: auto auto 1fr;
  animation: slideIn .28s var(--ease) both;
  will-change: transform;
}
@keyframes slideIn {
  from { transform: translate3d(100%, 0, 0); }
  to   { transform: none; }
}
.shop.is-closing .shop__panel { animation: slideOut .2s var(--ease) both; }
.shop.is-closing .shop__backdrop { animation: fadeIn .2s var(--ease) reverse both; }
@keyframes slideOut { to { transform: translate3d(100%, 0, 0); } }

.shop__head {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  padding: 18px var(--sp); border-bottom: 1px solid var(--line);
}
.shop__head h2 { margin: 0; font-size: 20px; }
.shop__money { font-family: "Space Grotesk", sans-serif; font-weight: 700; color: var(--gold); font-size: 20px; }
.shop__close { color: var(--muted); font-size: 16px; padding: 6px 8px; border-radius: 8px; }
.shop__close:hover { color: var(--text); background: rgba(255,255,255,.05); }

.tabs { display: flex; gap: 6px; padding: 12px var(--sp) 0; }
.tab {
  border-radius: 999px; padding: 8px 15px; font-size: 13px; font-weight: 600;
  color: var(--muted); border: 1px solid transparent;
  transition: color .18s var(--ease), background .18s var(--ease), border-color .18s var(--ease);
}
.tab.is-active { color: var(--text); background: rgba(255,255,255,.06); border-color: var(--line); }

.shop__list { overflow-y: auto; padding: 14px var(--sp) 26px; display: grid; gap: 9px; align-content: start; }

.item {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.02);
  padding: 11px 12px;
  transition: border-color .18s var(--ease), transform .18s var(--ease);
}
.item:hover { border-color: var(--line-strong); }
.item.is-owned { opacity: .55; }
.item.is-bought { animation: bought .45s var(--ease); }
@keyframes bought {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(46,230,197,.5); }
  40%  { transform: scale(1.02); box-shadow: 0 0 0 3px rgba(46,230,197,.28); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(46,230,197,0); }
}
.item__icon {
  width: 42px; height: 42px; border-radius: 11px;
  display: grid; place-items: center;
  font-family: "Space Grotesk", sans-serif; font-weight: 700;
  background: linear-gradient(160deg, rgba(108,92,255,.3), rgba(108,92,255,.08));
  border: 1px solid rgba(108,92,255,.28);
  font-size: 14px;
}
.item--potion .item__icon {
  background: linear-gradient(160deg, rgba(46,230,197,.26), rgba(46,230,197,.06));
  border-color: rgba(46,230,197,.28);
}
.item__body { min-width: 0; display: grid; gap: 2px; }
.item__name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 7px; }
.item__tag {
  font-size: 9px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
  border: 1px solid var(--line); border-radius: 5px; padding: 2px 5px;
}
.item__desc { font-size: 12px; color: var(--muted); line-height: 1.4; }
.item__buy {
  border-radius: 10px; padding: 9px 13px; font-size: 13px; font-weight: 700;
  background: rgba(255,200,87,.12); border: 1px solid rgba(255,200,87,.3); color: var(--gold);
  transition: transform .14s var(--ease), background .18s var(--ease);
  white-space: nowrap;
}
.item__buy:hover:not(:disabled) { background: rgba(255,200,87,.2); }
.item__buy:active:not(:disabled) { transform: scale(.94); }
.item__buy:disabled { opacity: .45; cursor: not-allowed; }
.item__owned { font-size: 12px; color: var(--accent-2); font-weight: 600; white-space: nowrap; }

/* ------------------------------------------------------------- Result */
.result { width: min(520px, 100%); display: grid; gap: 16px; justify-items: center; text-align: center; }
.result__crown { font-size: 46px; animation: crownIn .5s var(--ease) both; }
@keyframes crownIn {
  0%   { opacity: 0; transform: translate3d(0,-14px,0) scale(.6); }
  60%  { transform: translate3d(0,0,0) scale(1.12); }
  100% { opacity: 1; transform: none; }
}
.result__title { margin: 0; font-size: clamp(24px, 5vw, 32px); }
.result__scores { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; width: 100%; }
.result__side { display: grid; gap: 4px; }
.result__side .name { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.result__side .pts { font-family: "Space Grotesk", sans-serif; font-size: 34px; font-weight: 700; }
.result__side.is-winner .pts { color: var(--gold); }
.result__vs { color: var(--muted); font-size: 12px; }
.result__stats { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; font-size: 12px; color: var(--muted); }
.result__stats span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; }
.result__actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

/* ------------------------------------------------------------- Toasts */
.toasts {
  position: fixed; z-index: 80; left: 50%; top: 70px; transform: translateX(-50%);
  display: grid; gap: 8px; width: max-content; max-width: min(92vw, 420px); pointer-events: none;
}
.toast {
  border-radius: 12px; padding: 10px 15px; font-size: 13.5px; font-weight: 500;
  background: rgba(27, 33, 48, .96); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: toastIn .26s var(--ease) both;
}
.toast.is-error { border-color: rgba(255, 93, 143, .5); color: #ffc2d4; }
.toast.is-good { border-color: rgba(46, 230, 197, .45); color: #b6fff0; }
.toast.is-out { animation: toastOut .22s var(--ease) both; }
@keyframes toastIn {
  from { opacity: 0; transform: translate3d(0,-12px,0) scale(.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes toastOut {
  to { opacity: 0; transform: translate3d(0,-10px,0) scale(.97); }
}

/* --------------------------------------------------------- Responsive */
@media (max-width: 720px) {
  .players { grid-template-columns: 1fr; }
  .topbar__title { display: none; }
  .actionbar { flex-direction: column; align-items: stretch; }
  /* In der Spalte darf die Flex-Basis nicht als Hoehe wirken. */
  .actionbar__dice { flex: 0 0 auto; }
  .rollstage { min-height: 84px; }
  .target__tag { font-size: 8.5px; letter-spacing: 0; bottom: 6px; }
  .target { padding-bottom: 18px; }
  .stage__head { padding: 7px 12px 7px 7px; gap: 9px; }
  .turn-line, .turn-step { font-size: 13.5px; }
  .btn--roll { width: 100%; }
  .targets { gap: 8px; }
  .cube { width: 52px; height: 52px; font-size: 23px; border-radius: 13px; }
  .log { max-height: 112px; }
  .toasts { top: 62px; }
}

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