:root {
  --ink: #18211e;
  --paper: #f3f0e8;
  --acid: #c7f36b;
  --blue: #668fa3;
  --line: rgba(24, 33, 30, 0.16);
  --stage: #17201d;
  --stage-text: #e8ede8;
  --danger: #b3402a;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    linear-gradient(110deg, transparent 64%, rgba(199, 243, 107, 0.28) 64%),
    var(--paper);
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
  line-height: 1.7;
}

button,
select,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

::selection {
  background: var(--acid);
  color: var(--ink);
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1.5rem, 5vw, 4.5rem);
}

.app-header {
  margin-bottom: clamp(2rem, 6vw, 4rem);
}

.back-link {
  color: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link:hover,
.back-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.35em;
}

.top-links {
  display: flex;
  gap: 1.5rem;
  justify-content: space-between;
}

.title-row {
  display: flex;
  gap: 3rem;
  align-items: end;
  justify-content: space-between;
  margin-top: clamp(1.5rem, 5vw, 3.5rem);
}

.eyebrow {
  margin: 0 0 0.8rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.4rem, 9vw, 7.5rem);
  font-weight: 400;
  letter-spacing: -0.065em;
  line-height: 0.78;
}

.logo img {
  display: block;
  width: 404px;
  height: 176px;
  image-rendering: pixelated;
}

.description {
  max-width: 380px;
  margin: 0;
  font-size: 0.88rem;
}

/* Stage */

.stage-wrap {
  position: relative;
  overflow: hidden;
  min-height: min(62vh, 560px);
  border: 1px solid var(--ink);
  background: var(--stage);
  box-shadow: 12px 12px 0 rgba(102, 143, 163, 0.38);
  color: var(--stage-text);
}

.stage-wrap.dragover {
  box-shadow: 12px 12px 0 var(--acid);
  outline: 3px dashed var(--acid);
  outline-offset: -12px;
}

.stage {
  display: block;
  width: 100%;
  height: min(62vh, 560px);
}

.placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

.placeholder.hidden {
  display: none;
}

.placeholder-mark {
  margin: 0;
  font-size: 2.6rem;
  line-height: 1;
}

.placeholder-title {
  margin: 0.8rem 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  letter-spacing: -0.03em;
}

.placeholder-note {
  margin: 0;
  color: rgba(232, 237, 232, 0.7);
  font-size: 0.8rem;
}

.mini {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 5.2rem;
  height: 5.2rem;
  border: 1px solid rgba(232, 237, 232, 0.4);
  pointer-events: none;
}

.mini.hidden {
  display: none;
}

.dpad {
  position: absolute;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  gap: 0.35rem;
}

.dpad-btn {
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid rgba(232, 237, 232, 0.4);
  background: rgba(23, 32, 29, 0.7);
  color: var(--stage-text);
  font-size: 0.8rem;
  transition: background-color 140ms ease;
}

.dpad-btn:disabled {
  cursor: default;
  opacity: 0.25;
}

.dpad-btn:hover:not(:disabled) {
  background: rgba(199, 243, 107, 0.25);
}

.dpad-btn[aria-pressed="true"] {
  background: var(--acid);
  color: var(--ink);
}

.dpad-btn.up { grid-area: up; }
.dpad-btn.left { grid-area: left; }
.dpad-btn.right { grid-area: right; }
.dpad-btn.down { grid-area: down; }

.sample-button {
  margin-top: 1rem;
  padding: 0.4rem 1rem;
  border: 1px solid rgba(232, 237, 232, 0.4);
  background: transparent;
  color: var(--stage-text);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  transition: background-color 140ms ease;
}

.sample-button:hover {
  background: rgba(199, 243, 107, 0.25);
}

.sheet-info {
  position: absolute;
  top: 1rem;
  right: 6.9rem;
  left: 1rem;
  margin: 0;
  color: rgba(232, 237, 232, 0.72);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.sheet-info.error {
  color: var(--acid);
}

/* Direction strip */

.strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.5rem, 2vw, 1.25rem);
  margin-top: clamp(1.25rem, 4vw, 2.25rem);
}

