/* ──────────────────────────────────────────────────────
   Stein Schere Papier · Global Styles
   Aesthetic: Dark brutalist arcade — neon on void
────────────────────────────────────────────────────── */

:root {
  --bg:       #0a0a0f;
  --surface:  #111118;
  --border:   #2a2a38;
  --neon:     #e8ff47;
  --neon2:    #47ffe8;
  --red:      #ff4757;
  --green:    #2ed573;
  --text:     #f0f0f0;
  --muted:    #666680;
  --font-display: 'Bebas Neue', sans-serif;
  --font-mono:    'Space Mono', monospace;
}

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

html {
  /* Fluide Basisschrift: 14px auf kleinen Phones, 16px ab ca. 500px Breite */
  font-size: clamp(14px, 1.2vw + 10px, 16px);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

[hidden] { display: none !important; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  overflow-x: hidden;
}

/* ── Noise overlay ── */
.noise {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.5;
}

/* ═══════════════════════════════════════════════════
   LANDING PAGE
═══════════════════════════════════════════════════ */

.landing {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex; flex-direction: column;
  position: relative;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.landing-main {
  position: relative; z-index: 1;
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: clamp(1.5rem, 6vw, 3rem) clamp(1rem, 4vw, 1.5rem);
  gap: clamp(1.75rem, 6vw, 3.5rem);
}

/* Hero */
.hero { text-align: center; }

.symbols-row {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(0.5rem, 3vw, 1rem);
  font-size: clamp(1.6rem, 8vw, 2.2rem);
  margin-bottom: clamp(1rem, 4vw, 1.5rem);
}
.sym {
  display: inline-flex; align-items: center;
  animation: float 3s ease-in-out infinite;
}
.sym:nth-child(3) { animation-delay: 1s; }
.sym:nth-child(5) { animation-delay: 2s; }
.vs {
  font-size: 0.75rem; color: var(--muted);
  font-family: var(--font-mono); letter-spacing: 0.2em;
}

@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.hero h1 {
  font-family: var(--font-display);
  /* Breite und Höhe begrenzen, damit drei Zeilen auch quer aufs Display passen */
  font-size: clamp(3rem, min(18vw, 13vh), 8rem);
  line-height: 0.92;
  letter-spacing: -0.01em;
  color: var(--text);
  text-shadow: 0 0 60px rgba(232,255,71,0.15);
}

/* Cards */
.card-group {
  display: flex; gap: 0; align-items: stretch;
  max-width: 1100px; width: 100%;
  border: 1px solid var(--border);
  border-radius: 2px;
  overflow: visible;
}

.divider-v {
  display: flex; align-items: center; justify-content: center;
  width: 1px; background: var(--border);
  position: relative; flex-shrink: 0;
}
.divider-v span {
  position: absolute;
  background: var(--bg);
  padding: 0.4rem 0;
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  writing-mode: vertical-lr;
}

.card {
  flex: 1; padding: clamp(1.5rem, 5vw, 2.5rem) clamp(1.1rem, 4vw, 2rem);
  display: flex; flex-direction: column; gap: 1rem;
  position: relative;
  transition: background 0.2s;
}
.card:hover { background: rgba(255,255,255,0.02); }

.card-num {
  font-size: 0.65rem; letter-spacing: 0.3em;
  color: var(--neon); opacity: 0.7;
  text-transform: uppercase;
}

.card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 7vw, 2rem); letter-spacing: 0.05em;
  color: var(--text);
}

.card p {
  font-size: 0.75rem; color: var(--muted);
  line-height: 1.6; flex: 1;
}

.name-row, .code-row {
  display: flex; gap: 0.5rem;
}

input[type="text"] {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.65rem 0.9rem;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type="text"]:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 2px rgba(232,255,71,0.12);
}
input::placeholder { color: var(--muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  font-family: var(--font-mono); font-size: 0.8rem;
  letter-spacing: 0.08em; text-decoration: none;
  cursor: pointer; border: none; border-radius: 2px;
  transition: all 0.15s;
  text-align: center;
}

.btn-primary {
  background: var(--neon); color: var(--bg);
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
  background: #f5ff70;
  box-shadow: 0 0 20px rgba(232,255,71,0.35);
  transform: translateY(-1px);
}
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: transparent; color: var(--neon2);
  border: 1px solid var(--neon2);
}
.btn-secondary:hover {
  background: rgba(71,255,232,0.08);
  box-shadow: 0 0 16px rgba(71,255,232,0.2);
  transform: translateY(-1px);
}

