/* The game's family: dark purple, gold pixel frames, Jersey 10 headings, readable body text. */
@font-face {
  font-family: "Jersey 10";
  src: url("../fonts/Jersey10-Regular.ttf") format("truetype");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --night: #120c1d;
  --deep: #181026;
  --panel: #221734;
  --raised: #2d2045;
  --edge: #5d4590;
  --edge-soft: #3d2d5e;
  --ink: #07040c;
  --gold: #f2c14e;
  --gold-bright: #ffdc85;
  --gold-dim: #a9822f;
  --text: #f3eeff;
  --muted: #bfb2dc;
  --good: #7ee0a0;
  --warn: #ffca5c;
  --bad: #ff9a9a;
  --blue: #8cc7ff;
  --step: 3px;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --pixel: "Jersey 10", var(--body);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--night);
  background-image:
    radial-gradient(ellipse 90% 60% at 50% -10%, #3a2464 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgb(255 255 255 / 0.012) 3px 4px);
  background-attachment: fixed;
  color: var(--text);
  font: 400 15px/1.5 var(--body);
}

h1, h2, h3, .pixel {
  font-family: var(--pixel);
  font-weight: 400;
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin: 0;
}
h1 { font-size: 2.4rem; color: var(--gold-bright); text-shadow: 0 var(--step) 0 var(--ink); }
h2 { font-size: 1.7rem; color: var(--gold); text-shadow: 0 2px 0 var(--ink); }
h3 { font-size: 1.4rem; color: var(--gold); }
p { margin: 0 0 0.6rem; }
a { color: var(--gold-bright); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; }
.good { color: var(--good); }
.warn { color: var(--warn); }
.bad { color: var(--bad); }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* A pixel frame: a double border with gold studs on the upper corners. */
.frame {
  position: relative;
  background: linear-gradient(180deg, var(--raised) 0, var(--panel) 56px);
  border: var(--step) solid var(--edge);
  box-shadow: 0 0 0 var(--step) var(--ink), inset 0 0 0 var(--step) var(--ink), 0 10px 0 rgb(0 0 0 / 0.25);
  margin: var(--step);
  padding: 18px;
}
.frame::before, .frame::after {
  content: "";
  position: absolute;
  top: calc(-2 * var(--step));
  width: calc(3 * var(--step));
  height: calc(3 * var(--step));
  background: var(--gold);
  box-shadow: 0 0 0 var(--step) var(--ink);
}
.frame::before { left: calc(-2 * var(--step)); }
.frame::after { right: calc(-2 * var(--step)); }
.frame > h2:first-child, .frame > h3:first-child { margin-bottom: 12px; }

button, .button {
  font: 400 1.15rem/1 var(--pixel);
  letter-spacing: 0.03em;
  color: #241505;
  background: linear-gradient(180deg, var(--gold-bright) 0 45%, var(--gold) 45% 100%);
  border: 0;
  border-radius: 0;
  box-shadow: 0 0 0 var(--step) var(--ink), inset 0 calc(-1 * var(--step)) 0 var(--gold-dim);
  margin: var(--step);
  padding: 9px 16px 11px;
  min-height: 40px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
button:hover:not(:disabled) { filter: brightness(1.1); }
button:active:not(:disabled) { transform: translateY(2px); }
button:disabled { cursor: not-allowed; filter: grayscale(0.8) brightness(0.7); }
button.quiet {
  color: var(--text);
  background: var(--raised);
  box-shadow: 0 0 0 var(--step) var(--ink), inset 0 0 0 2px var(--edge);
}
button.quiet[aria-pressed="true"] { color: #241505; background: var(--gold); box-shadow: 0 0 0 var(--step) var(--ink); }
button.danger {
  color: #fff;
  background: #a3304a;
  box-shadow: 0 0 0 var(--step) var(--ink), inset 0 calc(-1 * var(--step)) 0 #6d1c30;
}
button.link {
  background: none; box-shadow: none; color: var(--gold-bright); font: 400 0.9rem var(--body);
  text-decoration: underline; padding: 4px; min-height: 32px;
}
button.small { font-size: 1.05rem; min-height: 32px; padding: 5px 10px 7px; }

:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; }

label { display: block; font-size: 0.85rem; color: var(--muted); margin: 0 0 4px; }
input, select, textarea {
  width: 100%;
  font: 400 1rem var(--body);
  color: var(--text);
  background: var(--deep);
  border: 2px solid var(--edge);
  box-shadow: inset 0 var(--step) 0 var(--ink);
  border-radius: 0;
  padding: 9px 10px;
  min-height: 42px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
input::placeholder, textarea::placeholder { color: #8f81b3; }
input[type="checkbox"] { width: 20px; height: 20px; min-height: 0; flex: none; accent-color: var(--gold); }
input[type="range"] { padding: 0; accent-color: var(--gold); background: none; border: 0; box-shadow: none; }
.code-input { font: 400 2rem var(--pixel); letter-spacing: 0.35em; text-align: center; text-indent: 0.35em; }
.field { margin-bottom: 14px; }
.check { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 0.95rem; cursor: pointer; margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; align-items: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 200px; }

.message { margin: 10px 0 0; padding: 9px 12px; border-left: 4px solid var(--blue); background: var(--deep); }
.message.bad { border-color: var(--bad); }
.message.good { border-color: var(--good); }
.message.warn { border-color: var(--warn); }

.badge {
  display: inline-block; font: 400 1rem/1 var(--pixel); letter-spacing: 0.04em; padding: 3px 7px 4px;
  background: var(--deep); box-shadow: 0 0 0 2px currentcolor; margin: 2px 4px; color: var(--muted);
  white-space: nowrap;
}
.badge.good { color: var(--good); }
.badge.warn { color: var(--warn); }
.badge.bad { color: var(--bad); }
.badge.gold { color: var(--gold); }
.badge.blue { color: var(--blue); }

.health {
  display: inline-block; width: 90px; height: 10px; background: var(--ink); box-shadow: 0 0 0 2px var(--edge-soft);
  vertical-align: middle; margin-right: 8px;
}
.health > span { display: block; height: 100%; background: #e25563; box-shadow: inset 0 3px 0 rgb(255 255 255 / 0.25); }

[class*="sprite-"] { image-rendering: pixelated; background-repeat: no-repeat; flex: none; }
canvas { image-rendering: pixelated; }

dialog {
  width: min(520px, calc(100vw - 20px));
  max-height: calc(100vh - 20px);
  overflow: auto;
  color: var(--text);
  padding: 4px;
  border: 0;
  background: transparent;
}
dialog::backdrop { background: rgb(8 4 14 / 0.78); }
dialog > .frame { margin: 6px; }

.simulated {
  display: flex; align-items: center; gap: 10px; justify-content: center; text-align: center;
  background: repeating-linear-gradient(135deg, #4a2f00 0 14px, #5c3c00 14px 28px);
  color: #fff3cf; font: 400 1.2rem/1.2 var(--pixel); letter-spacing: 0.05em; padding: 7px 12px;
  box-shadow: 0 var(--step) 0 var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
