/* Moirai: The Thread of Fate — shell: ink, bronze and thread */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  background: #07050f;
  color: #e9e2f4;
  font: 15px/1.6 "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.top {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 14px 18px 6px;
}
.wordmark {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 23px; font-weight: 700; letter-spacing: .26em; color: #f6ecd8;
}
.wordmark small {
  display: block; font-family: "Avenir Next", system-ui, sans-serif;
  font-size: 10px; font-weight: 600; letter-spacing: .32em;
  color: #c9964f; text-transform: uppercase; margin-top: 3px;
}
.top-note { font-size: 12.5px; color: #9a8fb5; }

#app { padding: 8px 18px 0; }
#stage-wrap {
  position: relative;
  height: min(80vh, 780px);
  min-height: 460px;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(201,150,79,.26);
  background: #07050f;
  box-shadow: 0 26px 80px rgba(0,0,0,.6), inset 0 0 120px rgba(60,30,90,.30);
}
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* ---------- HUD ---------- */
.hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 18px;
  background: linear-gradient(180deg, rgba(6,4,12,.86), rgba(6,4,12,0));
  pointer-events: none;
}
.hud button {
  pointer-events: auto;
  background: rgba(22,14,32,.78); color: #f0e6d6;
  border: 1px solid rgba(201,150,79,.34);
  border-radius: 9px; padding: 6px 10px; font-size: 13px; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.hud button:hover { border-color: rgba(255,214,150,.8); background: rgba(48,28,52,.9); }
.hud-mid { flex: 1; min-width: 0; pointer-events: none; }
.hud-ch {
  font-size: 11px; letter-spacing: .18em; text-transform: uppercase;
  color: #d9bf94; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hud-souls { display: flex; gap: 5px; margin-top: 4px; }
.soul-pip {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid rgba(255,220,170,.55);
  background: rgba(255,255,255,.06);
  transition: background .25s, box-shadow .25s;
}
.soul-pip.on { background: #ffd88a; box-shadow: 0 0 10px rgba(255,200,110,.9); }
.soul-pip.gone { background: #7a2233; border-color: rgba(255,120,140,.7); }
.hud-time { font-variant-numeric: tabular-nums; font-size: 15px; font-weight: 700; color: #f6ecd8; min-width: 46px; text-align: right; }
.hud-time.over { color: #ffb27a; }
.hud-slow b { color: #ffd88a; }
.hud-slow.spent { opacity: .38; }
.hud-slow.active { border-color: #9fd4ff; box-shadow: 0 0 14px rgba(120,180,255,.5); }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 5;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 38%, rgba(20,12,34,.70), rgba(5,3,10,.90));
  backdrop-filter: blur(3px);
  animation: fadeIn .22s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.scr-inner {
  text-align: center; max-width: 540px; padding: 26px 24px;
  animation: riseIn .28s cubic-bezier(.2,.8,.3,1) both;
}
@keyframes riseIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.scr-inner.wide { max-width: 680px; width: 94%; }
.kicker {
  font-size: 10.5px; letter-spacing: .34em; text-transform: uppercase;
  color: #c9964f; margin-bottom: 8px;
}
.scr-title {
  font-family: Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: clamp(28px, 4.2vw, 46px); font-weight: 700; letter-spacing: .04em; line-height: 1.1;
  background: linear-gradient(180deg, #fffaf0 10%, #f0cf95 62%, #b98a44 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 16px rgba(255,190,110,.18));
}
#title .scr-title { font-size: clamp(42px, 7vw, 74px); letter-spacing: .16em; }
#result .scr-title { font-size: clamp(24px, 3.4vw, 34px); max-width: 460px; margin-left: auto; margin-right: auto; }
.scr-sub { color: #b6a8c8; margin-bottom: 22px; font-size: 14.5px; }
.scr-hint { margin-top: 16px; font-size: 12.5px; color: #7f7597; }
.scr-hint strong { color: #cbb894; font-weight: 600; }
.act-kicker {
  font-size: 11px; letter-spacing: .3em; text-transform: uppercase;
  color: #c9964f; margin-bottom: 6px;
}
.brief-text { color: #cbbfd9; font-size: 14.5px; margin: 8px 0 14px; }
.brief-goal { color: #ffd88a; font-size: 14px; margin-bottom: 4px; }
.brief-par { color: #8d82a6; font-size: 12.5px; margin-bottom: 16px; }

.btn {
  display: block; width: 100%; margin: 8px auto; max-width: 330px;
  padding: 12px 18px; font-size: 15px; font-weight: 700;
  color: #f2e8d8; background: rgba(32,20,44,.86);
  border: 1px solid rgba(201,150,79,.36); border-radius: 12px;
  cursor: pointer; transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s;
  font-family: inherit;
}
.btn:hover { transform: translateY(-1px); border-color: rgba(255,214,150,.75); box-shadow: 0 8px 26px rgba(180,120,40,.20); }
.btn:active { transform: translateY(0); }
.btn.primary {
  background: linear-gradient(180deg, #d8ab5c, #a9762f);
  border-color: rgba(255,228,170,.7);
  color: #20140a;
  text-shadow: 0 1px 0 rgba(255,240,200,.4);
}
.btn.primary:hover { box-shadow: 0 10px 34px rgba(216,171,92,.38); }
.btn.ghost { background: transparent; border-color: rgba(201,150,79,.2); font-weight: 500; color: #b6a8c8; }

.endless-card {
  margin: 14px auto 0; max-width: 330px; padding: 10px 14px;
  font-size: 13px; color: #cbb4e6; cursor: pointer;
  border: 1px dashed rgba(180,140,240,.42); border-radius: 12px;
  transition: background .15s, border-color .15s;
}
.endless-card:hover { background: rgba(160,120,230,.10); border-color: rgba(200,170,255,.7); }

.ch-grid {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px; margin: 14px 0 4px;
}
.ch-btn {
  position: relative; padding: 9px 2px 7px;
  background: rgba(26,16,38,.92); border: 1px solid rgba(201,150,79,.28);
  border-radius: 10px; color: #efe4d4; cursor: pointer; text-align: center;
  transition: transform .12s, border-color .12s, background .12s;
  font-family: inherit;
}
.ch-btn .ch-n { display: block; font-weight: 700; font-size: 16px; font-family: Georgia, serif; }
.ch-btn .ch-act { display: block; font-size: 8.5px; letter-spacing: .16em; color: #a98a5c; text-transform: uppercase; }
.ch-btn .ch-stars { display: block; font-size: 9px; color: #ffd88a; letter-spacing: .06em; height: 12px; }
.ch-btn.locked { opacity: .3; cursor: not-allowed; }
.ch-btn:not(.locked):hover { border-color: rgba(255,214,150,.8); transform: translateY(-2px); background: rgba(46,28,54,.95); }
.ch-btn.cur { border-color: #ffd88a; box-shadow: 0 0 0 1px rgba(255,216,138,.35) inset; }

.res-badge {
  display: inline-block; padding: 4px 14px; border-radius: 20px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .26em; margin-bottom: 10px;
}
.res-badge.good { background: rgba(255,216,138,.14); color: #ffd88a; border: 1px solid rgba(255,216,138,.45); }
.res-badge.bad { background: rgba(255,90,110,.12); color: #ff9aa8; border: 1px solid rgba(255,90,110,.42); }
.res-stars { font-size: 32px; letter-spacing: .16em; color: #ffd88a; margin: 2px 0 4px; }
.res-stars .dim { color: rgba(255,216,138,.18); }
.res-stars span { display: inline-block; animation: starPop .45s cubic-bezier(.2,1.4,.4,1) both; }
.res-stars span:nth-child(2) { animation-delay: .12s; }
.res-stars span:nth-child(3) { animation-delay: .24s; }
@keyframes starPop { from { opacity: 0; transform: scale(.3) rotate(-25deg); } to { opacity: 1; transform: none; } }
.res-line { color: #b6a8c8; font-size: 14px; margin: 6px 0 16px; line-height: 1.65; }
.res-line b { color: #f6ecd8; }

.help-list { text-align: left; margin: 10px 0 18px; padding-left: 20px; color: #cbbfd9; font-size: 14px; }
.help-list li { margin: 7px 0; }
.help-list strong { color: #ffd88a; font-weight: 600; }

.toast {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%) translateY(8px);
  background: rgba(16,10,24,.94); border: 1px solid rgba(255,216,138,.42);
  color: #f6ecd8; font-size: 13px; padding: 8px 16px; border-radius: 20px;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; z-index: 9;
  max-width: 88%; text-align: center;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- article ---------- */
.about, .faq {
  max-width: 860px; margin: 0 auto; padding: 26px 20px 8px;
  color: #b3a8c4;
}
.about h1 { font-family: Georgia, serif; font-size: 25px; color: #f6ecd8; margin-bottom: 12px; line-height: 1.35; }
.about h2, .faq h2 { font-family: Georgia, serif; font-size: 20px; color: #f0e2c8; margin: 22px 0 8px; }
.about p, .faq p { font-size: 14.5px; margin: 8px 0; }
.about ol, .about ul { padding-left: 22px; font-size: 14.5px; }
.about li { margin: 5px 0; }
.about table {
  width: 100%; border-collapse: collapse; margin: 10px 0 6px;
  font-size: 13.5px; table-layout: fixed;
}
.about th, .about td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid rgba(201,150,79,.16);
  overflow-wrap: break-word;
}
.about th { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: #c9964f; }
.about code { font: 12.5px monospace; background: rgba(201,150,79,.12); padding: 2px 6px; border-radius: 5px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tags span {
  font-size: 11.5px; letter-spacing: .06em; padding: 5px 12px; border-radius: 14px;
  border: 1px solid rgba(201,150,79,.28); color: #d3b184;
}
.faq h3 { font-size: 15px; color: #f0e2c8; margin: 14px 0 4px; font-family: Georgia, serif; }
.foot { text-align: center; color: #6f6588; font-size: 12.5px; padding: 26px 18px 34px; }

/* ---------- responsive ---------- */
@media (max-width: 940px) {
  #stage-wrap { height: min(74vh, 700px); min-height: 420px; }
  #app { padding: 6px 10px 0; }
  .ch-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .scr-inner { padding: 20px 16px; }
}
@media (max-width: 620px) {
  .wordmark { font-size: 19px; }
  #stage-wrap { height: 72vh; min-height: 380px; border-radius: 12px; }
  .ch-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
  .ch-btn .ch-n { font-size: 14px; }
  .hud-time { font-size: 13px; min-width: 40px; }
  .hud button { padding: 5px 8px; font-size: 12px; }
  .about table { font-size: 12.5px; }
}
@media (max-width: 420px) {
  .ch-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .scr-inner { padding: 16px 12px; }
}
