* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  background: #f4f6f9;
  color: #1e293b;
  min-height: 100vh;
}

.lasermaze-chrome {
  background: #1e293b;
  color: #fff;
  padding: 0.75rem 1rem 1.25rem;
  text-align: center;
}

.lasermaze-chrome__brand {
  max-width: 900px;
  margin: 0 auto;
}

.lasermaze-chrome__logo {
  display: inline-block;
  line-height: 0;
}

.banner-logo {
  display: block;
  max-width: min(100%, 42rem);
  max-height: 8rem;
  width: auto;
  height: auto;
  margin: 0 auto 1rem;
}

.lasermaze-chrome__links {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.lasermaze-chrome__links a {
  color: #38bdf8;
  text-decoration: none;
}

.lasermaze-chrome__links a:hover {
  text-decoration: underline;
}

.lasermaze-main {
  max-width: 72rem;
  margin: 1rem auto 0;
  padding: 0 1rem 3rem;
}

.lasermaze-toolbar {
  margin-bottom: 1rem;
}

.lasermaze-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
  align-items: center;
}

.lasermaze-controls__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.65rem 1rem;
  margin-left: 0.35rem;
  color: #334155;
  font-size: 0.95rem;
}

.lasermaze-play-date {
  color: #64748b;
  font-size: 0.9rem;
}

#lasermaze-timer {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  color: #0f172a;
}

.lasermaze-scoreline {
  margin-top: 0.65rem;
  text-align: center;
  min-height: 1.25rem;
  font-size: 0.95rem;
  color: #475569;
}

#lasermaze-score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #0f172a;
}

#lasermaze-score:not(:empty) + #lasermaze-status:not(:empty) {
  margin-top: 0.25rem;
}

#lasermaze-status {
  color: #475569;
}

.lasermaze-btn {
  border: 0;
  border-radius: 5px;
  padding: 0.55rem 0.95rem;
  background: #38bdf8;
  color: #fff;
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.lasermaze-btn:hover {
  background: #0ea5e9;
}

.lasermaze-btn--primary {
  background: #0284c7;
}

.lasermaze-btn--primary:hover {
  background: #0369a1;
}

.lasermaze-btn--active {
  background: #f59e0b;
}

.lasermaze-btn:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.lasermaze-play-area {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
  padding: 1rem;
}

.lasermaze-help {
  text-align: center;
  margin: 0 0 1rem;
  color: #475569;
}

.lasermaze-stage {
  display: grid;
  gap: 1rem;
  align-items: start;
}

@media (min-width: 900px) {
  .lasermaze-stage {
    grid-template-columns: minmax(0, 1fr) 18rem;
  }
}

.lasermaze-board-wrap {
  position: relative;
  overflow: visible;
}

.lasermaze-board {
  position: relative;
  display: grid;
  gap: 2px;
  /* Extra padding keeps edge emitters inside the board, clear of chrome above. */
  padding: 1.75rem;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(30, 41, 59, 0.98));
  min-height: min(70vw, 36rem);
  overflow: visible;
}

@media (max-width: 600px) {
  .banner-logo {
    max-height: 5rem;
  }

  .lasermaze-board {
    padding: 1.25rem;
  }
}