.strip-item {
  margin: 0;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.strip-canvas {
  display: block;
  width: 100%;
  height: clamp(110px, 18vw, 190px);
}

.strip-item figcaption {
  border-top: 1px solid var(--line);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
}

/* Controls */

.controls {
  margin-top: clamp(1.5rem, 5vw, 3rem);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.primary-button {
  padding: 0.6rem 1.4rem;
  border: 1px solid var(--ink);
  background: var(--acid);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: transform 140ms ease;
}

.primary-button:hover {
  transform: translateY(-2px);
}

.layers {
  margin-top: 1.5rem;
}

.layers.hidden {
  display: none;
}

.layers-head {
  display: flex;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.text-button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 0.74rem;
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.layers-note {
  margin: 0.2rem 0 0;
  font-size: 0.74rem;
}

.layer-list {
  margin: 0.5rem 0 0;
  padding: 0;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.55);
  list-style: none;
}

.layer-item {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.35rem 0.6rem;
}

.layer-item + .layer-item {
  border-top: 1px solid var(--line);
}

.layer-item input {
  accent-color: var(--blue);
}

.layer-thumbnail {
  flex: none;
  width: 36px;
  height: 48px;
  background: var(--stage);
  image-rendering: pixelated;
}

.layer-item {
  cursor: pointer;
}

.layer-item.selected {
  background: rgba(199, 243, 107, 0.55);
}

.layer-name {
  overflow: hidden;
  flex: 1;
  min-width: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 0.82rem;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-size {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
}

.layer-button {
  flex: none;
  width: 1.8rem;
  height: 1.8rem;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: inherit;
  font-size: 0.7rem;
}

.layer-button:hover:not(:disabled) {
  background: var(--acid);
}

.layer-button:disabled {
  cursor: default;
  opacity: 0.3;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: clamp(1rem, 3vw, 1.75rem);
  margin-top: 1.5rem;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-label {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.control select {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.7);
  color: inherit;
  font-size: 0.82rem;
}

.control input[type="range"] {
  width: 100%;
  accent-color: var(--blue);
}

.control-checks {
  gap: 0.3rem;
}

.check {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.82rem;
}

.check input {
  accent-color: var(--blue);
}

.hint {
  margin: 2rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.7rem;
  letter-spacing: 0.04em;
}

/* Guide */

.guide {
  max-width: 760px;
  margin-top: clamp(3rem, 8vw, 5rem);
  font-size: 0.92rem;
}

.guide h2 {
  margin: 2.5rem 0 0.6rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.3rem, 3vw, 1.7rem);
  font-weight: 400;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.guide h2:first-child {
  margin-top: 0;
}

.guide p {
  margin: 0.6rem 0;
}

.guide ol,
.guide ul {
  margin: 0.6rem 0;
  padding-left: 1.4rem;
}

.guide dt {
  margin-top: 1rem;
  font-weight: 700;
}

.guide dd {
  margin: 0.15rem 0 0;
}

.guide a {
  color: inherit;
  text-underline-offset: 0.3em;
}

.ad {
  margin-top: clamp(2rem, 5vw, 3rem);
}

.ad-label {
  display: block;
  margin-bottom: 0.3rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.66rem;
  letter-spacing: 0.1em;
}

.ad ins {
  max-width: 100%;
}

/* 配信する広告が無かった枠（AdSense が data-ad-status="unfilled" を付ける）は、見出しごと隠す */
.ad:has(ins.adsbygoogle[data-ad-status="unfilled"]) {
  display: none;
}

.promo {
  display: flex;
  gap: 1.25rem;
  align-items: center;
  margin-top: clamp(2rem, 5vw, 3rem);
  padding: 1rem 1.25rem;
  border: 1px solid var(--ink);
  background: rgba(255, 255, 255, 0.55);
}

.promo img {
  flex: none;
  width: 202px;
  height: 66px;
  image-rendering: pixelated;
}

.promo p {
  flex: 1;
  margin: 0;
  font-size: 0.88rem;
}

.promo .primary-button {
  flex: none;
  text-decoration: none;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 4rem;
  font-size: 0.78rem;
}

.app-footer a {
  color: inherit;
  text-underline-offset: 0.3em;
}

.app-footer span {
  margin-right: auto;
}

@media (max-width: 760px) {
  .title-row {
    flex-direction: column;
    gap: 1.5rem;
    align-items: start;
  }

  .logo img {
    width: 303px;
    height: 132px;
  }

  .placeholder {
    padding-bottom: 8rem;
  }

  .strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .promo {
    flex-direction: column;
    align-items: start;
  }

  .layer-size {
    display: none;
  }
}

@media (max-width: 360px) {
  .logo img {
    width: 202px;
    height: 88px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .primary-button:hover {
    transform: none;
  }
}
