@font-face {
  font-family: "Saira";
  src: url("/fonts/saira.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Saira Condensed";
  src: url("/fonts/saira-condensed-600.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Saira Condensed";
  src: url("/fonts/saira-condensed-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

/* Bewusst nur dunkel: am Spieltisch blendet nichts, und die Statusleiste
   am iPhone (black-translucent) hat immer helle Schrift. */
:root {
  color-scheme: dark;
  --ground: #0B0D12;
  --ink: #F2F3F7;
  --muted: #959BAA;
  --danger: #FF5C66;

  /* Spieler 1, unten: Blau */
  --p1: #6C98FF;
  --p1-ground: #0F1830;
  --p1-key: #172447;
  --p1-line: #273B6E;
  --p1-press: #213366;

  /* Spieler 2, oben: Gold */
  --p2: #F2B544;
  --p2-ground: #1E1608;
  --p2-key: #30240D;
  --p2-line: #4D3A16;
  --p2-press: #423214;

  --condensed: "Saira Condensed", "Arial Narrow", system-ui, sans-serif;
  --sans: "Saira", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
}
body {
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.p1 { --c: var(--p1); --c-ground: var(--p1-ground); --c-key: var(--p1-key); --c-line: var(--p1-line); --c-press: var(--p1-press); }
.p2 { --c: var(--p2); --c-ground: var(--p2-ground); --c-key: var(--p2-key); --c-line: var(--p2-line); --c-press: var(--p2-press); }

/* ── Neues Duell ─────────────────────────────────────────────── */

.setup {
  height: 100%;
  overflow-y: auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 32px)
    max(20px, env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + 24px)
    max(20px, env(safe-area-inset-left, 0px));
}
.setup-inner {
  max-width: 440px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.setup h1 {
  margin: 0;
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 44px;
  line-height: 1;
  letter-spacing: .01em;
}
.hint {
  margin: -6px 0 8px;
  color: var(--muted);
  font-size: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: var(--c-ground);
  cursor: text;
}
.field:focus-within { border-color: var(--c); }
.field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--c);
}
.field input {
  appearance: none;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: 600 24px/1.25 var(--sans);
  outline: none;
}
.field input::placeholder { color: var(--muted); opacity: .6; }

.start {
  margin-top: 8px;
  height: 60px;
  border: 0;
  border-radius: 14px;
  background: var(--ink);
  color: var(--ground);
  font-family: var(--condensed);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
}
.start:active { transform: scale(.98); }
.back {
  padding: 10px;
  border: 0;
  background: none;
  color: var(--ink);
  font-size: 16px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}
.footnote {
  margin: 4px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Duell ───────────────────────────────────────────────────── */

.duel {
  height: 100%;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}

.player {
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 2vh, 18px);
  padding-inline: max(16px, env(safe-area-inset-left, 0px)) max(16px, env(safe-area-inset-right, 0px));
  background: var(--c-ground);
  transition: transform .4s ease;
}
.player.top {
  padding-top: calc(env(safe-area-inset-top, 0px) + 14px);
  padding-bottom: 14px;
}
.player.bottom {
  padding-top: 14px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 14px);
}
/* Gedreht liegt die eigene Unterkante oben am Bildschirmrand,
   also wandert der Abstand zur Statusleiste mit. */
.player.top.flipped {
  transform: rotate(180deg);
  padding-top: 14px;
  padding-bottom: calc(env(safe-area-inset-top, 0px) + 14px);
}

.who {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
}
.who-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--c);
}
.chip {
  flex: none;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.chip.lost { color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger); }
.chip.won { color: var(--ground); background: var(--c); }

.score {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: .25em;
}
.tag {
  font-family: var(--condensed);
  font-weight: 700;
  font-size: clamp(16px, 4.6vw, 26px);
  letter-spacing: .06em;
  color: var(--c);
}
.lp {
  font-family: var(--condensed);
  font-weight: 700;
  font-size: clamp(56px, min(30vw, 15vh), 180px);
  line-height: .9;
  font-variant-numeric: tabular-nums;
}
.player.out .lp { color: var(--danger); }

.delta {
  position: absolute;
  right: 0;
  bottom: 92%;
  font-family: var(--condensed);
  font-weight: 700;
  font-size: clamp(18px, 5vw, 28px);
  font-variant-numeric: tabular-nums;
  color: var(--danger);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .6s ease, transform .6s ease;
  pointer-events: none;
}
.delta.show {
  opacity: 1;
  transform: none;
  transition: opacity .1s ease, transform .1s ease;
}

.keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  width: 100%;
  max-width: 540px;
}
.key {
  appearance: none;
  height: clamp(50px, 8vh, 70px);
  padding: 0;
  border: 1px solid var(--c-line);
  border-radius: 12px;
  background: var(--c-key);
  color: var(--ink);
  font-family: var(--condensed);
  font-weight: 600;
  font-size: clamp(17px, 5vw, 23px);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  transition: transform .08s ease, background-color .08s ease;
}
.key:active { background: var(--c-press); transform: scale(.96); }
.key:disabled { opacity: .3; cursor: default; }

.bar {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px max(12px, env(safe-area-inset-right, 0px)) 8px max(12px, env(safe-area-inset-left, 0px));
  background: var(--ground);
}
.bar button {
  appearance: none;
  padding: 11px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: .08em;
  text-transform: uppercase;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}
.bar button:active { background: #1B1E27; }
.bar button:disabled { opacity: .35; cursor: default; }
.bar button[aria-pressed="true"] { color: var(--ink); }
.bar button.attention { background: var(--ink); color: var(--ground); }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .player, .delta, .delta.show, .key, .start { transition: none; }
}
