/*!
 * English Escape Mission - shared stylesheet
 * Design goals: readable (large type, high contrast), operable (big tap targets,
 * visible focus), perceivable without color alone (icons + text), calm motion.
 */

/* ---------- Design tokens ---------- */
:root {
  --c: #1d4ed8;          /* accent (text/buttons: contrast >= 4.5:1 on white) */
  --c-soft: #eaf1ff;     /* accent tint for backgrounds */
  --c-line: #b9cdfb;     /* accent tint for borders */
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-alt: #f8f9fc;
  --line: #d3dae5;
  --text: #172033;
  --muted: #566074;
  --ok: #14703a;
  --ok-bg: #e8f7ee;
  --ok-line: #7cc796;
  --ng: #a8281c;
  --ng-bg: #fdeeec;
  --ng-line: #f0a9a1;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(23, 32, 51, .06), 0 8px 20px rgba(23, 32, 51, .06);
}

[data-theme="blue"]   { --c: #1d4ed8; --c-soft: #eaf1ff; --c-line: #b9cdfb; }
[data-theme="violet"] { --c: #6d28d9; --c-soft: #f2ebff; --c-line: #d4c0fb; }
[data-theme="orange"] { --c: #c2410c; --c-soft: #fff0e5; --c-line: #f6c4a3; }

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-size: 106%; -webkit-text-size-adjust: 100%; }
html[data-size="large"] { font-size: 125%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: linear-gradient(180deg, var(--c-soft) 0, var(--bg) 280px) no-repeat, var(--bg);
  font-family: system-ui, -apple-system, "Hiragino Sans", "BIZ UDPGothic", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.7;
}

h1, h2, h3, p { margin: 0; }
button, a { font: inherit; }
button { color: inherit; }

:focus-visible { outline: 3px solid var(--c); outline-offset: 3px; }

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--c); color: #fff; padding: .6rem 1rem; border-radius: 0 0 12px 0; font-weight: 700;
}
.skip:focus { left: 0; }

.wrap { width: min(780px, 100%); margin: 0 auto; padding: 14px 14px 48px; }
.wrap.wide { width: min(1040px, 100%); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  margin-bottom: .9rem;
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 3.2rem; padding: 0 1.3rem;
  border: 2px solid var(--c); border-radius: 14px;
  background: var(--c); color: #fff;
  font-weight: 800; font-size: 1.05rem; text-decoration: none; cursor: pointer;
  transition: filter .15s, transform .12s;
}
.btn:hover { filter: brightness(1.1); }
.btn:active { transform: scale(.985); }
.btn.block { display: flex; width: 100%; margin-top: .9rem; }
.btn.ghost { background: #fff; color: var(--c); }

.chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 44px; padding: 0 .85rem;
  border: 2px solid var(--line); border-radius: 12px;
  background: #fff; color: var(--text);
  font-weight: 700; font-size: .92rem; text-decoration: none; cursor: pointer;
}
.chip:hover { border-color: var(--c); }

/* ---------- Game header ---------- */
.top { border-top: 6px solid var(--c); }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.brand { font-size: .8rem; letter-spacing: .14em; font-weight: 800; color: var(--c); }
.top h1 { margin: .15rem 0 .1rem; font-size: clamp(1.45rem, 5.6vw, 2rem); line-height: 1.25; }
.sub { color: var(--muted); font-size: .92rem; }

.segs { display: flex; gap: 3px; margin: .9rem 0 .4rem; }
.segs i { flex: 1; height: 10px; border-radius: 5px; background: #e1e6ef; }
.segs i.done { background: var(--c); }
.segs i.now { background: var(--c-soft); box-shadow: inset 0 0 0 2px var(--c); }

.goal { margin: .1rem 0 .75rem; font-weight: 800; font-size: .98rem; color: var(--c); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .45rem; }
.stat { background: var(--c-soft); border-radius: 12px; padding: .4rem .55rem; min-width: 0; }
.stat span { display: block; font-size: .74rem; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.stat b { font-size: 1.2rem; font-variant-numeric: tabular-nums; }

/* ---------- Mission ---------- */
.m-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; }
.area {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--c-soft); color: var(--c);
  border-radius: 99px; padding: .25rem .85rem;
  font-weight: 800; font-size: .86rem; letter-spacing: .08em;
}
.mtitle { display: flex; align-items: center; gap: .6rem; margin: .55rem 0 .7rem; font-size: 1.15rem; }
.mtitle:focus { outline: none; }
.mtitle:focus-visible { outline: 3px solid var(--c); outline-offset: 4px; border-radius: 8px; }
.ico { font-size: 2.5rem; line-height: 1; }