.btn-tertiary {
  background: transparent; color: var(--red);
  border: 1px solid var(--red);
}
.btn-tertiary:hover {
  background: rgba(255,71,87,0.08);
  box-shadow: 0 0 16px rgba(255,71,87,0.2);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }



/* ═══════════════════════════════════════════════════
   GAME PAGE — Screens
═══════════════════════════════════════════════════ */

.game-page {
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex; align-items: stretch;
  position: relative;
}

.screen {
  display: none; flex: 1;
  flex-direction: column; align-items: center; justify-content: center;
  padding: clamp(1rem, 4vw, 1.5rem);
  position: relative; z-index: 1;
  min-width: 0;
}
.screen.active { display: flex; }

/* ── Waiting Screen ── */
.wait-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 1rem;
  text-align: center;
  max-width: 420px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: clamp(1.75rem, 7vw, 3rem) clamp(1.1rem, 5vw, 2rem);
}

.state-icon { font-size: clamp(2.2rem, 11vw, 3rem); line-height: 1; margin: 0.5rem 0; }

.wait-card .logo-img { margin-bottom: 0.25rem; }

.wait-spinner {
  width: 36px; height: 36px;
  border: 2px solid var(--border);
  border-top-color: var(--neon);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0.5rem 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.wait-card h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 7vw, 1.8rem); letter-spacing: 0.05em;
}
.wait-card p { font-size: 0.75rem; color: var(--muted); }

.share-box {
  display: flex; align-items: center; gap: 0.5rem;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 0.6rem 0.9rem;
  font-size: 0.72rem; color: var(--neon2);
  word-break: break-all;
}
.share-box button {
  background: none; border: none; cursor: pointer;
  color: var(--muted); flex-shrink: 0;
  transition: color 0.15s;
}
.share-box button:hover { color: var(--neon); }

.copy-hint { font-size: 0.7rem; color: var(--green); height: 1em; }

.name-input-row { width: 100%; }
.name-input-row input { width: 100%; }
.link-back { font-size: 0.72rem; color: var(--muted); text-decoration: none; margin-top: 0.5rem; }
.link-back:hover { color: var(--text); }

/* ── Playing Screen Layout ── */
.screen-playing {
  justify-content: flex-start;
}

/* ── Game Header ── */
.game-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: 700px;
  gap: 0.75rem;
  padding: 0 0 clamp(0.75rem, 3vw, 1.5rem);
  border-bottom: 1px solid var(--border);
}

.logo-sm { display: block; flex-shrink: 0; line-height: 0; }
.logo-sm img { display: block; width: clamp(36px, 10vw, 48px); height: auto; }

.logo-img { display: block; width: clamp(56px, 16vw, 72px); height: auto; }

.scoreboard {
  display: flex; align-items: center; gap: clamp(0.5rem, 3vw, 1rem);
  min-width: 0;
}
.score-block {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  min-width: 0;
}
.score-name {
  font-size: 0.65rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase;
  max-width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.score-num {
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 9vw, 2.4rem); line-height: 1;
  color: var(--text);
  min-width: 1.5ch; text-align: center;
}
.score-sep {
  font-family: var(--font-display); font-size: clamp(1.5rem, 7vw, 2rem);
  color: var(--border);
}

.round-badge {
  font-size: 0.65rem; letter-spacing: 0.2em;
  color: var(--muted); text-transform: uppercase;
  border: 1px solid var(--border); border-radius: 2px;
  padding: 0.3rem 0.7rem;
}

/* ── Arena ── */
.arena {
  display: flex; align-items: center; gap: clamp(0.5rem, 3vw, 2rem);
  width: 100%; max-width: 700px;
  padding: clamp(1rem, 4vh, 2rem) 0;
  flex: 1;
}

