@font-face {
  font-family: 'Creepster';
  src: url('../assets/fonts/Creepster.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #000;
  --panel: #140b1f;
  --panel-2: #1f1230;
  --line: #3a2654;
  --text: #f3eaff;
  --muted: #a99bbd;
  --orange: #ff9a1f;
  --green: #6cff3c;
  --red: #ff3b4f;
  --purple: #b44dff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* Hide the cursor during play; it comes back when the mouse moves. */
body { cursor: none; }
body.show-ui { cursor: default; }

#stage {
  position: fixed;
  inset: 0;
  transform-origin: center;
}
#stage.flip-h { transform: scaleX(-1); }
#stage.flip-v { transform: scaleY(-1); }
#stage.flip-h.flip-v { transform: scale(-1, -1); }

#game {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- gear button ---------- */
#gear {
  position: fixed;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.4s;
}
body.show-ui #gear { opacity: 0.75; }
#gear:hover, #gear:focus-visible { opacity: 1; background: rgba(255, 255, 255, 0.14); }
#gear svg { width: 100%; height: 100%; fill: currentColor; }
#gear-dot {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--red);
  border: 2px solid #000;
}
#gear-dot.ok { background: var(--green); }
#gear-dot.warn { background: var(--orange); }

/* ---------- settings dialog ---------- */
dialog#settings {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  cursor: default;
  box-shadow: 0 0 60px rgba(255, 140, 30, 0.18);
}
dialog#settings::backdrop { background: rgba(0, 0, 0, 0.35); }

.panel {
  padding: 18px 22px 22px;
  max-height: calc(100vh - 50px);
  overflow-y: auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
header h2 {
  margin: 0;
  font-family: 'Creepster', fantasy;
  font-weight: normal;
  font-size: 30px;
  letter-spacing: 1px;
  color: var(--orange);
  text-shadow: 0 0 12px rgba(255, 154, 31, 0.5);
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--orange); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button.primary { background: var(--orange); border-color: var(--orange); color: #1a0a00; font-weight: 600; }
button.primary:hover:not(:disabled) { filter: brightness(1.1); }
.icon-btn { padding: 4px 10px; font-size: 18px; background: transparent; border-color: transparent; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.tabs button {
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 14px;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--orange); }

section { display: none; }
section.active { display: block; }

.status-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.pill {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 59, 79, 0.15);
  color: #ff8a97;
  font-weight: 600;
  font-size: 14px;
}
.pill.ok { background: rgba(108, 255, 60, 0.15); color: var(--green); }
.pill.warn { background: rgba(255, 154, 31, 0.15); color: var(--orange); }
.muted { color: var(--muted); font-size: 14px; }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.readout {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.readout div {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}
.readout span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.readout b { font-size: 22px; font-variant-numeric: tabular-nums; }

label.row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0;
}
label.row > span { font-size: 14px; color: var(--muted); }
label.row.slider {
  display: grid;
  grid-template-columns: 1fr 70px;
  align-items: center;
  column-gap: 12px;
}
label.row.slider > span { grid-column: 1 / -1; }
label.row.slider output { text-align: right; font-variant-numeric: tabular-nums; }

input[type="range"] { width: 100%; accent-color: var(--orange); }
select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  width: 100%;
}
textarea { resize: vertical; }

label.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 10px 0;
  line-height: 1.35;
}
label.check input { margin-top: 3px; accent-color: var(--orange); width: 16px; height: 16px; flex: none; }

details { margin: 14px 0; }
summary { cursor: pointer; color: var(--muted); }
#log {
  margin: 8px 0 0;
  height: 160px;
  overflow: auto;
  background: #07040b;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font: 12px/1.4 ui-monospace, Menlo, monospace;
  color: #cfc3e0;
  white-space: pre-wrap;
  word-break: break-all;
}

.hint { color: var(--muted); font-size: 13px; line-height: 1.45; margin: 8px 0; }
.hint b { color: var(--text); }
.hint.warn { color: var(--orange); }

@media (max-width: 480px) {
  .panel { padding: 14px 16px 18px; }
  .readout b { font-size: 18px; }
  .tabs button { padding: 8px 8px; }
}
