body {
  margin: 0;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: sans-serif;
  background: #eee; /* Sarà schiarito al colore del giocatore alla fine del turno */
  height: 100vh;
}

/* Menu & Game container */
#menu,
#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

#menu {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: radial-gradient(1200px 600px at 20% 20%, #ffffff, #e7edf5);
  padding: 24px;
  z-index: 10;
  overflow-y: auto;
  padding-bottom: 80px;
}

/* Menu card */
.menu-card {
  width: min(96vw, 980px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  padding: 22px 24px;
  margin: 12px auto 32px auto;
}
.menu-header h1 { margin: 0 0 6px 0; font-size: 28px; }
.menu-header .subtitle { margin: 0 0 16px 0; color: #60708a; }
.menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}
.menu-column {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
@media (min-width: 960px) {
  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.form-group, .menu-network { background: #f7f9fc; border: 1px solid #e7eef7; border-radius: 12px; padding: 14px; }
.group-title { font-weight: 700; margin-bottom: 10px; color: #394b67; }
.form-row { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.form-row label { flex: 1; font-weight: 600; color: #334155; }
.form-row select, .form-row input[type=number] { flex: 1; max-width: 220px; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; }
.ghost-btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #1f2937;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
}
.ghost-btn:hover { background: #f1f5f9; }
.shrink-anim-controls,
.shrink-coverage-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}
.shrink-coverage-controls input[type=number] {
  width: 120px;
  max-width: 120px;
}
.player-type-list { display: flex; flex-direction: column; gap: 6px; }
.player-type-list[aria-hidden="true"] { display: none; }
.player-type-list .form-row { margin: 6px 0; }
.checkbox-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; font-weight: 600; color: #334155; }
.player-type-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.player-type-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.player-name-group { display: flex; align-items: center; gap: 8px; flex: 1 1 240px; min-width: 220px; }
.player-name-input {
  flex: 1 1 140px;
  min-width: 140px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  font-weight: 600;
  color: #0f172a;
}
.player-type-row .player-type-toggle { flex: 0 0 auto; padding: 8px 10px; border: 1px solid #cbd5e1; border-radius: 8px; background: #fff; font-weight: 700; cursor: pointer; }
.player-type-row .player-type-toggle[aria-pressed="true"] { background: #111827; color: #fff; border-color: #111827; }
.player-type-row .player-type-toggle:disabled { cursor: not-allowed; opacity: 0.6; }
.player-field { display: flex; flex-direction: column; gap: 4px; min-width: 110px; }
.player-field-label { font-size: 0.72em; color: #64748b; font-weight: 600; }
.player-character-field {
  flex: 1 1 100%;
  cursor: pointer;
}
.player-character-field .player-field-label {
  cursor: inherit;
}
.player-character-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.player-character-nav {
  width: 30px;
  height: 40px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-weight: 700;
  color: #111827;
}
.player-character-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.player-character-preview-canvas {
  width: 64px;
  height: 64px;
}
.player-character-name {
  font-size: 0.7em;
  color: #334155;
  text-align: center;
  line-height: 1.1;
}
.player-color-field { flex: 1 1 100%; }
.player-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(24px, 1fr));
  gap: 6px;
  padding: 6px 0 2px;
}
.player-color-swatch {
  width: 26px;
  height: 26px;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
}
.player-color-swatch.selected {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.15);
}
.player-color-swatch:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.character-picker-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 30;
}
.character-picker-modal.active { display: flex; }
.character-picker-card {
  width: min(860px, 92vw);
  max-height: 80vh;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
}
.character-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 700;
  color: #0f172a;
}
.character-picker-header button {
  border: none;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.character-picker-grid {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 12px;
  overflow: auto;
}
.character-picker-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  color: #1f2937;
}
.character-picker-option.selected {
  border-color: #111827;
  box-shadow: 0 0 0 2px rgba(17, 24, 39, 0.15);
}
.character-picker-canvas {
  width: 70px;
  height: 70px;
}
.player-name-input:disabled { cursor: not-allowed; opacity: 0.6; }
.powerup-options { display: none; flex-direction: column; gap: 6px; margin-top: 6px; padding-left: 18px; }
.powerup-options[aria-hidden="false"] { display: flex; }
.menu-actions { display: flex; justify-content: flex-end; margin-top: 14px; gap: 8px; flex-wrap: wrap; }
.menu-actions button:not(.primary) { font-size: 0.95em; padding: 9px 14px; border-radius: 10px; }
.menu-actions .primary { font-size: 1.05em; padding: 10px 18px; border-radius: 10px; border: none; color: #fff; background: linear-gradient(180deg, #3b82f6, #2563eb); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.35); cursor: pointer; }
.menu-actions .primary:hover { filter: brightness(1.05); }
.menu-actions .primary:active { transform: translateY(1px); }
.preset-preview {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  margin-left: 8px;
}
.preset-preview .title {
  font-size: 12px;
  color: #334155;
  white-space: nowrap;
}
.preset-preview-grid {
  display: grid;
  gap: 2px;
  border: 1px solid #cbd5e1;
  padding: 4px;
  background: #fff;
  border-radius: 6px;
}
.preset-preview-cell {
  width: 8px;
  height: 8px;
  background: #e2e8f0;
  position: relative;
}
.preview-mode-dots .preset-preview-cell.seed {
  border-radius: 50%;
}
.preview-mode-tiles .preset-preview-cell.seed {
  border-radius: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.55), inset 0 0 0 1px rgba(15,23,42,0.18);
}

#game-container {
  display: none; /* Shown after Start */
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 110px 20px 20px;
  box-sizing: border-box;
  gap: 16px;
}
@media (max-width: 720px) {
  #game-container {
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* Contenitore Pixi */
#pixiContainer {
  /* Dimensioni regolate da JS */
  margin: 0 auto;
  position: relative;
}

/* Restart Button (in-game) */
#restartGameButton,
#pauseGameButton {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 100;
  font-size: 1.2em;
  padding: 5px 10px;
}
#pauseGameButton {
  right: 100px;
}
#slowMoControl {
  position: absolute;
  top: 10px;
  right: 200px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
  font-size: 12px;
}
#slowMoSlider {
  width: 110px;
}
#slowMoValue {
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Leaderboard Styles */
#leaderboard {
  width: 220px;
  background: #f5f5f5;
  padding: 10px;
  border-radius: 10px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  max-height: 70vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: fixed;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
}

