/* --- ZMIENNE GLOBALNE I RESET --- */
:root {
  --color-bg: #1a1c20;
  --color-primary: #0d6efd;
  --color-glow: #0079b6;
  --color-surface: #2c2f36;
  --color-border: #444857;
  --color-text: #e0e1e6;
  --color-text-muted: #8e9299;
  --font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
  --ui-scale: 1;
}

.hidden {
    display: none !important;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-surface);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  overflow: hidden;
  font-size: calc(16px * var(--ui-scale));
}

/* --- STYLE EKRANÓW I MENU --- */
.screen {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 20px;
  padding: 20px;
}

.screen.active {
  display: flex;
}

#game-container {
  align-items: flex-start;
  padding-top: 2vh;
}

.game-title {
  font-size: 3.5rem;
  color: var(--color-primary);
  text-shadow: 0 0 15px var(--color-glow);
}

.menu-title {
  font-size: 2.5rem;
  margin-bottom: 20px;
  color: var(--color-text);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 10px;
}

/* --- PRZYCISKI I ELEMENTY FORMULARZA --- */
.btn {
  background-color: transparent;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 0 5px transparent;
}

.btn:hover {
  background-color: var(--color-primary);
  color: var(--color-bg);
  box-shadow: 0 0 15px var(--color-glow), inset 0 0 10px rgba(0, 170, 255, 0.5);
}

.button-group {
    display: flex;
    gap: 20px;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 15px;
  font-size: 1.1rem;
}

select,
input[type='range'] {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 5px;
  border-radius: 4px;
}

#card-pool-text {
    margin-bottom: 15px;
    text-align: center;
    font-style: italic;
    color: var(--color-text-muted);
}

/* --- UKŁAD PLANSZY GRY --- */
#game-board {
  width: 98vw;
  height: 98vh;
  transform-origin: top center;
  padding: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
  grid-template-rows: auto auto 1fr auto 35px;
  gap: 30px 10px;
  grid-template-areas:
    'specials  line-up      line-up      line-up      line-up        stacks'
    'specials  play-area    play-area    play-area    play-area      stacks'
    'specials   .            .            .            .              stacks'
    'specials   player-hand  player-hand  player-hand  player-superhero player-superhero'
    '.         menu-bar     menu-bar     menu-bar     menu-bar       .';
}

/* --- PRZYPISANIE OBSZARÓW I WYRÓWNANIE --- */
#line-up-container {
  grid-area: line-up;
  overflow: visible;
  justify-self: center;
}

#stacks-container {
  grid-area: stacks;
}

#specials-container {
  grid-area: specials;
  align-self: start;
}

#play-area-container {
  grid-area: play-area;
  padding-top: 25px;
  overflow: visible;
  justify-self: center;
  min-height: 200px;
  max-width: 585px;
}

#player-superhero-container {
  grid-area: player-superhero;
  flex-direction: column;
  justify-content: flex-start;
  justify-self: start;
  gap: 20px;
}

#player-hand-container {
  grid-area: player-hand;
  overflow: visible;
  max-width: 900px;
}

#hand-cards-wrapper,
#play-area-wrapper {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  gap: 10px;
  padding: 15px;
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
  overflow-x: auto;
}

#hand-cards-wrapper.active,
#play-area-wrapper.active {
  cursor: grabbing;
}

#hand-cards-wrapper::-webkit-scrollbar,
#play-area-wrapper::-webkit-scrollbar {
  display: none;
}

#menu-bar-container {
  grid-area: menu-bar;
  background-color: var(--color-surface);
  border-radius: 5px;
  height: 100%;
  width: fit-content;
  justify-self: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 15px;
  padding: 0 15px;
}

#hud-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
}

#power-display {
  color: var(--color-glow);
  font-size: 1.5rem;
  font-weight: bold;
  text-shadow: 0 0 8px var(--color-glow);
}

#end-turn-button {
  width: 100%;
  max-width: 180px;
}

/* --- STYLE DLA KONTENERÓW Z ZAGNIEŻDŻONĄ SIATKĄ --- */
.nested-grid-container {
  display: grid;
  gap: 20px;
  justify-items: center;
  align-content: start;
}

#specials-container {
  grid-template-columns: 1fr;
  grid-template-rows: repeat(5, auto);
}

#stacks-container {
  grid-template-rows: repeat(3, auto);
}

/* --- OGÓLNE STYLE STREF I KART --- */
.game-zone {
  background-color: rgba(44, 47, 54, 0.6);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 10px;
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  align-content: center;
}

.deck-stack {
  position: relative;
}

