/* ================================================================
   Fallensteller — Mobile Layout (Tab-Navigation)
   Wird geladen mit: media="screen and (max-width: 767px)"
   ================================================================ */

/* ---- Topbar ---- */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  gap: 6px;
}

#active-player-label { font-size: 0.82rem; }
#topbar-actions { display: flex; gap: 4px; }
#btn-load-board, #btn-restart { padding: 4px 8px; font-size: 0.72rem; }

/* ---- Tab-Container ---- */
#game-area {
  display: flex;
  flex: 1;
  flex-direction: column;
  overflow: hidden;
}

/* Alle Bereiche standardmäßig ausgeblendet */
#player-panels,
#board-container,
#sidebar { display: none; }

/* ---- Tab: Spielfeld ---- */
#game-area.tab-spielfeld #board-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  min-height: 0;
}

#game-area.tab-spielfeld #sidebar {
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
}

#game-area.tab-spielfeld #action-panel {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: none;
}

/* Spieler-Info links, Würfel rechts — nur Hochformat */
@media (orientation: portrait) {
  #game-area.tab-spielfeld #mobile-player-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    order: -1;
    flex-shrink: 0;
  }
  #game-area.tab-spielfeld .mpi-header {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    margin-bottom: 0;
    font-size: 0.8rem;
  }
  #game-area.tab-spielfeld .mpi-name { display: none; }
  #game-area.tab-spielfeld .mpi-actions { margin-top: 0; }
  #game-area.tab-spielfeld #dice-area { margin-left: auto; }
}

#game-area.tab-spielfeld #legend,
#game-area.tab-spielfeld #log-container { display: none; }

.die { width: 34px; height: 34px; font-size: 1.4rem; }
#dice-sum { font-size: 0.9rem; }
#btn-roll { padding: 7px 16px; font-size: 0.88rem; }

/* ---- Tab: Spieler ---- */
#game-area.tab-spieler #player-panels {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 6px;
  padding: 8px;
}

/* ---- Tab: Log ---- */
#game-area.tab-log #sidebar {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#game-area.tab-log #action-panel,
#game-area.tab-log #legend { display: none; }

#game-area.tab-log #log-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 12px;
}

#game-area.tab-log #log {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ---- Tab-Bar ---- */
#mobile-tab-bar {
  display: flex;
  flex-shrink: 0;
  background: var(--bg2);
  border-top: 2px solid var(--border);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 4px 6px;
  background: none;
  border: none;
  border-top: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.68rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  margin-top: -2px;
}

.tab-btn .tab-icon { font-size: 1.3rem; line-height: 1; }
.tab-btn.active { color: var(--accent); border-top-color: var(--accent); }

/* ---- Vollbild-Button in Topbar ---- */
#btn-fullscreen {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 4px 8px;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