/* Entry Leaderboard */
.leaderboard-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease, background-color 0.3s ease;
}

/* Blob */
.blob {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: #ffffff;
  margin-right: 10px;
  flex-shrink: 0;
}

/* Nome e conteggio giocatore */
.player-info {
  display: flex;
  align-items: center;
}

.player-name {
  font-weight: bold;
  font-size: 0.9em;
}

.player-count {
  font-weight: bold;
  font-size: 0.9em;
  margin-left: auto;
}

.leaderboard-entry * {
  pointer-events: none;
}

/* Endgame Overlay */
#endgameOverlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.95);
  padding: 30px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 20;
}

#endgameOverlay h1 {
  margin-bottom: 20px;
}

#endgameOverlay button {
  padding: 10px 20px;
  font-size: 1em;
  border: none;
  border-radius: 5px;
  background-color: #1976d2;
  color: #fff;
  cursor: pointer;
  transition: background-color 0.3s;
}
#endgameOverlay button:hover {
  background-color: #115293;
}

/* Defeat Overlay */
.overlay-hidden {
  display: none !important;
}

#defeatOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  backdrop-filter: blur(4px);
}

.defeat-card {
  background: white;
  padding: 40px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
  max-width: 400px;
  width: 90%;
}

.defeat-card h1 {
  color: #d32f2f;
  font-size: 3rem;
  margin: 0 0 10px 0;
}

.defeat-card p {
  color: #334155;
  font-size: 1.2rem;
  margin-bottom: 30px;
}

