/* ================================================================
   Brettspiel — Dark Theme
   ================================================================ */

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

:root {
  --bg:        #0d1117;
  --bg2:       #161b22;
  --bg3:       #21262d;
  --border:    #30363d;
  --text:      #e2e8f0;
  --text-muted:#8b949e;
  --accent:    #58a6ff;
  --radius:    8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

#app {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------- Screens */

.screen { display: none; width: 100%; height: 100%; overflow: hidden; flex: 1; }
.screen.active { display: flex; flex-direction: column; }

/* ---------------------------------------------------------------- Setup Screen */

#screen-setup {
  align-items: center;
  justify-content: center;
  gap: 24px;
}

#screen-setup h1 {
  font-size: 2.4rem;
  color: var(--accent);
  letter-spacing: 2px;
}

.setup-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 32px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setup-panel h2 {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-row input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.player-row input[type="text"] {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 0.9rem;
}

.player-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
}

.color-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- Game Screen */

#screen-game { overflow: hidden; }

#mobile-tab-bar      { display: none; }
#btn-fullscreen      { display: none; }
#btn-roll-float      { display: none; }
#btn-fullscreen-exit { display: none; }
#mobile-player-info  { display: none; }
#sidebar-menu        { display: none; }
#fullscreen-hud      { display: none; }

#topbar {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#active-player-label {
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- Player Panels */

#player-panels {
  background: var(--bg2);
}

.player-card {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  transition: border-color 0.2s, background 0.2s;
}

.player-card.active {
  border-color: var(--accent);
  background: #1c2333;
}

.player-card.finished {
  opacity: 0.55;
}

.player-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.player-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.player-name {
  font-weight: 600;
  font-size: 0.85rem;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-rank {
  font-size: 0.75rem;
  color: #f1c40f;
  font-weight: bold;
}

.player-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.player-stats strong { color: var(--text); }

.player-inventory {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-height: 16px;
  letter-spacing: 1px;
}

.player-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.btn-item-action {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 3px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-item-action:hover {
  background: var(--bg2);
  border-color: var(--accent);
}

.shield-info {
  font-size: 0.78rem;
  color: #3498db;
}

/* ---------------------------------------------------------------- Board */

#board-container {
  overflow: hidden;
  background: #0a0f16;
}

#board-wrapper {
  position: relative;
  /* Größe wird von board.js _sizeWrapper() gesetzt (width + height in px) */
}

#board-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

#board-svg-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: #131a24;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

#board-svg-overlay.bomb-mode {
  outline: 2px solid #e74c3c;
  outline-offset: -2px;
}

#token-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

/* ---------------------------------------------------------------- Tokens */

.token {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.8); /* Breite wird von board.js gesetzt */
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.6);
  z-index: 10;
  transition: left 0.15s ease, top 0.15s ease, opacity 0.3s;
}

/* ---------------------------------------------------------------- Bomb-Marker */

.bomb-marker {
  position: absolute;
  transform: translate(-50%, -65%);
  font-size: 1.2rem;
  pointer-events: none;
  z-index: 8;
  animation: bomb-pulse 1.2s ease-in-out infinite;
  filter: drop-shadow(0 0 4px rgba(231,76,60,0.8));
}

@keyframes bomb-pulse {
  0%, 100% { transform: translate(-50%, -65%) scale(1);   opacity: 1; }
  50%       { transform: translate(-50%, -65%) scale(1.3); opacity: 0.7; }
}

/* ---------------------------------------------------------------- Bomb-Ring Animation */

.bomb-ring {
  position: absolute;
  border: 2px solid #e74c3c;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  width: 10px; height: 10px;
  pointer-events: none;
  animation: bomb-expand 0.6s ease-out forwards;
  z-index: 30;
}

@keyframes bomb-expand {
  from { width: 10px; height: 10px; opacity: 1; }
  to   { width: 80px; height: 80px; opacity: 0; }
}

/* ---------------------------------------------------------------- Sidebar */

#sidebar {
  background: var(--bg2);
  overflow: hidden;
}

/* ---------------------------------------------------------------- Action Panel */

#action-panel {
  border-bottom: 1px solid var(--border);
}

#dice-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.die {
  width: 44px; height: 44px;
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  user-select: none;
}

.die.shake {
  animation: dice-shake 0.08s infinite;
}

@keyframes dice-shake {
  0%   { transform: rotate(-8deg); }
  50%  { transform: rotate(8deg); }
  100% { transform: rotate(-8deg); }
}

#dice-sum {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--accent);
  min-width: 32px;
  text-align: center;
}

.placement-hint {
  font-size: 0.78rem;
  color: #e74c3c;
  text-align: center;
  min-height: 16px;
}

.btn-cancel-item {
  background: none;
  border: 1px solid #e74c3c;
  border-radius: 4px;
  color: #e74c3c;
  padding: 1px 8px;
  font-size: 0.75rem;
  cursor: pointer;
  margin-left: 4px;
  vertical-align: middle;
}

.btn-cancel-item:hover {
  background: rgba(231, 76, 60, 0.15);
}

/* ---------------------------------------------------------------- Legend */

#legend h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  margin-bottom: 4px;
  color: var(--text-muted);
}

.leg-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.leg-dot.start      { background: #27ae60; }
.leg-dot.ziel       { background: #e74c3c; }
.leg-dot.glasperlen { background: #f1c40f; }
.leg-dot.item       { background: #9b59b6; }
.leg-dot.portal     { background: #1abc9c; }
.leg-dot.ereignis   { background: #e67e22; }

/* ---------------------------------------------------------------- Log */

#log-container h3 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 8px;
  flex-shrink: 0;
}

.log-entry {
  font-size: 0.78rem;
  line-height: 1.4;
  padding: 3px 0;
  border-bottom: 1px solid var(--bg3);
}

.log-icon {
  margin-right: 4px;
}

/* ---------------------------------------------------------------- Buttons */

.btn-primary {
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-primary:hover:not(:disabled) { opacity: 0.85; }
.btn-primary:active:not(:disabled) { transform: scale(0.97); }

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#btn-load-board, #btn-restart {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 6px 12px;
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: border-color 0.15s;
}

#btn-load-board:hover, #btn-restart:hover {
  border-color: var(--accent);
}

/* ---------------------------------------------------------------- Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  min-width: 280px;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-box h2 {
  font-size: 1.1rem;
  color: var(--text);
}

.modal-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

#modal-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-choice {
  background: var(--bg3);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.btn-choice:hover { background: #1c2333; }
.btn-choice--muted { color: var(--text-muted); border-color: var(--border); }

/* ---------------------------------------------------------------- Gameover Screen */

#screen-gameover {
  align-items: center;
  justify-content: center;
}

.gameover-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 40px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.gameover-panel h1 {
  font-size: 1.8rem;
  color: #f1c40f;
}

#final-rankings {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.final-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg3);
  border: 1px solid;
  border-radius: var(--radius);
  padding: 10px 14px;
}

.final-rank {
  font-size: 1.2rem;
  font-weight: bold;
  color: #f1c40f;
  min-width: 30px;
}

.final-name {
  flex: 1;
  font-weight: 600;
}

.final-gems {
  color: #f1c40f;
  font-size: 0.95rem;
}

/* ---------------------------------------------------------------- Scrollbar */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