.lasermaze-beams {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.lasermaze-cell {
  position: relative;
  aspect-ratio: 1;
  background: #111e33;
  /* Equal borders on every cell so wall sides only change colour and never
     reshape the content box (which squashed detectors / shifted the grid). */
  border: 5px solid transparent;
  color: inherit;
  padding: 0;
  cursor: pointer;
  overflow: visible;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lasermaze-cell.is-drop-target {
  outline: 2px dashed #38bdf8;
  outline-offset: -3px;
}

.lasermaze-cell.is-drag-source {
  opacity: 0.35;
}

.lasermaze-cell.wall-top { border-top-color: #8ba4c5; }
.lasermaze-cell.wall-right { border-right-color: #8ba4c5; }
.lasermaze-cell.wall-bottom { border-bottom-color: #8ba4c5; }
.lasermaze-cell.wall-left { border-left-color: #8ba4c5; }

.lasermaze-detector {
  position: absolute;
  inset: 24%;
  border-radius: 50%;
  border: 4px solid var(--detector-colour);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.2);
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.lasermaze-detector.is-lit {
  background: var(--detector-colour);
  box-shadow:
    inset 0 0 0 3px rgba(255, 255, 255, 0.35),
    0 0 12px var(--detector-colour),
    0 0 24px rgba(255, 255, 255, 0.25);
}

.lasermaze-emitter {
  position: absolute;
  background: var(--laser-colour);
  box-shadow: 0 0 10px var(--laser-colour);
}

/* Class matches beam travel dir; stub sits outside the grid in board padding, aligned with beam start. */
.lasermaze-emitter--s { bottom: 100%; left: 50%; width: 12%; height: 34%; transform: translateX(-50%); }
.lasermaze-emitter--n { top: 100%; left: 50%; width: 12%; height: 34%; transform: translateX(-50%); }
.lasermaze-emitter--e { right: 100%; top: 50%; width: 34%; height: 12%; transform: translateY(-50%); }
.lasermaze-emitter--w { left: 100%; top: 50%; width: 34%; height: 12%; transform: translateY(-50%); }

.lasermaze-sidebar {
  display: grid;
  gap: 1rem;
}

.lasermaze-legend,
.lasermaze-tray {
  background: #f8fbff;
  border: 1px solid #dbeafe;
  border-radius: 18px;
  padding: 0.85rem;
}

.lasermaze-legend {
  display: grid;
  gap: 0.55rem;
  font-size: 0.95rem;
}

.legend-swatch {
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.55rem;
  width: 1rem;
  height: 1rem;
  border: 2px solid #0f172a;
  background: #364b6a;
}

.legend-swatch--circle { border-radius: 50%; }
.legend-swatch--square { border-radius: 0.25rem; }
.legend-swatch--single { background: linear-gradient(135deg, #fff 50%, #0f172a 50%); }
.legend-swatch--double { background: linear-gradient(135deg, #fff 50%, #fff 50%); }

.lasermaze-tray {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(78px, 1fr));
  gap: 0.7rem;
  align-content: start;
  min-height: 14rem;
}

.lasermaze-tray.is-drop-target {
  outline: 2px dashed #0ea5e9;
  outline-offset: 2px;
}

.lasermaze-tray-slot {
  border: 0;
  border-radius: 16px;
  padding: 0.45rem;
  background: #e2eefb;
  cursor: grab;
  min-height: 92px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lasermaze-tray-slot:active {
  cursor: grabbing;
}

.lasermaze-tray-slot.is-selected {
  outline: 3px solid #0ea5e9;
}

.lasermaze-tray-slot.is-used {
  opacity: 0.5;
}

.lasermaze-tray-slot.is-drag-source {
  opacity: 0.35;
}

.lasermaze-tray-slot__meta {
  margin-top: 0.25rem;
  font-size: 0.72rem;
  color: #475569;
  text-align: center;
}

.lasermaze-drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 72px;
  height: 72px;
  pointer-events: none;
  z-index: 10000;
  opacity: 0.92;
  transform: translate(-50%, -50%);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.25));
}

.lasermaze-drag-ghost .lasermaze-mirror {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
}

.lasermaze-mirror {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  display: grid;
  place-items: center;
  background: #364b6a;
  border: 2px solid rgba(226, 238, 251, 0.35);
  box-sizing: border-box;
}

.lasermaze-tray-slot .lasermaze-mirror {
  position: relative;
  inset: auto;
  width: 100%;
  aspect-ratio: 1;
}

.lasermaze-mirror--circle { border-radius: 50%; }
.lasermaze-mirror--square { border-radius: 0.65rem; }
.lasermaze-mirror__frame {
  position: relative;
  width: 72%;
  height: 72%;
  transform: rotate(var(--mirror-rotation));
}

.lasermaze-mirror__slash,
.lasermaze-mirror__face {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12%;
  height: 112%;
  transform-origin: center;
  border-radius: 999px;
}

.lasermaze-mirror__slash {
  transform: translate(-50%, -50%) rotate(45deg);
  background: rgba(255, 255, 255, 0.15);
}

.lasermaze-mirror__face {
  transform: translate(-50%, -50%) rotate(45deg);
}

.lasermaze-mirror--double .lasermaze-mirror__face {
  background: #f8fafc;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.lasermaze-mirror--single .lasermaze-mirror__face {
  background: linear-gradient(90deg, #0f172a 0%, #0f172a 50%, #f8fafc 50%, #f8fafc 100%);
}

.lasermaze-mirror--coloured {
  border-color: color-mix(in srgb, var(--mirror-colour) 65%, rgba(226, 238, 251, 0.35));
}

.lasermaze-mirror--coloured.lasermaze-mirror--double .lasermaze-mirror__face {
  background: var(--mirror-colour);
  box-shadow: 0 0 10px color-mix(in srgb, var(--mirror-colour) 55%, transparent);
}