.defeat-card .defeat-best {
  font-size: 1.05rem;
  color: #1f2937;
  margin: 0 0 24px 0;
}

.defeat-card button {
  padding: 12px 24px;
  font-size: 1rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.defeat-card button:hover {
  background: #2563eb;
}

/* Pause & Confirm Overlays */
#pauseOverlay,
#confirmOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
}
#reportOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12px;
  z-index: 130;
  pointer-events: none;
}
.pause-card,
.confirm-card {
  width: min(92vw, 420px);
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}
.pause-card h1 {
  margin: 0 0 8px 0;
  font-size: 28px;
}
.pause-card p,
.confirm-card p {
  margin: 0 0 18px 0;
  color: #334155;
}
.pause-actions,
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.pause-actions button,
.confirm-actions button {
  padding: 10px 16px;
  font-size: 1rem;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}
.pause-actions .primary,
.confirm-actions .primary {
  border: none;
  background: #2563eb;
  color: #fff;
}
.pause-actions .primary:hover,
.confirm-actions .primary:hover {
  background: #1d4ed8;
}
.report-card {
  background: rgba(255, 255, 255, 0.98);
  padding: 22px;
  border-radius: 14px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0,0,0,0.2);
  min-width: 260px;
  pointer-events: auto;
}
.report-card h2 { margin: 0 0 8px 0; }
.report-card p { margin: 0 0 12px 0; color: #475569; }
#reportReadout { font-weight: 700; margin-bottom: 12px; color: #111827; }
.report-actions { display: flex; justify-content: center; gap: 10px; }
.report-actions button {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #0f172a;
  background: #0f172a;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
.report-actions button:hover {
  background: #1e293b;
}

#boardOverlay {
  position: absolute;
  display: none;
  pointer-events: none;
  z-index: 45;
  overflow: visible;
}
#boardOverlay.active {
  display: block;
  pointer-events: auto;
}
#boardOverlay.labels-active {
  display: block;
  pointer-events: none;
}
.board-overlay-top,
.board-overlay-left {
  position: absolute;
  display: flex;
  gap: 0;
  font-size: 12px;
  font-weight: 700;
  color: #0f172a;
}
.board-overlay-top { top: -18px; left: 0; height: 18px; }
.board-overlay-left { top: 0; left: -18px; width: 18px; flex-direction: column; }
.board-overlay-top span,
.board-overlay-left span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.board-overlay-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.2) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.2) 1px, transparent 1px);
}

/* Pause state */
#game-container.paused #pixiContainer {
  pointer-events: none;
  filter: grayscale(0.1);
}

/* Timer Display */
#timerDisplay {
  width: min(92vw, 720px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--timer-ink, #111);
  box-shadow: none;
  font-size: 1rem;
  text-align: center;
  z-index: 50;
}
.skip-turn-btn {
  margin-top: 4px;
}
#replayOverlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 16px;
  background: rgba(0, 0, 0, 0.5);
  z-index: 140;
}
.replay-card {
  background: #ffffff;
  color: #111;
  border-radius: 16px;
  padding: 16px;
  width: min(360px, 88vw);
  box-shadow: 0 12px 40px rgba(0,0,0,0.25);
  text-align: center;
}
.replay-card h1 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}
.replay-card p {
  margin: 0 0 12px;
  opacity: 0.8;
  font-size: 0.9rem;
}
.replay-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.replay-speed {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}
.replay-speed input[type="range"] {
  width: 120px;
}
.replay-actions {
  display: flex;
  justify-content: center;
}
.timer-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}
.player-timer {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: 0.3px;
}
.timer-detail {
  font-size: 1.05rem;
  font-weight: 600;
  opacity: 0.85;
}
.shrink-buffer {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.shrink-buffer[aria-hidden="true"] {
  display: none;
}
.shrink-buffer-label {
  font-size: 0.95rem;
  font-weight: 700;
}
.shrink-buffer-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.12);
  overflow: hidden;
}
.shrink-buffer-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: #2b2f36;
  transition: width 0.25s ease;
}

#commentaryBar { display: none; }

