:root {
  --bg: #000000;
  --red: #ff2a23;
  --red-soft: rgba(255, 42, 35, 0.72);
  --red-dim: rgba(255, 42, 35, 0.42);
  --red-faint: rgba(255, 42, 35, 0.20);
  --black-glass: rgba(0, 0, 0, 0.82);
  --black-panel: rgba(3, 0, 0, 0.92);
  --dot-size: 3px;
  --gap: 16px;
  --radius: 24px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Roboto Mono", "Noto Sans Mono CJK JP", "Noto Sans JP", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html,
body {
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--red);
}

body {
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(255,42,35,0.08), transparent 34%),
    radial-gradient(circle at 0% 20%, rgba(255,42,35,0.06), transparent 30%),
    #000;
}

button,
input,
summary,
textarea {
  font: inherit;
}

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

.machine-shell {
  width: min(100%, 960px);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 30px);
  display: grid;
  gap: var(--gap);
}

.led-panel {
  position: relative;
  background:
    radial-gradient(circle, rgba(255,42,35,0.14) 0 1px, transparent 1.35px) 0 0 / 9px 9px,
    linear-gradient(180deg, rgba(255,42,35,0.05), rgba(0,0,0,0) 38%),
    var(--black-panel);
  border: 2px dotted var(--red-soft);
  border-radius: var(--radius);
  box-shadow:
    inset 0 0 0 1px var(--red-faint),
    inset 0 0 18px rgba(255,42,35,0.05),
    0 0 22px rgba(255,42,35,0.10);
  text-shadow: 0 0 4px var(--red-soft), 0 0 16px rgba(255,42,35,0.26);
}

.led-panel::before,
.led-panel::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  border: 2px dotted var(--red-soft);
  border-radius: 50%;
  top: 14px;
  opacity: 0.88;
  box-shadow: 0 0 10px rgba(255,42,35,0.25);
}
.led-panel::before { left: 16px; }
.led-panel::after { right: 16px; }

.top-panel {
  min-height: 96px;
  padding: 24px 58px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.eyebrow,
.result-label {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.22em;
  color: var(--red-soft);
}

h1 {
  margin: 0;
  font-size: clamp(18px, 4.8vw, 34px);
  line-height: 1.25;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.tiny-round {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 2px dotted var(--red-soft);
  color: var(--red);
  background: #000;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-weight: 800;
  box-shadow: inset 0 0 0 1px var(--red-faint), 0 0 14px rgba(255,42,35,0.12);
}

.key-panel {
  padding: 18px 22px;
}

.key-panel::before,
.key-panel::after,
.result-panel::before,
.result-panel::after { width: 9px; height: 9px; }

summary {
  cursor: pointer;
  list-style: none;
  color: var(--red-soft);
  letter-spacing: 0.13em;
  font-size: 12px;
  user-select: none;
}
summary::-webkit-details-marker { display: none; }

.key-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(140px, 0.55fr) auto;
  align-items: end;
  gap: 12px;
  padding-top: 14px;
}

.field-label {
  display: grid;
  gap: 6px;
  color: var(--red-soft);
  font-size: 11px;
  letter-spacing: 0.12em;
}

input,
textarea {
  width: 100%;
  color: var(--red);
  background: #000;
  border: 1px dotted var(--red-soft);
  border-radius: 999px;
  outline: none;
  padding: 11px 14px;
  box-shadow: inset 0 0 12px rgba(255,42,35,0.05);
}

textarea {
  min-height: 76px;
  resize: vertical;
  border-radius: 16px;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder { color: var(--red-dim); }

.save-key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--red-soft);
  font-size: 11px;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.save-key input { width: 16px; height: 16px; accent-color: var(--red); }

.slot-panel {
  padding: clamp(18px, 4vw, 34px);
}

.slot-headline {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 14px;
  align-items: center;
  margin: 0 14px 18px;
  color: var(--red-soft);
  letter-spacing: 0.14em;
  font-size: 12px;
  text-align: center;
}
.slot-headline span {
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--red-soft) 0 4px, transparent 4px 10px);
}

.reel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(8px, 2vw, 18px);
}

.reel-unit {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 7px;
}

.reel-title {
  font-size: clamp(14px, 3vw, 22px);
  letter-spacing: 0.12em;
  font-weight: 800;
}

