/* SPECHT-PIEPE: Erzgebirgs-Braustube & 90er-Arcade Styling */

:root {
  --bg-deep: #15100c;
  --bg-wood: #231811;
  --bg-card: #2c1e15;
  --bg-card-soft: #36251a;
  --border-brass: #b87f35;
  --border-soft: rgba(226, 168, 75, 0.28);
  --gold: #f5b82e;
  --gold-bright: #ffe066;
  --copper: #c86d31;
  --spruce: #1e6b3d;
  --spruce-bright: #2d9658;
  --cream: #fcf3e3;
  --muted: #c9b59b;
  --danger: #ef4444;
  --success: #34d399;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  --radius: 14px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 20% 10%, rgba(184, 127, 53, 0.16), transparent 45%),
    radial-gradient(circle at 85% 90%, rgba(30, 107, 61, 0.18), transparent 45%),
    linear-gradient(160deg, #1b130d 0%, #120d09 100%);
  color: var(--cream);
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app-shell {
  max-width: 1060px;
  margin: 0 auto;
  padding: 10px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== TOPBAR ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: linear-gradient(180deg, #322217 0%, #24170f 100%);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 8px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-emblem {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
}

.specht-svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  line-height: 1.05;
  color: var(--gold-bright);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  font-family: Georgia, 'Times New Roman', serif;
}

.brand-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.03em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.pill-btn,
.icon-btn {
  border: 1px solid var(--border-soft);
  background: #3a271b;
  color: var(--cream);
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  font-family: inherit;
}

.pill-btn:hover,
.icon-btn:hover {
  background: #4b3323;
  border-color: var(--gold);
}

.pill-btn:active,
.icon-btn:active {
  transform: scale(0.95);
}

.player-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 0.85rem;
  font-weight: 700;
  max-width: 170px;
}

#hud-player-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edit-pen {
  opacity: 0.65;
  font-size: 0.78rem;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  padding: 0;
}

/* ===== MEISTER SPECHT BANNER ===== */
.specht-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(90deg, rgba(46, 30, 19, 0.96), rgba(34, 24, 17, 0.92));
  border: 1.5px solid var(--border-soft);
  border-left: 4px solid var(--gold);
  border-radius: var(--radius);
  padding: 8px 12px;
}

.specht-avatar {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.specht-avatar.bounce {
  animation: spechtBounce 0.45s ease;
}

@keyframes spechtBounce {
  0%, 100% { transform: scale(1) rotate(0deg); }
  35% { transform: scale(1.14) rotate(-6deg); }
  70% { transform: scale(1.06) rotate(4deg); }
}

.specht-speech {
  min-width: 0;
  flex: 1;
}

.specht-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.level-tag {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gold);
}

.beer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--cream);
}

.beer-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 6px var(--gold);
}

#specht-quip {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.3;
  color: var(--cream);
}

/* ===== MAIN GAME LAYOUT ===== */
.game-layout {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--cream);
}

.stat-value.gold {
  color: var(--gold-bright);
}

.stat-value.urgent {
  color: #f87171;
  animation: pulseUrgent 0.65s ease-in-out infinite alternate;
}

