/* 恐応研式 恐怖診断 Web 版: ゲームの診断画面と同じ「方眼の用紙」 */
:root {
  --back: #f6f8f2;
  --paper: #ffffff;
  --ink: #22382e;
  --sub: #56705f;
  --accent: #5aa488;
  --grid: rgba(90, 164, 136, 0.16);
  --red: #c0392b;
  --selected: #dff0e8;
  --radius: 2px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background-color: var(--back);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  line-height: 1.7;
}

button, a.primary, a.ghost { font: inherit; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 2px solid var(--accent);
  background: rgba(246, 248, 242, 0.92);
}

.brand { font-weight: 900; font-size: 16px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.kicker-top { flex: 1; font-size: 13px; color: var(--sub); letter-spacing: 0.05em; }

.lang {
  border: 1px solid var(--accent);
  background: var(--paper);
  color: var(--ink);
  padding: 4px 12px;
  font-size: 13px;
  white-space: nowrap;
  flex: none;
  cursor: pointer;
}

main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.sheet {
  background: var(--paper);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 28px 28px 32px;
  box-shadow: 0 2px 0 rgba(34, 56, 46, 0.08);
}

[hidden] { display: none !important; }

/* ---- はじめ ---- */
.title { display: flex; align-items: center; gap: 18px; margin: 8px 0 20px; }
.check { position: relative; width: 84px; height: 84px; flex: none; }
.check .box { position: absolute; left: 6px; top: 22px; width: 58px; height: 58px; border: 5px solid var(--ink); }
.check svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.check path { fill: none; stroke: var(--red); stroke-width: 11; stroke-linecap: square; }
.kicker { margin: 0; font-weight: 700; font-size: 20px; }
h1 { margin: -6px 0 0; font-size: clamp(44px, 12vw, 72px); font-weight: 900; line-height: 1.1; letter-spacing: 0.04em; }
.subtitle { margin: 4px 0 0; color: var(--sub); font-size: 18px; }
.lead { white-space: pre-line; font-size: 16px; }
.notice {
  font-size: 14px;
  color: var(--sub);
  border-left: 4px solid var(--red);
  padding: 6px 12px;
  background: #fbf3f1;
}

.primary, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 8px 22px;
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  text-decoration: none;
  cursor: pointer;
  font-size: 16px;
}
.primary { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.primary:hover, .primary:focus-visible { background: #2f4d40; }
.ghost { background: var(--paper); color: var(--ink); }
.ghost:hover, .ghost:focus-visible { background: var(--selected); }
#start { width: 100%; margin-top: 12px; font-size: 18px; min-height: 56px; }

/* ---- 設問 ---- */
.qhead { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.qtitle { font-weight: 700; }
.progress { color: var(--sub); font-size: 14px; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--selected); margin: 8px 0 18px; }
.bar .fill { height: 100%; width: 0; background: var(--accent); transition: width 0.25s; }
.instruction { color: var(--sub); font-size: 14px; margin: 0 0 6px; }
.qtext { font-size: clamp(20px, 5vw, 26px); line-height: 1.5; margin: 0 0 20px; min-height: 2.4em; }

.qbody { display: flex; gap: 20px; align-items: flex-start; }
.answers { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; flex: 1; }
.answers button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  min-height: 52px;
  padding: 10px 14px;
  border: 2px solid var(--accent);
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-size: 16px;
}
.answers button:hover, .answers button:focus-visible { background: var(--selected); }
.answers button .mark {
  flex: none;
  width: 26px;
  height: 26px;
  border: 2px solid var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--red);
  font-size: 16px;
}
.answers button .num { color: var(--sub); font-size: 13px; min-width: 1.2em; }
.answers button.chosen { background: var(--selected); }
.answers button.chosen .mark::after { content: "✓"; font-size: 22px; line-height: 1; }
.answers button.ranked { background: var(--selected); }
.answers button:disabled { cursor: default; }

.ranksheet { width: 240px; flex: none; border: 2px solid var(--accent); padding: 12px; background: #fbfdfb; }
.ranksheet ol { list-style: none; margin: 0 0 10px; padding: 0; }
.ranksheet li { border-bottom: 1px dashed var(--accent); padding: 4px 0; font-size: 14px; min-height: 2em; }
.ranksheet li .rank { color: var(--red); font-weight: 700; margin-right: 6px; }
.ranksheet li.next { background: var(--selected); }
.ranksheet .ghost { width: 100%; min-height: 40px; font-size: 14px; }

/* ---- 結果 ---- */
.label { color: var(--sub); font-size: 14px; margin: 18px 0 2px; }
.feartype { font-size: clamp(32px, 9vw, 52px); font-weight: 900; margin: 0; line-height: 1.25; }
.ranking { list-style: none; margin: 6px 0 0; padding: 0; }
.ranking li { display: flex; gap: 16px; padding: 6px 10px; background: rgba(90, 164, 136, 0.08); margin-bottom: 4px; }
.ranking li .rank { color: var(--sub); min-width: 3em; }
.codebox { margin-top: 22px; padding: 14px 16px; border: 2px dashed var(--accent); background: #fbfdfb; }
.codebox .label { margin-top: 0; }
.coderow { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
#code { font-family: "Noto Sans JP", ui-monospace, monospace; font-size: clamp(18px, 5vw, 26px); font-weight: 700; letter-spacing: 0.04em; word-break: keep-all; overflow-wrap: normal; }
.note { color: var(--sub); font-size: 13px; margin: 8px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.status { min-height: 1.6em; color: var(--accent); font-size: 14px; margin: 6px 0 0; }
.steam { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--accent); }
.steamlink { width: 100%; }
.retry { margin-top: 16px; width: 100%; }

.footer { display: flex; justify-content: center; gap: 16px; flex-wrap: wrap; color: var(--sub); font-size: 12px; padding: 12px 16px 20px; }
.footer a { color: var(--sub); }

@media (max-width: 640px) {
  .kicker-top { display: none; }
  .sheet { padding: 20px 16px 24px; }
  .qbody { flex-direction: column-reverse; }
  .ranksheet { width: 100%; }
  .actions > * { flex: 1 1 100%; }
  .check { width: 64px; height: 64px; }
  .check .box { left: 4px; top: 16px; width: 44px; height: 44px; border-width: 4px; }
}
