@font-face {
  font-family: Xirod;
  src: url("../Xirod.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: ConsolasCustom;
  src: url("../fonts/consolas.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #090a12;
  --panel: #10121d;
  --panel-light: #171a27;
  --text: #f5f7fb;
  --muted: #9ba2b5;
  --cyan: #0abdc6;
  --magenta: #ea00d9;
  --yellow: #ead500;
  --border: rgba(255, 255, 255, 0.14);
  --content: 1180px;
}

*, *::before, *::after { box-sizing: border-box; }
html { min-height: 100%; background: var(--ink); }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 82% 18%, rgba(234, 0, 217, 0.11), transparent 25rem),
    radial-gradient(circle at 18% 42%, rgba(10, 189, 198, 0.09), transparent 28rem),
    var(--ink);
  font-family: ConsolasCustom, Consolas, Monaco, monospace;
  font-size: 16px;
  line-height: 1.55;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  content: "";
  opacity: 0.035;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.12) 3px 4px),
    url("../images/ng-background-dot.png");
}

button, input, textarea { font: inherit; }
a { color: inherit; }
.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 200;
  padding: 0.7rem 1rem;
  color: #000;
  background: var(--cyan);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; }

.site-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 76px;
  padding: 0.8rem max(1.15rem, calc((100vw - var(--content)) / 2));
  border-bottom: 1px solid var(--border);
  background: rgba(9, 10, 18, 0.9);
  backdrop-filter: blur(14px);
}
.wordmark {
  font-family: Xirod, sans-serif;
  font-size: 1rem;
  text-decoration: none;
  text-shadow: 0 0 7px rgba(255, 255, 255, 0.35), 0 3px 10px #000;
}
.tool-context { color: var(--muted); font-size: 0.64rem; letter-spacing: 0.13em; }

