:root {
  color-scheme: light;
  --bg: #f6f2ea;
  --paper: #fffdf8;
  --ink: #24211d;
  --muted: #6b6258;
  --line: #d9cec0;
  --accent: #2d5f73;
  --accent-strong: #183b49;
  --danger: #9f2f35;
  --ok: #24714d;
  --shadow: 0 18px 50px rgba(49, 39, 28, 0.12);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.82), rgba(246, 242, 234, 0.96)),
    radial-gradient(circle at 18% 8%, rgba(45, 95, 115, 0.10), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.7;
}

button,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 32px;
}

.hero {
  margin-bottom: 24px;
}

.lab-label,
.mode-name,
.difficulty {
  margin: 0;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

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

.subtitle {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

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

.game-panel {
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-head h2 {
  margin: 2px 0 0;
  font-size: clamp(1.35rem, 4vw, 2rem);
  line-height: 1.2;
}

.status-stack {
  display: grid;
  gap: 6px;
  min-width: 92px;
  text-align: right;
  color: var(--accent-strong);
  font-weight: 800;
}

.status-stack span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  background: #f8f5ef;
}

.rules {
  display: grid;
  gap: 4px;
  margin-bottom: 18px;
  color: var(--muted);
}

.rules p {
  margin: 0;
}

.support-note {
  font-size: 0.92rem;
}

.trap-card {
  display: grid;
  justify-items: center;
  gap: 12px;
  min-height: 250px;
  padding: 24px;
  border: 1px solid #cfc2b3;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(45, 95, 115, 0.07), transparent 45%),
    #fbf8f1;
}

.target-wrap {
  display: grid;
  place-items: center;
  width: min(100%, 560px);
  min-height: 112px;
  padding: 18px;
  border-radius: 8px;
  background: #fffdf8;
  border: 1px solid var(--line);
}

.target-text {
  font-size: clamp(3rem, 15vw, 7rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  text-align: center;
}

.target-text.is-phrase {
  font-size: clamp(2.35rem, 10vw, 5.3rem);
}

.ink-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
}

.ink-chip {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(36, 33, 29, 0.28);
  border-radius: 50%;
  background: currentColor;
}

.round-message {
  min-height: 1.7em;
  margin: 0;
  color: var(--accent-strong);
  font-weight: 800;
  text-align: center;
}

.answer-form {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.answer-form label {
  color: var(--muted);
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 78px;
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  color: var(--ink);
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(45, 95, 115, 0.16);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

#judgeButton {
  background: var(--accent);
}

#retryButton {
  background: #574633;
}

.result-strip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-weight: 800;
}

.result-strip span:first-child.clear {
  color: var(--ok);
}

.result-strip span:first-child.trapped {
  color: var(--danger);
}

.notes {
  margin-top: 18px;
  padding: 20px 24px;
}

.notes h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
}

.notes ul {
  margin: 0;
  padding-left: 1.2em;
  color: var(--muted);
}

.site-footer {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto 32px;
  padding: 20px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

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

.site-footer a {
  color: var(--accent-strong);
  font-weight: 700;
}

@media (max-width: 560px) {
  .page-shell {
    width: min(100% - 20px, 1040px);
    padding-top: 28px;
  }

  .game-panel,
  .notes {
    padding: 16px;
  }

  .panel-head,
  .result-strip {
    display: grid;
    text-align: left;
  }

  .status-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    min-width: 0;
    text-align: center;
  }

  .trap-card {
    min-height: 230px;
    padding: 16px;
  }

  .target-wrap {
    min-height: 104px;
    padding: 12px;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .site-footer {
    width: min(100% - 20px, 1040px);
  }
}