.reel-kind {
  min-height: 1.4em;
  font-size: clamp(10px, 2.4vw, 13px);
  letter-spacing: 0.08em;
  color: var(--red-soft);
  text-align: center;
}

.pointer {
  font-size: 18px;
  line-height: 1;
  color: var(--red);
  animation: pointerBlink 1.35s steps(2, end) infinite;
}

.reel-window {
  width: 100%;
  min-height: clamp(178px, 35vw, 270px);
  display: grid;
  grid-template-rows: 1fr 1px 1.25fr 1px 1fr;
  align-items: center;
  justify-items: center;
  padding: 18px 10px;
  border: 3px dotted var(--red-soft);
  border-radius: 999px;
  background:
    radial-gradient(circle, rgba(255,42,35,0.12) 0 1px, transparent 1.35px) 0 0 / 8px 8px,
    #000;
  box-shadow:
    inset 0 0 0 2px rgba(255,42,35,0.12),
    inset 0 0 24px rgba(255,42,35,0.08),
    0 0 22px rgba(255,42,35,0.12);
  overflow: hidden;
}

.reel-unit.running .reel-window {
  animation: reelPulse 0.42s steps(2, end) infinite;
}

.reel-word {
  width: 100%;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 3px;
}

.reel-word.main {
  font-size: clamp(21px, 5.3vw, 41px);
  font-weight: 900;
  letter-spacing: 0.05em;
  color: var(--red);
}

.reel-word.dim {
  font-size: clamp(12px, 2.8vw, 18px);
  color: var(--red-soft);
  opacity: 0.82;
}

.scanline {
  width: 88%;
  background: repeating-linear-gradient(90deg, var(--red-soft) 0 7px, transparent 7px 11px);
  box-shadow: 0 0 10px rgba(255,42,35,0.24);
}

.stop-button,
.big-button,
.add-button,
.chip-remove {
  cursor: pointer;
  border: 2px dotted var(--red-soft);
  color: var(--red);
  background: #000;
  text-shadow: 0 0 4px var(--red-soft), 0 0 16px rgba(255,42,35,0.24);
  box-shadow: inset 0 0 0 1px var(--red-faint), 0 0 14px rgba(255,42,35,0.12);
}

.stop-button {
  width: min(160px, 88%);
  min-height: 50px;
  border-radius: 10px;
  font-size: clamp(14px, 3vw, 22px);
  font-weight: 900;
  letter-spacing: 0.12em;
}
.stop-button:disabled { opacity: 0.40; cursor: default; }

.primary-controls {
  margin: clamp(16px, 3vw, 24px) auto 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(10px, 2vw, 18px);
}

.big-button {
  min-height: 66px;
  border-radius: 12px;
  font-size: clamp(15px, 3.2vw, 22px);
  font-weight: 900;
  letter-spacing: 0.10em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.big-button span { font-size: 1.15em; }
.big-button:active,
.stop-button:active,
.tiny-round:active,
.add-button:active { transform: translateY(1px); }
.big-button.flash { animation: buttonFlash 0.62s steps(2, end) 1; }

.bank-panel {
  padding: clamp(17px, 3vw, 26px);
}

.bank-line { margin-bottom: 14px; }

.bank-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
}

.bank-card {
  min-width: 0;
  border: 2px dotted var(--red-soft);
  border-radius: 16px;
  padding: 14px;
  background:
    radial-gradient(circle, rgba(255,42,35,0.12) 0 1px, transparent 1.3px) 0 0 / 8px 8px,
    #000;
  box-shadow: inset 0 0 0 1px var(--red-faint);
}

.bank-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.bank-title {
  margin: 0;
  font-size: clamp(15px, 3vw, 19px);
  letter-spacing: 0.10em;
}

.bank-count {
  font-size: 11px;
  color: var(--red-soft);
  white-space: nowrap;
}

.bank-kind {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: 0.10em;
  color: var(--red-soft);
}

.add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  margin-bottom: 10px;
}

.add-row input { height: 42px; padding: 9px 12px; }

.add-button {
  border-radius: 50%;
  min-width: 42px;
  min-height: 42px;
  font-size: 24px;
  line-height: 1;
}

.bulk-details {
  margin-bottom: 10px;
}
.bulk-details summary {
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--red-soft);
}
.bulk-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}
.bulk-actions .big-button {
  min-height: 42px;
  font-size: 12px;
}

.bank-scroll {
  max-height: 210px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  display: grid;
  align-content: start;
  gap: 8px;
  scrollbar-color: var(--red-soft) #000;
}