.game-zone[data-zone-name]::before {
  content: attr(data-zone-name);
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--color-border);
  color: var(--color-text-muted);
  padding: 2px 8px;
  font-size: 0.75rem;
  border-radius: 4px;
  font-weight: bold;
  white-space: nowrap;
  z-index: 1;
}

.card {
  width: 130px;
  height: 182px;
  background-color: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  position: relative;
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 1.2rem;
  font-weight: bold;
  color: var(--color-text-muted);
}

.card:hover {
  transform: scale(1.05);
  z-index: 10;
  box-shadow: 0 0 15px var(--color-glow);
  border-color: var(--color-glow);
}

.card.disabled {
  filter: grayscale(100%) brightness(0.6);
  cursor: not-allowed;
}

.card.disabled:hover {
  transform: none;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
  border-color: var(--color-border);
}

.card-placeholder-dashed,
.lineup-placeholder {
  width: 130px;
  height: 182px;
  border: 2px dashed var(--color-border);
  border-radius: 6px;
  opacity: 0.6;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 10px;
  font-size: 1rem;
  color: var(--color-text-muted);
}

#main-deck-container .card:hover,
#weakness-stack-container .card:hover,
#player-deck-container .card:hover,
#destroyed-pile-container .card:hover {
    transform: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    border-color: var(--color-border);
    cursor: default;
}

/* --- SEKCJA DEBUGOWANIA I PASKA MENU --- */
#debug-toggle-button,
#settings-ingame-button,
#reset-game-button,
#exit-game-button {
  background: none;
  border: none;
  padding: 5px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
}

#debug-toggle-button svg,
#settings-ingame-button svg,
#reset-game-button svg,
#exit-game-button svg {
  width: 24px;
  height: 24px;
  fill: var(--color-text-muted);
  transition: all 0.2s ease-in-out;
}

#debug-toggle-button:hover svg,
#settings-ingame-button:hover svg,
#reset-game-button:hover svg,
#exit-game-button:hover svg {
  fill: var(--color-glow);
  transform: scale(1.15);
  filter: drop-shadow(0 0 4px var(--color-glow));
}

#debug-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--color-bg);
  border: 2px solid var(--color-primary);
  border-radius: 8px;
  padding: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 15px;
  box-shadow: 0 0 20px rgba(0, 170, 255, 0.5);
  min-width: 350px;
}

#debug-panel.hidden {
  display: none;
}

#debug-panel h3 {
  cursor: move;
  user-select: none;
  text-align: center;
  margin-bottom: 10px;
}

.debug-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

#debug-selection-container {
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}

#debug-selection-container label {
  margin-bottom: 5px;
}

#debug-selection-container select {
  width: auto;
  min-width: 250px;
  margin-bottom: 10px;
}

#debug-selection-container button {
  margin-right: 5px;
}

/* --- Dodatkowe style dla zawartości panelu debugowania --- */

#debug-panel button {
  background-color: transparent;
  border: 1px solid var(--color-primary);
  color: var(--color-primary);
  padding: 6px 12px;
  font-size: 0.9rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px;
}

#debug-panel button:hover {
  background-color: var(--color-primary);
  color: var(--color-bg);
  box-shadow: 0 0 10px var(--color-glow);
}

#debug-panel select {
  background-color: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  padding: 5px;
  border-radius: 4px;
  margin: 5px 0 10px; /* Dodaje trochę odstępu */
}

