#game-app, .modal-backdrop {
  --bg-board: #fdf6ea;
  --board-border: #000000;
  --track-rail: #bec6ce;
  --slot-border: #bec6ce;
  --slot-empty-bg: rgba(0, 0, 0, 0.045);
  --text-main: #222222;
  --text-muted: #555555;
  --accent-blue: #3a7ede;
  --accent-yellow: #f7e55f;
  --match-green: #589a56;
  --coral: #ec8d6f;
  --purple: #dcb0ed;
}

#game-app, #game-app *, #game-app *::before, #game-app *::after,
.modal-backdrop, .modal-backdrop *, .modal-backdrop *::before, .modal-backdrop *::after {
  box-sizing: border-box;
}

#game-app {
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  font-family: "Comic Relief", system-ui, sans-serif;
  color: var(--text-main);
}

/* Header & Controls */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  gap: 12px;
}

.title-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.title-group h1 {
  font-size: 1.8rem;
  margin: 0;
  font-weight: 700;
  color: #000;
}

.level-badge {
  font-size: 0.95rem;
  padding: 4px 14px;
  cursor: default;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

button.icon-btn, .icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 !important;
  border: 2px solid #000;
  border-radius: 50% !important;
  cursor: pointer;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
  transition: transform 0.1s ease, background-color 0.1s;
}

button.icon-btn svg, .icon-btn svg {
  display: block;
  flex-shrink: 0;
  pointer-events: none;
}

.icon-btn:hover {
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(1px);
}

.game-instructions {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0 0 10px;
  max-width: 600px;
  line-height: 1.4;
}

/* Status Bar */
.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 680px;
  padding: 2px 12px 10px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.status-bar strong {
  color: #000;
}

/* Main Playfield: Orbit Stage & Canvas */
.playfield-container {
  position: relative;
  width: 100%;
  max-width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  margin-bottom: 16px;
  overflow-x: auto;
  padding: 8px 0;
}

.orbit-stage {
  position: relative;
  --picture-size: 240px;
  width: calc(var(--picture-size) + 128px);
  height: calc(var(--picture-size) + 128px);
  flex-shrink: 0;
  margin: 0 auto;
  background: var(--bg-board);
  border: 2px solid var(--board-border);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}

/* Orbital Perimeter Rail */
.orbit-rail {
  position: absolute;
  inset: 22px;
  border: 2px dashed var(--track-rail);
  border-radius: 16px;
  pointer-events: none;
}

/* Pixel Canvas Container */
.pixel-canvas-wrap {
  position: relative;
  width: calc(var(--picture-size) + 4px);
  height: calc(var(--picture-size) + 4px);
  background-color: #e8edf0;
  border: 2px solid #bec6ce;
  border-radius: 0;
  overflow: hidden;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.04);
}

#pixel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Orbital Vacuum Shuttles Layer */
.orbit-shuttles-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 95;
}

/* Orbital Vacuum Shuttle */
.orbit-shuttle {
  position: absolute;
  width: 44px;
  height: 32px;
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12);
  z-index: 100;
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: box-shadow 0.15s;
}

.orbit-shuttle.active {
  box-shadow: 0 0 12px var(--shuttle-glow, rgba(0, 0, 0, 0.3)), 0 4px 10px rgba(0, 0, 0, 0.15);
}

.orbit-shuttle-core {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--shuttle-color, #ec8d6f);
  border: 1.5px solid rgba(0, 0, 0, 0.2);
}

.orbit-shuttle-count {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #000000;
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid #ffffff;
}

/* Vacuum Beam Stream */
.vacuum-beam-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 80;
}

/* Staging Bays Area */
.staging-section {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
}

.section-label {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.staging-bays-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-board);
  border: 2px solid var(--board-border);
  border-radius: 18px;
}

.staging-slot {
  height: 64px;
  border-radius: 14px;
  border: 2px dotted var(--slot-border);
  background: var(--slot-empty-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.staging-slot.occupied {
  background: #ffffff;
  border: 2px solid var(--board-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  cursor: pointer;
}

.staging-slot.occupied:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 8px rgba(58, 126, 222, 0.25);
}

.staging-slot.occupied.in-flight {
  background: #c6dcfa;
  border-color: var(--accent-blue);
  box-shadow: none;
  cursor: default;
}

@keyframes pulse-inflight {
  from { border-color: #3a7ede; }
  to { border-color: #f7e55f; }
}

.staging-slot.occupied.ready-pulse {
  animation: pulse-ready 1s infinite alternate;
  border-color: var(--match-green);
}

@keyframes pulse-ready {
  from { box-shadow: 0 0 4px rgba(88, 154, 86, 0.3); }
  to { box-shadow: 0 0 12px rgba(88, 154, 86, 0.6); }
}

.slot-color-pip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.2);
  margin-bottom: 2px;
}

.slot-count-badge {
  font-size: 0.85rem;
  font-weight: bold;
  color: #000000;
}

/* Incoming Queues Area */
.queues-section {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 20px;
}

.queues-lanes-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
}

.queue-lane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 8px 6px;
  background: rgba(0, 0, 0, 0.02);
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  min-height: 160px;
}