.story { display: grid; gap: .4rem; }
.fact {
  padding: .55rem .85rem;
  border-left: 5px solid var(--c);
  background: var(--surface-alt);
  border-radius: 0 12px 12px 0;
  font-size: 1.13rem; line-height: 1.7; letter-spacing: .01em;
}
.fact strong, .q strong { background: #fff3b0; border-radius: 4px; padding: 0 .15em; }
.num {
  font-weight: 800; color: var(--c); font-variant-numeric: tabular-nums;
}

.qlabel { font-size: .8rem; font-weight: 800; letter-spacing: .14em; color: var(--c); margin-bottom: .2rem; }
.q { font-size: clamp(1.2rem, 4.6vw, 1.45rem); font-weight: 800; line-height: 1.45; margin-bottom: .9rem; }

/* ---------- Choices ---------- */
.choices { display: grid; gap: .6rem; }
.choice {
  position: relative;
  display: grid; grid-template-columns: 2.3rem 1fr 1.6rem; align-items: center; gap: .75rem;
  width: 100%; min-height: 3.7rem; padding: .7rem .85rem;
  text-align: left; cursor: pointer;
  border: 2px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--text); font-weight: 700;
  transition: border-color .12s, background .12s, transform .1s;
}
.choice:hover:not([aria-disabled="true"]) { border-color: var(--c); background: var(--c-soft); }
.choice:active:not([aria-disabled="true"]) { transform: scale(.99); }
.choice[aria-disabled="true"] { cursor: default; }
.badge {
  width: 2.2rem; height: 2.2rem; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c-soft); color: var(--c); font-weight: 800;
}
.ctext { display: block; min-width: 0; }
.en { display: block; font-size: 1.12rem; line-height: 1.4; }
.jp { display: none; margin-top: .15rem; color: var(--muted); font-size: .9rem; font-weight: 500; }
.show .jp { display: block; }
.mark { font-size: 1.4rem; font-weight: 900; text-align: center; }