@keyframes pulseUrgent {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.connection-pill {
  background: rgba(245, 184, 46, 0.1);
  border: 1px solid rgba(245, 184, 46, 0.3);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fde68a;
  text-align: center;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.connection-pill.connected {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(52, 211, 153, 0.65);
  color: #a7f3d0;
}

.connection-pill.danger {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(248, 113, 113, 0.7);
  color: #fecaca;
}

/* ===== ROHR-SPENDER (QUEUE) ===== */
.dispenser-box {
  background: linear-gradient(180deg, #2d1e15 0%, #22160f 100%);
  border: 1.5px solid var(--border-brass);
  border-radius: var(--radius);
  padding: 10px;
}

.dispenser-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.next-label {
  background: var(--gold);
  color: #211206;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 900;
}

.queue-strip {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.queue-slot {
  background: #1b120c;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.76;
}

.queue-slot canvas {
  width: 38px;
  height: 38px;
  display: block;
}

.queue-slot.active {
  opacity: 1;
  background: #332013;
  border: 2.5px solid var(--gold-bright);
  box-shadow: 0 0 14px rgba(245, 184, 46, 0.35);
  padding: 5px;
}

.queue-slot.active canvas {
  width: 56px;
  height: 56px;
}

/* ===== BUTTONS ===== */
.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.primary-btn,
.secondary-btn {
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.primary-btn {
  background: linear-gradient(180deg, #ffd447 0%, #e09112 100%);
  color: #221205;
  padding: 12px 16px;
  font-size: 0.96rem;
  box-shadow: 0 4px 14px rgba(224, 145, 18, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.primary-btn:active {
  transform: scale(0.97);
}

.primary-btn.big-btn {
  font-size: 1.04rem;
  padding: 13px 18px;
}

.fastflow-btn.ready {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%);
  color: #052e16;
  box-shadow: 0 0 18px rgba(74, 222, 128, 0.55);
  animation: pulseReady 1.2s ease-in-out infinite;
}

.fastflow-btn.active {
  background: linear-gradient(180deg, #fb923c 0%, #dc2626 100%);
  color: #fffbeb;
  box-shadow: 0 0 18px rgba(251, 146, 60, 0.55);
}

@keyframes pulseReady {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

.secondary-btn {
  background: #3b281c;
  border: 1px solid var(--border-soft);
  color: var(--cream);
  padding: 10px 14px;
  font-size: 0.88rem;
}

.secondary-btn:hover {
  background: #4b3425;
  border-color: var(--gold);
}

.small-btn {
  padding: 8px 12px;
  font-size: 0.82rem;
}

/* ===== BOARD STAGE ===== */
.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.board-frame {
  position: relative;
  padding: 6px;
  background: linear-gradient(145deg, #5d3a1f 0%, #2c1a0e 50%, #4b2d17 100%);
  border: 2px solid var(--border-brass);
  border-radius: 16px;
  box-shadow: var(--shadow), inset 0 0 12px rgba(0, 0, 0, 0.65);
  max-width: 100%;
}

#game-canvas {
  display: block;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.board-overlay {
  position: absolute;
  inset: 6px;
  border-radius: 10px;
  background: rgba(16, 10, 6, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 5;
}

.overlay-card {
  text-align: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border-brass);
  border-radius: 14px;
  padding: 20px 24px;
  max-width: 300px;
}

.overlay-card h2 {
  margin: 0 0 8px;
  color: var(--gold-bright);
}

.overlay-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

.controls-hint {
  margin: 0;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
}

.hint-mobile {
  display: none;
}

/* ===== MODALS ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 6, 3, 0.78);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  z-index: 50;
  overflow-y: auto;
}

.hidden {
  display: none !important;
}

.modal-card {
  width: 100%;
  max-width: 490px;
  background: linear-gradient(180deg, #322116 0%, #22160f 100%);
  border: 2px solid var(--border-brass);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.72);
  max-height: 92vh;
  overflow-y: auto;
}

.small-card {
  max-width: 380px;
}

.modal-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.hero-specht {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 2px;
}

.modal-card h2 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--gold-bright);
  font-size: 1.4rem;
  line-height: 1.15;
}

.modal-lead {
  margin: 10px 0 14px;
  font-size: 0.93rem;
  line-height: 1.45;
  color: var(--cream);
}

.modal-sub {
  margin: 6px 0 12px;
  font-size: 0.85rem;
  color: var(--muted);
}

.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.close-x {
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--muted);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1rem;
}

.close-x:hover {
  color: var(--cream);
  border-color: var(--gold);
}

.quick-rules {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 14px;
}

.rule-chip {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 210, 130, 0.16);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.84rem;
  line-height: 1.35;
}

.name-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.name-form label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--gold);
}

.name-input-row {
  display: flex;
  gap: 8px;
}

.name-input-row input {
  flex: 1;
  min-width: 0;
  background: #17100b;
  border: 1.5px solid var(--border-brass);
  border-radius: 10px;
  color: var(--cream);
  font-size: 1rem;
  font-weight: 700;
  padding: 10px 12px;
  outline: none;
}

.name-input-row input:focus {
  border-color: var(--gold-bright);
  box-shadow: 0 0 0 3px rgba(245, 184, 46, 0.25);
}

.dice-btn {
  width: 44px;
  height: 44px;
  font-size: 1.2rem;
  flex-shrink: 0;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.modal-actions.split {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.danger-link {
  background: transparent;
  border: none;
  color: #fca5a5;
  font-size: 0.78rem;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 0;
}

/* ===== WIN / SPILL / GAMEOVER ===== */
.stars-row {
  font-size: 2rem;
  text-align: center;
  letter-spacing: 6px;
  margin-bottom: 6px;
}

.win-card,
.spill-card,
.gameover-card {
  text-align: center;
}

.breakdown-box {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.bd-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.bd-row.total {
  border-top: 1px solid var(--border-soft);
  padding-top: 6px;
  margin-top: 4px;
  font-weight: 800;
  color: var(--gold-bright);
  font-size: 0.96rem;
}

.bd-row.bonus {
  color: #6ee7b7;
}

.bd-row.penalty {
  color: #fca5a5;
}

.next-preview {
  background: rgba(30, 107, 61, 0.24);
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.83rem;
  color: #d1fae5;
  margin-bottom: 4px;
}

.spill-badge {
  display: inline-block;
  background: rgba(239, 68, 68, 0.2);
  border: 1px solid rgba(248, 113, 113, 0.55);
  color: #fecaca;
  font-weight: 900;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.spill-reason {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 10px;
  padding: 8px 12px;
  color: #fde68a;
  font-weight: 700;
  font-size: 0.92rem;
  margin: 10px 0;
}

.rank-banner {
  background: linear-gradient(90deg, rgba(245, 184, 46, 0.18), rgba(200, 109, 49, 0.22));
  border: 1.5px solid var(--gold);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-weight: 800;
  color: var(--gold-bright);
  font-size: 0.98rem;
}

.mini-scores {
  text-align: left;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 0.84rem;
}

/* ===== SCORES TABLE ===== */
.scores-table-wrap {
  max-height: 52vh;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.25);
}

.scores-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.scores-table th,
.scores-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.scores-table th {
  background: rgba(245, 184, 46, 0.12);
  color: var(--gold);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}

.scores-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.scores-table tr.highlight-row {
  background: rgba(245, 184, 46, 0.2);
}

.scores-table tr.player-row td:nth-child(2) {
  color: var(--gold-bright);
  font-weight: 800;
}

.rank-sub {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  font-weight: 500;
}

/* ===== HELP LIST ===== */
.help-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.help-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(0, 0, 0, 0.22);
  border-radius: 10px;
  padding: 9px 10px;
}

.help-icon {
  font-size: 1.25rem;
  line-height: 1.2;
}

.help-item strong {
  display: block;
  color: var(--gold-bright);
  font-size: 0.88rem;
  margin-bottom: 2px;
}

.help-item p {
  margin: 0;
  font-size: 0.81rem;
  line-height: 1.38;
  color: var(--cream);
}

/* ===== RESPONSIVE MOBILE LAYOUT ===== */
@media (max-width: 860px) {
  .app-shell {
    padding: 6px 8px 14px;
    gap: 7px;
  }

  .topbar {
    padding: 6px 8px;
  }

  .brand-emblem {
    width: 34px;
    height: 34px;
  }

  .brand-text h1 {
    font-size: 1.02rem;
  }

  .brand-sub {
    display: none;
  }

  .player-pill {
    padding: 5px 8px;
    font-size: 0.78rem;
    max-width: 112px;
  }

  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
  }

  .specht-banner {
    padding: 6px 9px;
    gap: 8px;
  }

  .specht-avatar {
    width: 34px;
    height: 34px;
  }

  #specht-quip {
    font-size: 0.81rem;
  }

  .game-layout {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .side-panel {
    gap: 6px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }

  .stat-card {
    padding: 5px 6px;
    text-align: center;
  }

  .stat-label {
    font-size: 0.6rem;
  }

  .stat-value {
    font-size: 0.9rem;
  }

  .connection-pill {
    padding: 4px 8px;
    font-size: 0.74rem;
  }

  .dispenser-box {
    padding: 6px 8px;
  }

  .dispenser-header {
    margin-bottom: 5px;
    font-size: 0.68rem;
  }

  .queue-slot canvas {
    width: 34px;
    height: 34px;
  }

  .queue-slot.active canvas {
    width: 48px;
    height: 48px;
  }

  .action-buttons {
    flex-direction: row;
  }

  .fastflow-btn {
    flex: 1;
    padding: 10px 12px;
    font-size: 0.88rem;
  }

  .small-btn {
    padding: 10px 10px;
    font-size: 0.78rem;
  }

  .board-frame {
    padding: 4px;
  }

  .hint-desktop {
    display: none;
  }

  .hint-mobile {
    display: inline;
  }
}