main { width: min(var(--content), calc(100vw - 2.3rem)); margin: 0 auto; padding: 0 0 5rem; }
.tool-hero {
  position: relative;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(3.8rem, 8vw, 6.5rem) 1rem clamp(2.5rem, 5vw, 4rem);
  text-align: center;
}
.tool-hero::after {
  display: block;
  width: min(560px, 80vw);
  height: 1px;
  margin: 2rem auto 0;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(10, 189, 198, 0.65), transparent);
}
.eyebrow, .section-label {
  margin: 0 0 0.8rem;
  color: var(--cyan);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.eyebrow::before, .section-label::before { margin-right: 0.55rem; color: var(--magenta); content: "//"; }
h1, h2 { margin-top: 0; font-family: Xirod, sans-serif; font-weight: 400; text-transform: uppercase; }
h1 {
  margin-bottom: 1.1rem;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1;
  text-shadow: 0 0 7px rgba(255, 255, 255, 0.4), 0 3px 0 #000;
}
.tool-hero > p:last-child { margin: 0 auto; color: var(--muted); font-size: 1rem; }
h2 { margin-bottom: 0; font-size: clamp(1rem, 2vw, 1.35rem); line-height: 1.15; }

.main-layout { display: grid; grid-template-columns: minmax(460px, 0.95fr) minmax(360px, 1.05fr); gap: 1.25rem; align-items: start; }
.preview-panel, .controls-panel {
  position: relative;
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid var(--border);
  background: linear-gradient(145deg, rgba(23, 26, 39, 0.93), rgba(11, 13, 22, 0.96));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.preview-panel { border-top: 3px solid var(--magenta); }
.controls-panel { border-top: 3px solid var(--cyan); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.panel-heading > span { padding-top: 0.15rem; color: var(--muted); font-size: 0.62rem; letter-spacing: 0.12em; }

.preview-viewport { display: grid; justify-items: center; overflow: auto; padding: 1rem; border: 1px solid rgba(10, 189, 198, 0.18); background: #07080e; }
.image-container { position: relative; z-index: 0; display: inline-block; width: 420px; height: 572.73px; max-width: none; }
#main-image { display: block; width: 420px; height: 572.73px; }
.image-container.is-dragging { outline: 2px dashed var(--cyan) !important; outline-offset: 5px; }
.check-banner { position: absolute; top: 65px; left: 50px; z-index: 1; width: auto; height: 28px; pointer-events: none; }
.check-label {
  position: absolute;
  top: 67px;
  left: 60px;
  z-index: 2;
  padding: 2px 6px;
  color: #000;
  font-family: Xirod, sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.5px;
  white-space: nowrap;
  text-transform: uppercase;
  pointer-events: none;
}
.virus-banner { position: absolute; top: 105px; left: 50px; z-index: 1; width: auto; height: 28px; pointer-events: none; }
.virus-label {
  position: absolute;
  top: 108px;
  left: 60px;
  z-index: 2;
  padding: 2px 6px;
  color: #000;
  font-family: Xirod, sans-serif;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.5px;
  white-space: nowrap;
  text-transform: uppercase;
  pointer-events: none;
}
.card-art { position: absolute; top: 40px; left: 50%; z-index: -1; width: 360px; height: 230px; margin-left: -180px; border-radius: 12px; object-fit: cover; pointer-events: none; }
.card-name { position: absolute; top: 273px; left: 50%; color: #000; font-family: Xirod, sans-serif; font-size: 15px; font-weight: 700; white-space: nowrap; transform: translateX(-50%); pointer-events: none; }
.card-body { position: absolute; top: 72%; left: 50%; width: 70%; height: 200px; text-align: left; transform: translate(-50%, -50%); pointer-events: none; }
#card-text-wrapper { display: table; width: 100%; height: 100%; table-layout: fixed; }
#card-text { display: flex; flex-direction: column; justify-content: center; height: 200px; overflow: hidden; color: #000; font-family: Consolas, monospace; font-size: 17px; text-align: left; }
#card-text p { padding: 0; margin: 0 0 8px; }
.card-flavor-wrapper { position: absolute; bottom: 0; display: none; width: 100%; overflow: hidden; background: transparent; }
.card-divider { height: 1px; margin: 0.5rem 0 0.25rem; background: #808080; }
.card-flavor { color: #000; font-family: Consolas, monospace; font-size: 12px; font-style: italic; white-space: pre-wrap; }
.drop-hint { margin: 0.9rem 0 0; color: var(--muted); font-size: 0.72rem; text-align: center; text-transform: uppercase; letter-spacing: 0.06em; }
.drop-hint span { color: var(--cyan); }

fieldset { padding: 0; margin: 0 0 1.4rem; border: 0; }
legend, .field > span { display: flex; justify-content: space-between; width: 100%; margin-bottom: 0.55rem; color: #d7dce7; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.field small { color: var(--muted); font: inherit; font-weight: 400; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.55rem; }
.choice-grid label, .toggle { position: relative; cursor: pointer; }
.choice-grid input, .toggle input { position: absolute; opacity: 0; pointer-events: none; }
.choice-grid label > span, .toggle > span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.choice-grid input:checked + span, .toggle input:checked + span { border-color: var(--cyan); color: #fff; background: rgba(10, 189, 198, 0.12); box-shadow: inset 0 -2px var(--cyan); }
.controls input[value="images/basement.png"]:checked + span { border-color: var(--magenta); background: rgba(234, 0, 217, 0.12); box-shadow: inset 0 -2px var(--magenta); }
.controls input[value="images/encounter.png"]:checked + span { border-color: var(--yellow); background: rgba(234, 213, 0, 0.12); box-shadow: inset 0 -2px var(--yellow); }
.check-types input[value="mind"]:checked + span { border-color: var(--magenta); background: rgba(234, 0, 217, 0.12); box-shadow: inset 0 -2px var(--magenta); }
.check-types input[value="threat"]:checked + span { border-color: var(--yellow); background: rgba(234, 213, 0, 0.12); box-shadow: inset 0 -2px var(--yellow); }
.choice-grid input:focus-visible + span, .toggle input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }
.check-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px 86px; gap: 0.55rem; align-items: end; }
.compact-field { min-width: 0; }
.toggle > span { min-height: 46px; }
.form-fields { display: grid; gap: 1rem; }
.field { display: block; min-width: 0; }
.field input, .field textarea {
  width: 100%;
  padding: 0.8rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0;
  outline: 0;
  color: #fff;
  background: rgba(0, 0, 0, 0.42);
  font-family: ConsolasCustom, Consolas, monospace;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(10, 189, 198, 0.14), 0 0 16px rgba(10, 189, 198, 0.1); }
#name-input { font-family: Xirod, sans-serif; font-size: 0.78rem; }
#text-input { min-height: 130px; }
#flavor-input { min-height: 78px; }
.button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  min-height: 58px;
  margin-top: 1.35rem;
  padding: 0.95rem 1.25rem;
  border: 1px solid var(--cyan);
  border-radius: 0;
  color: #000;
  background: var(--cyan);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  transition: filter 120ms ease, box-shadow 120ms ease, transform 80ms ease;
}
.button:hover { filter: brightness(1.13); box-shadow: 0 0 18px rgba(10, 189, 198, 0.35); }
.button:active { transform: translateY(1px); }
.bg-magenta { border-color: var(--magenta); background: var(--magenta); }
.bg-yellow { border-color: var(--yellow); background: var(--yellow); }
button:focus-visible, input:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--yellow); outline-offset: 3px; }

footer { display: flex; justify-content: space-between; gap: 1rem; padding: 2rem max(1.15rem, calc((100vw - var(--content)) / 2)); border-top: 1px solid var(--border); color: var(--muted); background: #07080e; font-size: 0.68rem; letter-spacing: 0.08em; text-transform: uppercase; }
footer a { color: #c8cdd7; text-decoration: none; }
footer a:hover { color: var(--cyan); }

@media (max-width: 980px) {
  .main-layout { grid-template-columns: 1fr; }
  .preview-panel { display: grid; justify-items: stretch; }
}

@media (max-width: 560px) {
  .site-header { min-height: 64px; }
  .tool-context { display: none; }
  main { width: min(100% - 1rem, var(--content)); }
  .tool-hero { padding-top: 3rem; }
  .preview-panel, .controls-panel { padding: 0.85rem; }
  .preview-viewport { justify-items: start; padding: 0.65rem; }
  .check-row { grid-template-columns: 1fr 72px; }
  .check-types { grid-column: 1 / -1; }
  footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