/* --- SEKCJA MODALI --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay:not(.hidden) {
  opacity: 1;
  pointer-events: all;
}

#card-inspector-modal {
  z-index: 4000;
}

.modal-content {
  position: relative;
  transform: scale(0.95);
  max-width: 450px;
  transition: transform 0.2s ease;
}

.modal-overlay:not(.hidden) .modal-content {
  transform: scale(1);
}

.modal-content img {
  width: 100%;
  border-radius: 15px;
  border: 2px solid var(--color-border);
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
}

.close-button {
  position: absolute;
  top: -15px;
  right: -15px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: var(--color-primary);
  color: white;
  border: 2px solid var(--color-bg);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  line-height: 1;
  z-index: 1;
}

.close-button:hover {
  transform: scale(1.1);
  box-shadow: 0 0 10px var(--color-glow);
}

#debug-panel .close-button {
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  font-size: 20px;
}

#debug-panel .close-button:hover {
  background-color: red;
  color: white;
  transform: none;
  box-shadow: none;
}

.settings-modal {
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
  width: auto;
  min-width: 400px;
}

.settings-modal .menu-title {
  margin-top: 0;
}

.settings-modal .setting-item {
  justify-content: space-between;
}

.confirmation-modal {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
  width: 90%;
  max-width: 450px;
}

.confirmation-modal p {
  font-size: 1.2rem;
  margin-bottom: 25px;
  color: var(--color-text);
}

.confirmation-buttons {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.btn-secondary {
  background-color: transparent;
  border-color: var(--color-text-muted);
  color: var(--color-text-muted);
}

.btn-secondary:hover {
  background-color: var(--color-text-muted);
  color: var(--color-bg);
  box-shadow: 0 0 10px var(--color-text-muted);
}

.choice-modal {
  display: flex;
  flex-direction: column !important;
  gap: 15px;
  background-color: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 20px;
  width: fit-content;
  max-width: calc(6 * 100px + 7 * 10px + 20px);
  height: fit-content;
  max-height: calc(4 * 140px + 5 * 10px + 120px);
  box-shadow: 0 0 25px rgba(0, 0, 0, 0.7);
}

.choice-modal h3 {
  text-align: center;
  color: var(--color-primary);
  margin: 0;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.card-list-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  overflow-y: auto;
  flex-grow: 1;
  padding: 10px;
  background-color: var(--color-surface);
  border-radius: 6px;
  justify-content: center;
}

.card-list-container .card {
  width: 100px;
  height: 140px;
}

.choice-modal-buttons {
  display: flex;
  justify-content: center;
  gap: 15px;
}

.choice-modal .btn {
  align-self: center;
  padding: 8px 20px;
}

.choice-modal.mandatory-choice #choice-modal-cancel {
  display: none !important;
}

.card-list-container .card.selected {
  box-shadow: 0 0 20px var(--color-glow);
  border-color: var(--color-primary);
  transform: scale(1.05);
}

/* --- Style dla modala z inputem --- */

.input-modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 25px 0;
}

.input-modal-body label {
    font-size: 1.1rem;
}

.input-modal-body input[type="number"] {
    width: 80px;
    padding: 8px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    color: var(--color-text);
    font-size: 1.1rem;
    border-radius: 4px;
    text-align: center;
}

/* --- Style dla modala z kartą i pytaniem --- */
#card-prompt-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    margin: 15px 0;
    padding: 15px;
    background-color: var(--color-surface);
    border-radius: 6px;
}

#card-prompt-card-area {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    width: 100%;
}

#card-prompt-card-area .card {
    width: 100px;
    height: 140px;
    flex-shrink: 0;
    cursor: default;
}

#card-prompt-card-area .card:hover {
    transform: none;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    border-color: var(--color-border);
}

#card-prompt-text {
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    width: 100%;
}

.card-list-container p {
    color: var(--color-text-muted);
    font-style: italic;
}

.choice-modal.superhero-selection-modal .card-list-container {
    max-width: fit-content;
}

.choice-modal.superhero-selection-modal .card {
    width: 130px;
    height: 182px;
}

/* --- SEKCJA ROZMIARÓW SPECJALNYCH --- */
#kick-stack-container,
#weakness-stack-container,
#discard-pile-container,
#destroyed-pile-container {
  width: 120px;
  height: 160px;
}

#kick-stack-container .card,
#weakness-stack-container .card,
#locations-container .card,
#discard-pile-container .card,
#destroyed-pile-container .card,
#play-area-container .card {
  width: 100px;
  height: 140px;
}

#kick-stack-container .card-placeholder-dashed,
#weakness-stack-container .card-placeholder-dashed,
#locations-container .card-placeholder-dashed,
#discard-pile-container .card-placeholder-dashed,
#destroyed-pile-container .card-placeholder-dashed {
  width: 100px;
  height: 140px;
}

#super-villain-stack-container,
#super-villain-stack-container .card-placeholder-dashed {
  width: 150px;
  height: 200px;
}

#super-villain-stack-container .card {
  width: 130px;
  height: 182px;
}

#superhero-card-area {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.inspector-content {
    display: flex;
    align-items: flex-start;
    gap: 25px;
    background-color: var(--color-surface);
    padding: 25px;
    border-radius: 12px;
    border: 1px solid var(--color-border);
    max-width: 800px; /* Maksymalna szerokość całego modala */
}

.inspector-content img {
    width: 380px;
    height: auto;
    border-radius: 10px;
    border: none;
    box-shadow: none;
}

#inspector-description-panel {
    flex: 1;
    min-width: 280px;
    color: var(--color-text);
}

#inspector-description-panel h4 {
    color: var(--color-primary);
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 10px;
    margin-top: 5px;
    margin-bottom: 15px;
    font-size: 1.2rem;
}

#inspector-description-panel p {
    font-size: 1rem;
    line-height: 1.6;
    white-space: pre-wrap;
}