#newsBox { position: fixed; left: 10px; bottom: 10px; width: 360px; max-width: 92vw; max-height: 38vh; display: none; flex-direction: column; background: rgba(255,255,255,0.97); border: 1px solid rgba(0,0,0,0.08); border-radius: 12px; box-shadow: 0 10px 24px rgba(0,0,0,0.10); overflow: hidden; z-index: 60; }
.news-header { display: flex; align-items: center; padding: 8px 12px; background: linear-gradient(180deg, #f5f7fb, #eaf0f8); border-bottom: 1px solid rgba(0,0,0,0.06); }
.news-header #newsMinBtn { margin-left: auto; border: none; background: transparent; cursor: pointer; font-size: 16px; color: #1f2a44; }
.news-logo { font-size: 14px; color: #1f2a44; letter-spacing: 0.2px; }
#newsFeed { overflow-y: auto; padding: 8px 8px 10px 8px; display: flex; flex-direction: column; gap: 6px; }
.collapsed #newsFeed { display: none; }
.collapsed { height: auto; width: auto; }
.news-item { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.25; color: #0f172a; }
.news-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 4px; flex-shrink: 0; box-shadow: 0 0 0 2px rgba(0,0,0,0.05); }
.news-text { flex: 1; }
.news-meta { color: #64748b; font-size: 11px; }

@media (max-width: 900px) {
  #leaderboard {
    position: static;
    transform: none;
    width: min(92vw, 360px);
    max-height: 40vh;
    margin-top: 8px;
  }
  #game-container {
    padding-top: 120px;
  }
#newsBox { left: 50%; transform: translateX(-50%); width: 92vw; }
}

@media (max-width: 600px) {
  #restartGameButton {
    right: 10px;
    top: 10px;
  }
  #pauseGameButton {
    right: 10px;
    top: 54px;
  }
  #slowMoControl {
    right: 10px;
    top: 98px;
  }
}

@media (max-width: 900px), (orientation: portrait) {
  .menu-grid {
    grid-template-columns: 1fr;
  }
  .menu-actions {
    position: sticky;
    bottom: 0;
    background: rgba(255, 255, 255, 0.96);
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    justify-content: center;
    z-index: 12;
  }
  .menu-actions button {
    width: min(92vw, 440px);
  }
}

@media (max-width: 600px) {
  #menu {
    padding: 12px;
  }
  .menu-card {
    width: 100%;
    padding: 16px;
    margin: 8px auto 20px auto;
    border-radius: 14px;
  }
  .menu-grid {
    gap: 14px;
  }
  .form-group,
  .menu-network {
    width: 100%;
    padding: 14px;
  }
  .form-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .form-row label {
    width: 100%;
  }
  .form-row select,
  .form-row input[type=number] {
    max-width: 100%;
    width: 100%;
  }
  .menu-actions {
    width: 100%;
    box-sizing: border-box;
  }
  .menu-actions button {
    width: 100%;
  }
}