.queue-card {
  width: 100%;
  height: 56px;
  background: #ffffff;
  border: 2px solid var(--board-border);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.15s, border-color 0.15s;
  position: relative;
}

.queue-card.head-card:hover {
  border-color: var(--accent-blue);
  box-shadow: 0 0 8px rgba(58, 126, 222, 0.25);
}

.queue-card.head-card {
  border-width: 2px;
}

.queue-card.waiting-card {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

.card-color-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid rgba(0, 0, 0, 0.2);
  margin-bottom: 2px;
}

.card-quota-num {
  font-size: 0.85rem;
  font-weight: bold;
  color: #000000;
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 600px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.toolbar button.button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  transition: transform 0.1s ease, background-color 0.1s ease;
}

.toolbar button.button:active {
  transform: translateY(1px);
}

.toolbar button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
  padding: 16px;
}

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

.modal-card {
  background: #ffffff;
  border: 2px solid #000000;
  border-radius: 24px;
  padding: 24px 28px;
  width: 100%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.modal-card h2 {
  font-size: 1.8rem;
  margin: 0 0 12px;
  color: #000000;
}

.modal-card p {
  color: var(--text-muted);
  font-size: 1rem;
  margin-bottom: 16px;
}

/* Settings Card */
.settings-card {
  text-align: left;
}

.settings-card h2 {
  text-align: center;
  margin-bottom: 18px;
}

.setting-row {
  margin-bottom: 16px;
}

.setting-row label {
  display: block;
  font-weight: bold;
  margin-bottom: 6px;
  font-size: 0.95rem;
  color: #333;
}

.setting-row select {
  width: 100%;
  padding: 10px 14px;
  font-size: 1rem;
  font-family: "Comic Relief", system-ui, sans-serif;
  border: 2px solid #000;
  border-radius: 16px;
  background: #ffffff;
  color: #000;
  outline: none;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
}

#game-app .button, .modal-backdrop .button {
  font-family: "Comic Relief", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: bold;
  border: 2px solid #000;
  border-radius: 24px;
  padding: 8px 24px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: #000;
  text-decoration: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);
  transition: transform 0.1s ease, background-color 0.1s ease;
}

#game-app .button:hover, .modal-backdrop .button:hover {
  transform: translateY(-1px);
}

#game-app .button:active, .modal-backdrop .button:active {
  transform: translateY(1px);
}

/* Giraffian Design System Palette for Buttons */
#game-app .button.aqua, .modal-backdrop .button.aqua {
  background-color: #82dee6;
  color: #000000;
}
#game-app .button.aqua:hover, .modal-backdrop .button.aqua:hover {
  background-color: #46ceda;
}

#game-app .button.grey, .modal-backdrop .button.grey {
  background-color: #bec6ce;
  color: #000000;
}
#game-app .button.grey:hover, .modal-backdrop .button.grey:hover {
  background-color: #a7b2bd;
}

#game-app .button.yellow, .modal-backdrop .button.yellow {
  background-color: #f7e55f;
  color: #000000;
}
#game-app .button.yellow:hover, .modal-backdrop .button.yellow:hover {
  background-color: #f4da1e;
}

#game-app .button.green, .modal-backdrop .button.green {
  background-color: #589a56;
  color: #ffffff;
}
#game-app .button.green:hover, .modal-backdrop .button.green:hover {
  background-color: #4f8b4d;
}

#game-app .button.coral, .modal-backdrop .button.coral {
  background-color: #ec8d6f;
  color: #000000;
}
#game-app .button.coral:hover, .modal-backdrop .button.coral:hover {
  background-color: #e87550;
}

#game-app .button.purple, .modal-backdrop .button.purple {
  background-color: #dcb0ed;
  color: #000000;
}
#game-app .button.purple:hover, .modal-backdrop .button.purple:hover {
  background-color: #cd8ee5;
}

.hidden {
  display: none !important;
}

/* Responsive adjustments */
@media (max-width: 540px) {
  .staging-bays-grid {
    gap: 6px;
    padding: 8px;
  }
  .staging-slot {
    height: 54px;
  }
  .slot-color-pip {
    width: 18px;
    height: 18px;
  }
  .queues-lanes-grid {
    gap: 6px;
  }
  .queue-card {
    height: 48px;
  }
}

/* Site page pattern: centred title, with the level badge and buttons as a nav row beneath it */
.game-header {
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
}

.title-group {
  display: contents;
}

.title-group h1 {
  flex-basis: 100%;
  margin: 0 0 4px;
  font-size: 2em;
  text-align: center;
}