.choice.ok { border-color: var(--ok); background: var(--ok-bg); }
.choice.ok .badge { background: var(--ok); color: #fff; }
.choice.ok .mark { color: var(--ok); }
.choice.no { border-style: dashed; border-color: var(--ng-line); background: #faf5f4; color: var(--muted); }
.choice.no .badge { background: #eee3e1; color: var(--ng); }
.choice.no .mark { color: var(--ng); }

/* ---------- Clue tools ---------- */
.tools { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.tool {
  min-height: 46px; padding: 0 .95rem;
  border: 2px solid var(--line); border-radius: 12px; background: #fff;
  font-weight: 800; font-size: .92rem; cursor: pointer;
}
.tool:hover { border-color: var(--c); }
.tool[aria-expanded="true"] { background: var(--c-soft); border-color: var(--c); }
.tool.book { margin-left: auto; }
.tool.pulse { animation: pulse 1.6s ease-in-out 3; }

.hb {
  margin-top: .7rem; padding: .8rem .95rem;
  border-left: 5px solid var(--c); border-radius: 0 12px 12px 0;
  background: var(--c-soft); line-height: 1.75; font-size: 1rem;
}
.hb b { display: block; font-size: .82rem; letter-spacing: .08em; color: var(--c); }
.hb span { display: block; }

/* ---------- Feedback ---------- */
.fb { margin-top: .9rem; border-radius: 14px; padding: .85rem 1rem; border: 2px solid; }
.fb.good { background: var(--ok-bg); border-color: var(--ok-line); color: #0f4f29; }
.fb.bad { background: var(--ng-bg); border-color: var(--ng-line); color: #7f1d14; }
.fb-t { display: flex; gap: .5rem; align-items: baseline; font-weight: 800; font-size: 1.08rem; }
.fb-why { margin-top: .35rem; font-size: .98rem; color: var(--text); font-weight: 500; line-height: 1.75; }
.fb-why b { color: inherit; }
.clue-get {
  margin-top: .65rem; display: flex; gap: .6rem; align-items: flex-start;
  background: #fff; border: 2px dashed var(--c); border-radius: 12px; padding: .6rem .8rem;
  color: var(--text); animation: pop .35s ease-out;
}
.clue-get small { display: block; font-size: .76rem; font-weight: 800; letter-spacing: .1em; color: var(--c); }

.notice {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .6rem;
  margin-bottom: .9rem; padding: .7rem .95rem;
  background: #fff; border: 2px dashed var(--c-line); border-radius: 14px;
  font-size: .95rem; font-weight: 600;
}

/* ---------- Footer ---------- */
.foot { display: flex; justify-content: space-between; gap: .6rem; margin-top: .4rem; }

/* ---------- Dialog (CLUE BOOK) ---------- */
dialog {
  width: min(600px, 92%); max-height: 85vh; padding: 0;
  border: 0; border-radius: 20px; color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog::backdrop { background: rgba(15, 23, 42, .55); }
.dlg-in { padding: 1.2rem; overflow: auto; max-height: 85vh; }
.dlg-in h2 { font-size: 1.3rem; }
.dlg-in .hint { color: var(--muted); font-size: .92rem; margin-top: .2rem; }
.clues { counter-reset: c; list-style: none; margin: .9rem 0 1rem; padding: 0; display: grid; gap: .5rem; }
.clues li {
  counter-increment: c; display: flex; gap: .7rem; align-items: flex-start;
  padding: .65rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-alt);
  font-weight: 600;
}
.clues li::before {
  content: counter(c); flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%;
  display: grid; place-items: center; background: var(--c); color: #fff; font-weight: 800; font-size: .85rem;
}
.clues li.latest { border-color: var(--c); background: var(--c-soft); }
.empty { margin: .9rem 0 1rem; color: var(--muted); }

/* ---------- Finish ---------- */
.finish { text-align: center; padding-top: 1.6rem; }
.trophy { font-size: 4rem; line-height: 1.1; animation: pop .5s ease-out; }
.finish h2 { font-size: clamp(1.5rem, 6vw, 2rem); margin-top: .3rem; }
.finish h2:focus { outline: none; }
.lead { color: var(--muted); font-weight: 600; }
.results { display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem; margin: 1.1rem 0; }
.result { background: var(--c-soft); border-radius: 14px; padding: .6rem; }
.result span { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); }
.result b { font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.praise { font-weight: 700; line-height: 1.8; margin-bottom: .8rem; }
.review { text-align: left; margin: .6rem 0 1.1rem; }
.review summary { cursor: pointer; font-weight: 800; padding: .5rem 0; min-height: 44px; }
.actions { display: grid; gap: .6rem; }

/* ---------- Index page ---------- */
.hero { text-align: center; padding: 2.2rem 1.2rem 1.6rem; border-top: 6px solid var(--c); position: relative; }
.hero .util { position: absolute; top: .8rem; right: .8rem; }
.hero h1 { font-size: clamp(2rem, 8vw, 3.1rem); line-height: 1.2; margin: .3rem 0 .6rem; }
.hero p.desc { max-width: 40rem; margin: .6rem auto; color: var(--muted); font-size: 1.02rem; }
.pill {
  display: inline-block; margin-top: .4rem; padding: .4rem .9rem;
  background: var(--c-soft); color: var(--c); border-radius: 99px; font-weight: 800; font-size: .88rem;
}
.allclear { margin-top: .9rem; font-weight: 800; color: var(--ok); }

.section-title { font-size: 1.05rem; margin: 1.2rem .2rem .6rem; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .9rem; margin-bottom: .9rem; }
.game {
  position: relative; display: flex; flex-direction: column; margin: 0;
  border-top: 6px solid var(--c);
  transition: transform .15s, box-shadow .15s;
}
.game:hover { transform: translateY(-3px); }
.game:focus-within { box-shadow: 0 0 0 3px var(--c), var(--shadow); }
.game.recommended { border-color: var(--c); box-shadow: 0 0 0 2px var(--c-line), var(--shadow); }
.g-top { display: flex; justify-content: space-between; align-items: center; min-height: 2rem; }
.g-icon { font-size: 3rem; line-height: 1; }
.status {
  font-size: .82rem; font-weight: 800; padding: .2rem .7rem; border-radius: 99px;
  background: var(--c-soft); color: var(--c);
}
.status.clear { background: var(--ok-bg); color: var(--ok); }
.ribbon {
  position: absolute; top: -.8rem; left: 1rem;
  background: var(--c); color: #fff; font-weight: 800; font-size: .82rem;
  padding: .2rem .8rem; border-radius: 99px; box-shadow: var(--shadow);
}
.g-no { margin-top: .5rem; font-size: .82rem; font-weight: 800; letter-spacing: .12em; color: var(--c); }
.game h2 { font-size: 1.35rem; line-height: 1.25; margin: .1rem 0 .4rem; }
.game .desc { color: var(--muted); font-size: .95rem; }
.meta { margin: .9rem 0 1rem; padding: 0; }
.meta > div { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid #e8ecf2; padding: .45rem .2rem; font-size: .9rem; }
.meta dt { color: var(--muted); font-weight: 700; font-size: .82rem; letter-spacing: .04em; }
.meta dd { margin: 0; font-weight: 800; }
.dots i {
  display: inline-block; width: .9rem; height: .9rem; margin-left: .2rem;
  border: 2px solid var(--c); border-radius: 50%; vertical-align: middle;
}
.dots i.on { background: var(--c); }
.dots i.half { background: linear-gradient(90deg, var(--c) 50%, transparent 50%); }
.start { margin-top: auto; }
.start::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }

.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { counter-increment: s; background: var(--surface-alt); border-radius: 14px; padding: .8rem .9rem; font-size: .95rem; }
.steps li::before {
  content: counter(s); display: inline-grid; place-items: center; width: 1.7rem; height: 1.7rem; margin-bottom: .3rem;
  border-radius: 50%; background: var(--c); color: #fff; font-weight: 800; font-size: .85rem;
}
.steps b { display: block; }
.note { margin-top: .8rem; color: var(--muted); font-size: .88rem; }

/* ---------- Motion ---------- */
@keyframes pop { from { transform: scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 0 7px var(--c-line); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .grid { grid-template-columns: 1fr; }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .wrap { padding: 10px 10px 40px; }
  .card { padding: 1rem .95rem; }
  .tools .tool { flex: 1 1 calc(50% - .5rem); }
  .tools .tool.book { flex-basis: 100%; margin-left: 0; }
  .stat span { font-size: .7rem; }
  .stat b { font-size: 1.1rem; }
}
