/* Same layout as nes-tgl-random, painted in mynesgames.com's palette.
   The brand tokens are copied verbatim from mynesgames.com/style.css, and keep
   the roles they have there: blue is a fill or ground, cyan is the text and the
   outline. Blue cannot be text on these dark cards (about 1.6:1); cyan reaches
   15:1 on the card and 11:1 on the blue. */
:root {
  color-scheme: dark;
  --brand-blue: #1c0cd4;
  --brand-blue-bright: #3320ee;
  --brand-cyan: #a5fdfd;
  --brand-cyan-bright: #d9ffff;

  --bg: #000;
  --panel: #1a1a1a;
  --panel-edge: #333;
  --field: #111;
  --field-edge: #4b5563;
  --text: #f2f2f2;
  --muted: #9ca3af;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute sets display:none in the UA sheet, but ANY author
   display rule beats it -- in nes-tgl-random `.download { display: inline-grid }`
   won, and the download link showed before anything had been generated. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(680px, 100%);
  border: 1px solid var(--panel-edge);
  border-radius: 12px;
  background: var(--panel);
  padding: 28px;
  box-shadow: 0 16px 48px rgb(0 0 0 / 70%);
}

.mast {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--brand-cyan);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.3px;
  line-height: 1.1;
}

.form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input[type="text"],
input[type="file"] {
  width: 100%;
  border: 1px solid var(--field-edge);
  border-radius: 6px;
  background: var(--field);
  color: #fff;
  padding: 12px 14px;
  font: inherit;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--brand-cyan);
}

input[type="file"] {
  padding: 10px;
}

/* Primary: mynesgames' blue fill with cyan lettering. */
button,
.download {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--brand-blue);
  color: var(--brand-cyan);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
  display: inline-grid;
  place-items: center;
  padding: 0 18px;
}

button:hover,
.download:hover {
  background: var(--brand-blue-bright);
}

.seed-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.seed-row input[type="text"] {
  flex: 1 1 auto;
  min-width: 0;
}

.seed-row button {
  flex: 0 0 auto;
}

/* Secondary action: must not compete with the primary Generate button. */
button.ghost {
  background: transparent;
  border: 1px solid var(--field-edge);
  color: var(--brand-cyan);
}

button.ghost:hover {
  border-color: var(--brand-cyan);
  background: rgb(28 12 212 / 22%);
}

button.ghost:active {
  background: rgb(28 12 212 / 35%);
}

button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.saved-row {
  display: flex;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--field-edge);
  border-radius: 6px;
  background: var(--field);
  padding: 10px 10px 10px 14px;
}

.saved-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #fff;
  font-weight: 400;
}

.share-row {
  margin-top: 16px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.share-row input[type="text"] {
  font-size: 13px;
  color: var(--muted);
}

.status {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
}

.status.error {
  color: var(--danger);
}

.download {
  margin-top: 16px;
  width: 100%;
}

@media (max-width: 520px) {
  .shell {
    padding: 14px;
  }

  .panel {
    padding: 20px;
  }

  h1 {
    font-size: 28px;
  }
}

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--brand-cyan);
}

/* --- Adventure options -------------------------------------------------- */

.options {
  border: 1px solid var(--field-edge);
  border-radius: 6px;
  background: var(--field);
  padding: 0;
}

.options > summary {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 12px 14px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}

/* Safari draws its own triangle through ::-webkit-details-marker, which the
   standard `list-style: none` above does not remove. */
.options > summary::-webkit-details-marker {
  display: none;
}

.options > summary::before {
  content: "\25B8";
  color: var(--brand-cyan);
  font-size: 12px;
}

.options[open] > summary::before {
  content: "\25BE";
}

.options-summary {
  color: #fff;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.options-body {
  display: grid;
  gap: 14px;
  padding: 4px 14px 0;
}

.option {
  display: grid;
  gap: 6px;
}

.option-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

/* Radios drive the state; the labels are what you see and click. */
.option-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.option-choices input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-choices label {
  border: 1px solid var(--field-edge);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.option-choices label:hover {
  border-color: var(--brand-cyan);
  color: #fff;
}

/* Selected reads like mynesgames' active header button: blue ground, cyan text. */
.option-choices input:checked + label {
  border-color: var(--brand-blue);
  background: var(--brand-blue);
  color: var(--brand-cyan);
}

/* Keyboard users get the same ring the browser would have drawn on the radio. */
.option-choices input:focus-visible + label {
  outline: 2px solid var(--brand-cyan);
  outline-offset: 2px;
}

.option-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.options .hint {
  padding: 0 14px;
  margin-top: 14px;
}

#reset-options {
  margin: 12px 14px 14px;
  min-height: 36px;
  font-size: 13px;
}