/* Preview modal */
#previewModal { position: fixed; inset: 0; background: rgba(0,0,0,0.35); display: none; align-items: center; justify-content: center; z-index: 200; }
#previewModal[aria-hidden="false"] { display: flex; }
.preview-card { width: min(92vw, 560px); background: #fff; border-radius: 12px; box-shadow: 0 14px 40px rgba(0,0,0,0.25); }
.preview-header { display:flex; align-items:center; justify-content:space-between; padding:10px 12px; border-bottom:1px solid #e5e7eb; }
.preview-header button { border:none; background:transparent; font-size:16px; cursor:pointer; }
#previewStage { position: relative; width: 520px; max-width: 92vw; height: 300px; background: #f5f7fb; border-radius: 0 0 12px 12px; overflow: hidden; }
.pv-board { position:absolute; left:50%; top:50%; width: 300px; height: 220px; transform: translate(-50%, -50%); background:#dde6f4; border-radius: 8px; box-shadow: inset 0 0 0 2px #c7d2e5; }
.pv-cell { position:absolute; width: 22px; height: 22px; background:#ffffff; border-radius:5px; box-shadow: 0 1px 0 rgba(0,0,0,0.05); overflow: hidden; }
.pv-bar { position:absolute; background:#111; opacity:0.92; }
.pv-rock { position:absolute; width: 22px; height:22px; background:#000; border-radius:5px; }
.pv-crack { position:absolute; inset:2px; opacity:0; pointer-events:none; }
.pv-crack-line {
  position:absolute;
  left: 3px;
  top: 10px;
  width: 18px;
  height: 1px;
  background: linear-gradient(90deg, rgba(15,23,42,0.85), rgba(15,23,42,0.15));
  transform-origin: 0 50%;
  transform: scaleX(0);
}
#powerupBar {
  display: none;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  position: relative;
}
.skip-announcement {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 70;
}
.skip-announcement-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: #ffffff;
  padding: 16px 22px;
  border-radius: 16px;
  border: 2px solid rgba(0,0,0,0.08);
  box-shadow: 0 12px 24px rgba(0,0,0,0.2);
}
.skip-announcement[aria-hidden="false"] {
  opacity: 1;
  transform: scale(1);
}
.skip-announcement-text {
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 0;
}
.skip-announcement-thanks {
  font-size: 42px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.preform-menu,
#preformMenu {
  display: none;
  position: absolute;
  left: 20px;
  bottom: 20px;
  background: rgba(255,255,255,0.94);
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 10px 22px rgba(0,0,0,0.12);
  z-index: 55;
  min-width: 220px;
}
#preformMenu[aria-hidden="false"] { display: block; }
.preform-header {
  font-weight: 800;
  margin-bottom: 8px;
  color: #0f172a;
}
.preform-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preform-controls button {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
}
.preform-preview {
  display: grid;
  grid-template-columns: repeat(5, 12px);
  grid-template-rows: repeat(5, 12px);
  gap: 2px;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: #fff;
}
.preform-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: #e5e7eb;
  font-size: 8px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
}
.preform-cell.active {
  background: #111827;
  color: #fff;
}
.preform-actions {
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.preform-actions button {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
}
.preform-hint {
  margin-top: 6px;
  font-size: 12px;
  color: #475569;
}
.powerup-btn {
  border: 1px solid #cbd5e1;
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border-radius: 10px;
  padding: 8px 12px 6px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 110px;
}
.powerup-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.powerup-label {
  line-height: 1.1;
}
.powerup-ammo {
  font-size: 12px;
  font-weight: 800;
  color: #0f172a;
  background: #e2e8f0;
  border-radius: 999px;
  padding: 2px 8px;
  min-width: 36px;
  text-align: center;
  line-height: 1.2;
}
.powerup-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.powerup-row > span {
  flex: 1;
}
.powerup-ammo-input {
  max-width: 70px;
}
.powerup-ammo-input:disabled {
  background: #e2e8f0;
  color: #64748b;
  cursor: not-allowed;
}
.powerup-shared-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.inset-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.inset-control input[type=number] {
  max-width: 80px;
  text-align: center;
}
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #f1f5f9; }
.player-count-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.player-count-control input[type=number] {
  max-width: 90px;
  text-align: center;
  flex: 1;
}
.graphics-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  padding: 6px 8px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  min-height: 52px;
  gap: 8px;
}
.graphics-preview-canvas {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}
.graphics-nav {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  background: #fff;
  font-weight: 700;
  cursor: pointer;
}
.graphics-nav:hover { background: #f1f5f9; }
.graphics-preview canvas {
  display: block;
}
.ghost-btn {
  margin-top: 8px;
}
.mitosis-preview {
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}
.mitosis-preview[aria-hidden="true"] {
  display: none;
}
.mitosis-preview-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 6px;
}
.mitosis-preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #475569;
}
.mitosis-preview-controls select {
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 4px 8px;
  background: #ffffff;
  color: #0f172a;
}
.mitosis-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.mitosis-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}
.mitosis-preview-card.selected {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}
.mitosis-preview-label {
  font-size: 11px;
  color: #475569;
}
.mitosis-preview-frame {
  width: 48px;
  height: 48px;
  object-fit: contain;
  image-rendering: auto;
}
.explosion-preview {
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
}
.explosion-preview[aria-hidden="true"] {
  display: none;
}
.missile-preview-panel {
  margin-top: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.missile-preview-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.missile-preview-canvas {
  width: 96px;
  height: 96px;
}
.explosion-preview-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  margin-bottom: 6px;
}
.explosion-preview-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #475569;
}
.explosion-preview-controls select {
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 4px 8px;
  background: #ffffff;
  color: #0f172a;
}
.explosion-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.explosion-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
}
.explosion-preview-label {
  font-size: 11px;
  color: #475569;
}
.explosion-preview-canvas {
  width: 56px;
  height: 56px;
  display: block;
}
.explosion-preview-card.selected {
  border-color: #38bdf8;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}
.graphics-preview-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
}
.graphics-preview-fallback-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  position: relative;
  overflow: hidden;
}
.graphics-preview-fallback-dot {
  width: 40%;
  height: 40%;
  border-radius: 50%;
}
.graphics-preview-fallback-img {
  width: 80%;
  height: auto;
  image-rendering: pixelated;
}
.graphics-preview-fallback-empty {
  width: 60%;
  height: 60%;
  border: 2px dashed #94a3b8;
  border-radius: 10px;
}
.powerup-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  filter: grayscale(0.4);
}
.powerup-btn.active {
  border-color: #3b82f6;
  box-shadow: 0 6px 14px rgba(59,130,246,0.35);
  transform: translateY(-1px);
}
.powerup-shapes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.powerup-shapes[aria-hidden="true"] { display: none; }
.powerup-gain-bar {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(255,255,255,0.9);
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
  margin-top: 8px;
}
.powerup-gain-bar[aria-hidden="false"] { display: flex; }
.powerup-shape-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.powerup-shape-card.selected,
.powerup-gain-shape.selected {
  border-color: #3b82f6;
  box-shadow: 0 6px 14px rgba(59,130,246,0.35);
}
.powerup-shape-grid {
  display: grid;
  grid-template-columns: repeat(3, 16px);
  grid-template-rows: repeat(3, 16px);
  gap: 3px;
}
.powerup-shape-cell {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #0f172a;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.powerup-shape-cell.core {
  background: #111827;
  color: #ffffff;
}
.powerup-gain-shape {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: rgba(255,255,255,0.85);
  cursor: pointer;
  position: relative;
}
.powerup-gain-popup {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: rgba(17,24,39,0.9);
  color: #ffffff;
  border-radius: 999px;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 20;
}
.powerup-gain-popup.show {
  opacity: 1;
}
.powerup-gain-grid {
  display: grid;
  grid-template-columns: repeat(3, 12px);
  grid-template-rows: repeat(3, 12px);
  gap: 2px;
}
.powerup-gain-shape .powerup-shape-cell {
  width: 12px;
  height: 12px;
  font-size: 8px;
  border-radius: 3px;
}
.powerup-cooldown {
  margin-left: auto;
  font-size: 12px;
  color: #334155;
}

/* Factories Panel */
.factories-panel {
  display: none;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
  max-width: 900px;
}
.factory-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}
.factory-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.factory-card.active {
  border-color: #3b82f6;
  background-color: #eff6ff;
  box-shadow: 0 0 0 2px #3b82f6;
}
.factory-card.disabled {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}
.factory-title {
  font-size: 10px;
  font-weight: 700;
  color: #475569;
}
.factory-grid {
  display: grid;
  gap: 1px;
  background: #cbd5e1;
  padding: 1px;
  border-radius: 2px;
}
.factory-cell {
  width: 18px;
  height: 18px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  border-radius: 2px;
}
.factory-cell.filled {
  background: #64748b;
}
.factory-cell.core {
  background: #0f172a;
}
.factory-status {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  height: 12px;
}
.factory-card.ready .factory-status {
  color: #2563eb;
}