.bank-scroll::-webkit-scrollbar { width: 6px; }
.bank-scroll::-webkit-scrollbar-thumb { background: var(--red-soft); border-radius: 999px; }
.bank-scroll::-webkit-scrollbar-track { background: #000; }

.word-chip {
  width: 100%;
  min-height: 38px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 28px;
  align-items: center;
  gap: 4px;
  border: 1px dotted var(--red-soft);
  border-radius: 999px;
  background: #000;
  color: var(--red);
  box-shadow: inset 0 0 10px rgba(255,42,35,0.04);
  overflow: hidden;
}

.word-chip span:first-child {
  min-width: 0;
  padding: 0 0 0 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
  text-align: center;
}

.word-chip.active {
  background: rgba(255,42,35,0.10);
  box-shadow: inset 0 0 18px rgba(255,42,35,0.12), 0 0 18px rgba(255,42,35,0.16);
}

.chip-remove {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  opacity: 0.7;
  margin-right: 5px;
}

.result-panel {
  padding: clamp(22px, 4vw, 34px);
  text-align: center;
}

.result-text {
  min-height: 1.3em;
  font-size: clamp(27px, 7vw, 58px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 1.22;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.comment-text {
  margin: 18px auto 0;
  min-height: 1.5em;
  font-size: clamp(17px, 4.6vw, 30px);
  line-height: 1.35;
  letter-spacing: 0.08em;
  color: var(--red-soft);
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.about-dialog {
  width: min(92vw, 520px);
  padding: 0;
  border: 0;
  color: var(--red);
  background: transparent;
}
.about-dialog::backdrop { background: rgba(0,0,0,0.86); }
.dialog-inner { padding: 28px; }
.dialog-inner h2 { margin: 0 0 12px; }
.dialog-inner p { color: var(--red-soft); line-height: 1.8; }

@keyframes reelPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.6); }
}
@keyframes pointerBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.32; }
}
@keyframes buttonFlash {
  0%, 100% { filter: brightness(1); }
  45% { filter: brightness(2.1); }
}

@media (max-width: 760px) {
  :root { --gap: 12px; --radius: 20px; }
  .machine-shell { padding: 10px; }
  .top-panel { padding: 22px 48px 20px; min-height: 84px; }
  .key-grid { grid-template-columns: 1fr; }
  .save-key { white-space: normal; }
  .slot-panel { padding: 18px 10px; }
  .reel-grid { gap: 6px; }
  .reel-window { padding: 14px 5px; min-height: 178px; }
  .stop-button { min-height: 44px; font-size: 13px; letter-spacing: 0.08em; }
  .primary-controls { gap: 7px; }
  .big-button { min-height: 58px; font-size: 12px; letter-spacing: 0.08em; gap: 6px; }
  .bank-grid { grid-template-columns: 1fr; }
  .bank-scroll { max-height: 232px; }
}

@media (max-width: 410px) {
  .reel-title { font-size: 13px; }
  .reel-kind { font-size: 9px; }
  .reel-word.main { font-size: 19px; }
  .reel-word.dim { font-size: 11px; }
  .primary-controls { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

.image-actions {
  margin: 22px auto 0;
  display: flex;
  justify-content: center;
}

.image-button {
  min-width: min(100%, 260px);
  min-height: 58px;
}

.image-button.loading {
  animation: buttonFlash 0.9s steps(2, end) infinite;
}

.image-status {
  margin-top: 14px;
  color: var(--red-soft);
  font-size: clamp(12px, 3vw, 16px);
  letter-spacing: 0.12em;
  text-align: center;
}

.generated-image-wrap {
  width: min(100%, 560px);
  margin: 18px auto 0;
  padding: 12px;
  border: 2px dotted var(--red-soft);
  border-radius: 18px;
  background:
    radial-gradient(circle, rgba(255,42,35,0.14) 0 1px, transparent 1.35px) 0 0 / 9px 9px,
    #000;
  box-shadow:
    inset 0 0 0 1px var(--red-faint),
    0 0 22px rgba(255,42,35,0.12);
}

.generated-image-wrap img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px dotted var(--red-dim);
  background: #000;
}

.key-note {
  margin: 8px 0 12px;
  color: var(--red-soft);
  font-size: 12px;
  letter-spacing: 0.04em;
}

.key-panel input {
  min-height: 44px;
}