/* ---- Querformat (Landscape) ---- */
@media (orientation: landscape) {
  #mobile-tab-bar { display: none; }
  #topbar         { display: none !important; }

  #game-area {
    flex-direction: row;
  }

  /* ---- Sidebar-Menü (ersetzt Topbar-Buttons im Querformat) ---- */
  #sidebar-menu {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 4px 6px;
    border-bottom: 1px solid var(--border);
  }

  #sidebar-menu button {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text);
    padding: 3px 8px;
    font-size: 0.9rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #sidebar-menu button:hover { border-color: var(--accent); }

  /* Alle Tab-Sichtbarkeiten zurücksetzen */
  #player-panels { display: none; }

  #board-container {
    flex: 1 !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 4px;
    min-height: 0;
    min-width: 0;
  }

  #sidebar {
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    width: 160px;
    flex-shrink: 0;
    border-left: 1px solid var(--border);
    border-top: none;
  }

  #action-panel {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }

  #legend { display: none; }

  #log-container {
    display: flex !important;
    flex-direction: column;
    overflow: hidden;
    padding: 6px 8px;
    flex: 1;
  }

  #log {
    flex: 1;
    overflow-y: auto;
    display: flex !important;
    flex-direction: column;
    gap: 3px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }

  #log-container h3 { font-size: 0.68rem; margin-bottom: 4px; }
  .log-entry { font-size: 0.66rem; }
  .die { width: 30px; height: 30px; font-size: 1.1rem; }
  #dice-area { gap: 6px; }
  #dice-sum { font-size: 0.8rem; }
  #btn-roll { width: 100%; padding: 6px 4px; font-size: 0.8rem; }

  /* ---- Spezifizitäts-Overrides: Portrait-Tab-Regeln zurücksetzen ---- */
  /* Portrait-Regeln (#game-area.tab-xyz #element) haben Spezifizität 2,1,0 und
     schlagen einfache ID-Selektoren 1,0,0 im Landscape-Block. Durch identische
     Selektoren hier (später im Cascade) werden sie korrekt überschrieben.      */

  #game-area.tab-spielfeld #action-panel,
  #game-area.tab-spieler   #action-panel,
  #game-area.tab-log       #action-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid var(--border);
  }

  #game-area.tab-spielfeld #sidebar,
  #game-area.tab-spieler   #sidebar,
  #game-area.tab-log       #sidebar {
    border-top: none;
    width: 160px;
    overflow: hidden;
  }

  #game-area.tab-spielfeld #log-container,
  #game-area.tab-spieler   #log-container,
  #game-area.tab-log       #log-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 6px 8px;
  }

  #game-area.tab-spielfeld #board-container,
  #game-area.tab-spieler   #board-container,
  #game-area.tab-log       #board-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    min-height: 0;
    min-width: 0;
  }

  #game-area.tab-spieler #player-panels,
  #game-area.tab-log     #player-panels {
    display: none;
  }

  /* ---- Aktiver Spieler (Querformat-Sidebar) ---- */
  #mobile-player-info {
    display: block;
    width: 100%;
    padding-top: 6px;
    margin-top: 2px;
    border-top: 1px solid var(--border);
  }

  .mpi-header {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.75rem;
    margin-bottom: 3px;
  }

  .mpi-name {
    flex: 1;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mpi-gems { color: #f1c40f; font-size: 0.75rem; }

  .mpi-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
}

/* ---- Vollbild-Modus ---- */
.board-fullscreen #topbar { display: none; }
.board-fullscreen #sidebar { display: none !important; }
.board-fullscreen #mobile-tab-bar { display: none !important; }
.board-fullscreen #player-panels { display: none !important; }

.board-fullscreen #game-area {
  flex-direction: column;
}

.board-fullscreen #board-container {
  flex: 1 !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 0;
  min-height: 0;
}

/* Schwebender Würfel-Button */
#btn-roll-float {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 50;
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 50px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#btn-roll-float:active { opacity: 1; }
#btn-roll-float:disabled { opacity: 0.35; cursor: not-allowed; }

/* Vollbild-Exit-Button */
#btn-fullscreen-exit {
  display: none;
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 51;
  background: rgba(13,17,23,0.85);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.85rem;
  cursor: pointer;
}

.board-fullscreen #btn-roll-float { display: block; }
.board-fullscreen #btn-fullscreen-exit { display: block; }
.board-fullscreen #fullscreen-hud { display: flex; }

/* ---- Fullscreen HUD ---- */
#fullscreen-hud {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 49;
  pointer-events: none;
}

#fs-player-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(13,17,23,0.5);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 8px 16px;
  pointer-events: all;
  backdrop-filter: blur(6px);
}

#fs-player-name {
  font-weight: 700;
  font-size: 0.95rem;
}

#fs-player-gems {
  color: #f1c40f;
  font-weight: 600;
  font-size: 0.9rem;
  margin-left: 4px;
}

#fs-items {
  display: flex;
  gap: 4px;
  margin-left: 6px;
}

#fs-items button {
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 1rem;
  cursor: pointer;
}

#fs-items .shield-info {
  font-size: 0.85rem;
  color: #3498db;
  align-self: center;
}

#fs-event {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(13,17,23,0.88);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 0.85rem;
  text-align: center;
  backdrop-filter: blur(6px);
  max-width: calc(100vw - 20px);
  transition: opacity 0.4s;
  white-space: nowrap;
}

#fs-event:empty { display: none; }
#fs-event.fs-fade { opacity: 0; }