.fighter {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 0.75rem;
  min-width: 0;
}

.fighter-label {
  font-size: 0.65rem; letter-spacing: 0.25em;
  color: var(--muted); text-transform: uppercase;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.choice-display {
  /* Größe richtet sich nach Breite und Höhe, damit es auch quer passt */
  --box: clamp(80px, min(30vw, 24vh), 160px);
  width: var(--box);
  height: var(--box);
  font-size: calc(var(--box) * 0.55);
  display: flex; align-items: center; justify-content: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
  user-select: none;
}

.fighter-me .choice-display { border-color: rgba(232,255,71,0.3); }
.fighter-enemy .choice-display { border-color: rgba(71,255,232,0.3); }


/* ── Choice placeholder ── */
.choice-placeholder {
  font-size: 0.4em;
  color: var(--border);
  font-family: var(--font-mono);
  font-weight: 700;
}

.choice-display.chosen {
  border-color: var(--neon);
  box-shadow: 0 0 20px rgba(232,255,71,0.25);
  animation: pop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.choice-display.enemy-waiting {
  border-color: rgba(71,255,232,0.5);
  animation: pulse-border 1.2s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { box-shadow: 0 0 0px rgba(71,255,232,0.2); }
  50%       { box-shadow: 0 0 16px rgba(71,255,232,0.4); }
}

.choice-display.revealed {
  animation: pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes pop {
  0%   { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

.choice-status {
  font-size: 0.68rem; color: var(--muted);
  letter-spacing: 0.05em; min-height: 1.2em;
  text-align: center;
}

.vs-center {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 5vw, 2rem); color: var(--border);
  flex-shrink: 0;
}

/* ── Round Result — inline ── */
.round-result-inline {
  width: 100%; max-width: 700px;
  display: flex; justify-content: center;
  padding: 0.25rem 0 0.5rem;
}
.round-result-inline.hidden { display: none; }

.result-badge {
  padding: clamp(0.6rem, 2vw, 0.9rem) clamp(1rem, 5vw, 2.2rem);
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 5.5vw, 1.8rem);
  overflow-wrap: anywhere;
  letter-spacing: 0.05em;
  border-radius: 4px;
  animation: badge-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
  max-width: 90vw;
}
@keyframes badge-in {
  from { transform: scale(0.6) translateY(30px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}
.result-badge.win  { background: var(--green); color: var(--bg); }
.result-badge.lose { background: var(--red);   color: #fff; }
.result-badge.draw { background: var(--surface); color: var(--neon); border: 2px solid var(--neon); }

/* ── Choice Buttons ── */
.choices {
  display: flex; gap: clamp(0.5rem, 2.5vw, 1rem); justify-content: center;
  width: 100%; max-width: 700px;
  padding-bottom: 1rem;
}

.choice-btn {
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  flex: 1 1 0; min-width: 0; max-width: 180px;
  padding: clamp(0.75rem, 3vw, 1.2rem) clamp(0.4rem, 2vw, 1rem);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer; color: var(--text);
  font-family: var(--font-mono); font-size: 0.75rem;
  letter-spacing: 0.08em;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.choice-btn:hover:not(:disabled) {
  border-color: var(--neon);
  background: rgba(232,255,71,0.05);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(232,255,71,0.15);
}
.choice-btn:active:not(:disabled) { transform: translateY(0); }
.choice-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.choice-icon { font-size: clamp(1.7rem, 8vw, 2.2rem); }
.choice-name { color: var(--muted); }

.waiting-msg {
  font-size: 0.75rem; color: var(--muted);
  letter-spacing: 0.1em; padding: 0.5rem 0;
  animation: pulse 1.5s ease-in-out infinite;
}
.waiting-msg.hidden { display: none; }
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ── Finished Screen ── */
.finish-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 1.2rem;
  text-align: center;
  max-width: 440px; width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: clamp(1.75rem, 7vw, 3rem) clamp(1.1rem, 5vw, 2rem);
}

.finish-icon { font-size: clamp(3rem, 15vw, 4rem); animation: bounce 1s ease-in-out; }
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.25); }
}

.finish-card h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 12vw, 3.5rem); letter-spacing: 0.05em;
}
.finish-card p { font-size: 0.8rem; color: var(--muted); }

.finish-score {
  display: flex; align-items: center; gap: clamp(0.75rem, 4vw, 1.5rem);
  font-family: var(--font-display); font-size: clamp(2.8rem, 14vw, 4rem);
  color: var(--neon);
}
.finish-score span:nth-child(2) { color: var(--muted); font-size: 0.5em; }

.finish-actions {
  display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════ */

@media (max-width: 900px) {

  .card-group {
    flex-direction: column;
    border-radius: 2px;
    max-width: 520px;
  }
  .divider-v {
    width: 100%; height: 1px;
  }
  .divider-v span { writing-mode: horizontal-tb; padding: 0 0.4rem; }
}

@media (max-width: 640px) {
  .game-header { flex-wrap: wrap; justify-content: center; }
}

/* Touch-Geräte: Eingabefelder mit 16px, sonst zoomt iOS beim Antippen */
@media (pointer: coarse) {
  input[type="text"] { font-size: 16px; }
}

/* ── QR Code ── */
.qr-wrapper {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  padding: 1rem;
  background: #111118;
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 0.5rem;
}
.qr-wrapper img, .qr-wrapper canvas {
  border-radius: 2px;
  display: block;
}
.qr-label {
  font-size: 0.65rem; color: var(--muted);
  letter-spacing: 0.12em; text-transform: uppercase;
}

/* ── Lobby Countdown ── */
.timeout-hint {
  font-size: 0.7rem; color: var(--muted);
  letter-spacing: 0.05em;
  margin-top: 0.25rem;
}
.timeout-hint span { color: var(--neon); font-weight: 700; }

/* ── Reconnect Banner ── */
.reconnect-banner {
  width: 100%; max-width: 700px;
  background: rgba(255, 71, 87, 0.12);
  border: 1px solid var(--red);
  border-radius: 2px;
  padding: 0.6rem 1rem;
  font-size: 0.75rem;
  color: var(--red);
  letter-spacing: 0.05em;
  text-align: center;
  margin-bottom: 0.5rem;
  animation: pulse 1.5s ease-in-out infinite;
}
.reconnect-banner.hidden { display: none; }

/* ═══════════════════════════════════════════════════
   HISTORY PAGE
═══════════════════════════════════════════════════ */

.history-main {
  position: relative; z-index: 1;
  flex: 1;
  display: flex; flex-direction: column;
  padding: clamp(1.5rem, 5vw, 3rem) clamp(1rem, 5vw, 3rem);
  gap: clamp(1.25rem, 4vw, 2rem);
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.history-header {
  display: flex; align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.history-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 12vw, 5rem);
  line-height: 0.92;
  color: var(--text);
}

.history-link {
  display: flex; justify-content: center; flex-wrap: wrap; gap: 0.75rem;
  padding-top: 0.5rem;
}

.install-hint {
  font-size: 0.72rem; color: var(--muted);
  text-align: center; max-width: 40ch;
  margin-top: -1rem;
}

.history-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.history-table thead {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.history-table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 400;
}

.history-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

.history-table tbody tr:hover {
  background: rgba(255,255,255,0.02);
}

.history-table .num {
  color: var(--muted);
  font-size: 0.7rem;
  width: 2rem;
}

.history-table .winner {
  color: var(--neon);
  font-weight: 700;
}

.history-table .score {
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  color: var(--text);
}

.history-table .loser {
  color: var(--muted);
}

.history-table .rounds {
  color: var(--muted);
  text-align: center;
}

.history-table .time {
  color: var(--muted);
  font-size: 0.7rem;
  white-space: nowrap;
}

.history-empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 0.75rem;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 2px;
}

@media (max-width: 640px) {
  .history-header { flex-direction: column; align-items: flex-start; }
  .history-table th, .history-table td { padding: 0.6rem 0.6rem; }
}

@media (max-width: 420px) {
  .history-table .num, .history-table .rounds { display: none; }
}
