/* ===== Farben & Grundwerte ===== */
:root {
  --bg: #0d0e11;
  --panel: #17191e;
  --panel-edge: #262a31;
  --text: #e9e6df;
  --muted: #8a8f99;

  --active-bg: #f1e9d8;      /* helles "Elfenbein" für den Spieler am Zug */
  --active-text: #16171b;
  --accent: #d9a84e;         /* Messing/Gold */
  --danger: #ff4d4d;
  --win: #5cc98a;

  --radius: 28px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background:
    radial-gradient(ellipse at 50% 50%, #1c1f26 0%, var(--bg) 70%);
  color: var(--text);
  font-family: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 3D-Hintergrund ===== */
#bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
}

/* Alles andere liegt über dem 3D-Canvas */
.player,
.controls {
  position: relative;
  z-index: 1;
}

/* ===== Spielerflächen (Glas-Look, damit das Brett durchscheint) ===== */
.player {
  position: relative;
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  background:
    linear-gradient(160deg, rgba(255,255,255,0.06), transparent 60%),
    rgba(23, 25, 30, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  /* Achtung: KEIN transition auf transform – das macht GSAP */
  transition: background 0.35s, color 0.35s, box-shadow 0.35s, border-color 0.35s;
}

.inner {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px 24px 28px;
}

/* Der obere Spieler sieht seinen Inhalt richtig herum */
.player.top .inner {
  transform: rotate(180deg);
}

.head {
  position: absolute;
  top: 18px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--muted);
  transition: color 0.35s;
}

.piece {
  font-size: 1.6rem;
  line-height: 1;
  display: inline-block;
}

.name {
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
}

.moves {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}

.time {
  display: inline-block;
  font-size: clamp(3.5rem, 20vw, 10rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.status {
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-height: 1.2em;
  transition: color 0.35s;
}

/* Fortschrittsbalken: wie viel Zeit ist noch übrig */
.bar {
  position: absolute;
  left: 24px;
  right: 24px;
  bottom: 18px;
  height: 4px;
  border-radius: 4px;
  background: rgba(127, 127, 127, 0.18);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform-origin: left center;
  transition: transform 0.1s linear, background 0.35s;
}

/* "+2s" das beim Zeitbonus hochschwebt */
.bonus {
  position: absolute;
  top: 50%;
  right: 12%;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
}

/* ===== Zustände ===== */

/* Am Zug: helle Fläche mit Messing-Rand */
.player.active {
  background: rgba(241, 233, 216, 0.82);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--active-text);
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(217, 168, 78, 0.25),
    0 20px 60px -20px rgba(217, 168, 78, 0.45);
}
.player.active .head,
.player.active .status {
  color: rgba(22, 23, 27, 0.55);
}
.player.active .bonus {
  color: #9a6f1f;
}

/* Weniger als 10 Sekunden */
.player.low .time {
  color: var(--danger);
}
.player.low .bar-fill {
  background: var(--danger);
}
.player.active.low {
  border-color: var(--danger);
  box-shadow:
    0 0 0 3px rgba(255, 77, 77, 0.3),
    0 20px 60px -20px rgba(255, 77, 77, 0.6);
}

/* Zeit abgelaufen */
.player.lost {
  background: rgba(42, 18, 20, 0.7);
  border-color: var(--danger);
  color: var(--danger);
}
.player.lost .status { color: var(--danger); }

/* Gewonnen */
.player.won {
  border-color: var(--win);
  box-shadow: 0 0 0 3px rgba(92, 201, 138, 0.25);
}
.player.won .status { color: var(--win); }

/* Pausiert: beide Flächen etwas gedimmt */
body.paused .player {
  opacity: 0.55;
}

/* ===== Steuerleiste ===== */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.icon-btn,
.select-wrap {
  height: 48px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(23, 25, 30, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--text);
}

.icon-btn {
  width: 48px;
  font-size: 1.3rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.2s, border-color 0.2s;
}
.icon-btn:hover {
  border-color: var(--accent);
}

.select-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.select-wrap::after {
  content: '▾';
  position: absolute;
  right: 16px;
  color: var(--muted);
  pointer-events: none;
}

select {
  appearance: none;
  -webkit-appearance: none;
  height: 100%;
  padding: 0 40px 0 20px;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
select option {
  background: var(--panel);
  color: var(--text);
}

/* Sichtbarer Fokus für Tastatur-Bedienung */
button:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
