:root {
  color-scheme: light;
  --ink: #202024;
  --muted: #62636c;
  --paper: #f6f2e9;
  --panel: #fffdf8;
  --line: #d8d1c4;
  --accent: #17684c;
  --accent-dark: #0f4635;
  --danger: #a73532;
  --danger-dark: #6c2020;
  --shadow: 0 18px 50px rgba(48, 42, 33, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 0;
  background: var(--paper);
}

body {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  line-height: 1.75;
  letter-spacing: 0;
}

button,
textarea {
  font: inherit;
}

.page-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 32px 18px 28px;
}

.hero {
  padding: 18px 0 24px;
}

.lab-label,
.eyebrow,
.target-label,
.difficulty {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 6px 0 10px;
  font-size: clamp(2.15rem, 4.4vw, 4.5rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.lead {
  max-width: 720px;
  margin: 0;
  color: #3f4046;
  font-size: 1.05rem;
}

.game-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 22px;
}

.panel-header,
.signal-board,
.controls,
.result-line {
  display: flex;
  align-items: center;
  gap: 14px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 18px;
}

.panel-header h2 {
  margin: 2px 0 0;
  font-size: clamp(1.24rem, 2.5vw, 2rem);
  line-height: 1.32;
  letter-spacing: 0;
}

.round-badge {
  flex: 0 0 auto;
  min-width: 72px;
  border: 1px solid #c9c1b3;
  border-radius: 8px;
  padding: 8px 12px;
  text-align: center;
  font-weight: 800;
  background: #f2eadc;
}

.signal-board {
  justify-content: space-between;
  min-height: 132px;
  border: 1px solid #cfc7b8;
  border-radius: 8px;
  padding: 16px;
  background: #f9f5ed;
}

.traffic-light {
  display: grid;
  gap: 10px;
  flex: 0 0 auto;
  width: 64px;
  border: 1px solid #2e2f33;
  border-radius: 28px;
  padding: 10px;
  background: #27282c;
}

.lamp {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  display: block;
  border: 2px solid rgba(255, 255, 255, 0.32);
  opacity: 0.34;
  filter: grayscale(0.35);
}

.lamp-green {
  background: #2fb879;
}

.lamp-red {
  background: #df4b48;
}

.lamp.is-active {
  opacity: 1;
  filter: none;
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.12), 0 0 18px currentColor;
}

.signal-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.signal-state {
  margin: 0;
  font-size: clamp(1.8rem, 4vw, 3.2rem);
  font-weight: 900;
  line-height: 1;
}

.signal-state.is-green {
  color: var(--accent);
}

.signal-state.is-red {
  color: var(--danger);
}

.signal-help {
  margin: 8px 0 0;
  color: var(--muted);
}

.signal-timers {
  display: grid;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 118px;
  color: #393a40;
  font-size: 0.92rem;
  text-align: right;
}

.target-area {
  margin-top: 18px;
  border-left: 5px solid var(--accent);
  padding: 4px 0 4px 16px;
}

.target-text {
  min-height: 74px;
  margin: 6px 0;
  font-size: clamp(1.65rem, 4vw, 3rem);
  font-weight: 800;
  line-height: 1.35;
}

.input-label {
  display: block;
  margin-top: 18px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

textarea {
  display: block;
  width: 100%;
  min-height: 112px;
  margin-top: 6px;
  border: 2px solid #bdb5a6;
  border-radius: 8px;
  padding: 14px;
  resize: vertical;
  background: #fff;
  color: var(--ink);
  font-size: 1.2rem;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(23, 104, 76, 0.18);
}

textarea.is-red {
  border-color: var(--danger);
  background: #fff7f6;
}

textarea:disabled {
  color: #74757b;
  background: #ece8df;
}

.controls {
  flex-wrap: wrap;
  margin-top: 16px;
}

button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  padding: 10px 18px;
  background: var(--accent-dark);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  background: #4d4a44;
}

button:hover {
  filter: brightness(1.08);
}

button:focus-visible {
  outline: 3px solid rgba(23, 104, 76, 0.28);
  outline-offset: 2px;
}

.result-line {
  flex-wrap: wrap;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

#judgeText {
  min-width: 118px;
  border-radius: 8px;
  padding: 8px 12px;
  background: #efe5d4;
  font-weight: 900;
  text-align: center;
}

#judgeText.is-clear {
  background: #d9efe4;
  color: var(--accent-dark);
}

#judgeText.is-trapped {
  background: #f5d9d6;
  color: var(--danger-dark);
}

#judgeText.is-complete {
  background: #e3deca;
  color: #3e3b34;
}

#statusText {
  min-width: 0;
  color: var(--muted);
}

.history-list {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
}

.history-list li {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #faf7ef;
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.history-list .clear {
  border-color: #9fcfb7;
  background: #e6f5ed;
  color: var(--accent-dark);
}

.history-list .trapped {
  border-color: #e1aaa4;
  background: #fff0ee;
  color: var(--danger-dark);
}

.notes {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  background: rgba(255, 253, 248, 0.7);
  color: #4d4e55;
}

.notes p {
  margin: 0;
}

.site-footer {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 0 18px 30px;
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
}

.site-footer a {
  color: #2b6150;
  text-underline-offset: 3px;
}

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

  .game-panel {
    padding: 16px;
  }

  .panel-header,
  .signal-board {
    align-items: stretch;
    flex-direction: column;
  }

  .round-badge,
  .signal-timers {
    width: 100%;
    text-align: left;
  }

  .traffic-light {
    grid-template-columns: repeat(2, 42px);
    width: max-content;
    border-radius: 28px;
  }

  .target-area {
    padding-left: 12px;
  }

  .history-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
