:root {
  --bg: #f5f1ea;
  --card: #fffdf9;
  --ink: #241f3a;
  --muted: #6d6780;
  --line: #e4ddd1;
  --accent: #6c4fe0;
  --accent-ink: #fff;
  --ghost: #8a6cf5;
  --rare: #3d8fe0;
  --uncommon: #3fae6b;
  --common: #e2b33c;
  --obvious: #cfc8bc;
  --miss: #d9534f;
  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --display: "Georgia", "Iowan Old Style", "Palatino Linotype", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--font); min-height: 100vh; display: flex; flex-direction: column; }
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.site-head { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg); position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font: 700 1.3rem/1 var(--display); letter-spacing: .01em; }
.logo { width: 32px; height: 32px; }
.site-nav { display: none; gap: 4px; margin-left: 12px; }
.site-nav a, .menu-list a { color: var(--ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.site-nav a:hover, .menu-list a:hover { background: #ebe5da; }
.site-nav a[aria-current], .menu-list a[aria-current] { background: var(--ink); color: #fff; }
.head-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn, .site-menu summary { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; list-style: none; cursor: pointer; }
.site-menu summary::-webkit-details-marker { display: none; }
.icon-btn svg, .site-menu svg { width: 20px; height: 20px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; }
.site-menu { position: relative; }
.menu-list { position: absolute; right: 0; top: 46px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; min-width: 180px; box-shadow: 0 10px 30px rgba(36, 31, 58, .14); }
@media (min-width: 860px) {
  .site-nav { display: flex; }
  .site-menu .menu-list a:nth-child(-n+4) { display: none; }
}

.site-main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 14px 40px; }

/* game */
.hero { text-align: center; margin: 4px 0 12px; }
.hero h1 { font: 600 1rem/1.3 var(--font); color: var(--muted); margin: 0; }
#game { min-height: 520px; }
.g-card, .g-result { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; box-shadow: 0 2px 0 rgba(36, 31, 58, .04); }
.g-meta { margin: 0 0 6px; color: var(--muted); font-size: .9rem; text-align: center; }
.tag { display: inline-block; background: var(--ink); color: #fff; border-radius: 6px; padding: 0 7px; font-size: .78rem; font-weight: 600; vertical-align: 1px; }
.g-q { font: 700 1.65rem/1.2 var(--display); text-align: center; margin: 4px 0 12px; overflow-wrap: anywhere; }
.g-score { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 0 12px; }
.g-score strong { font: 700 2.6rem/1 var(--display); font-variant-numeric: tabular-nums; }
.g-score span { color: var(--muted); font-size: .8rem; line-height: 1.2; }
.slots { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 6px; }
.slot { display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #faf7f1; min-height: 48px; }
.slot-no { width: 24px; height: 24px; border-radius: 50%; background: #ebe5da; color: var(--muted); display: grid; place-items: center; font-size: .78rem; font-weight: 700; }
.slot-text { font-weight: 600; overflow-wrap: anywhere; min-width: 0; }
.slot-text small { display: block; font-weight: 500; color: var(--muted); font-size: .75rem; }
.slot .pts { font: 700 1.15rem/1 var(--display); min-width: 42px; text-align: center; padding: 6px 4px; border-radius: 8px; background: #ebe5da; font-variant-numeric: tabular-nums; }
.slot.empty .slot-text, .slot.empty .pts { color: #b3ab9d; font-weight: 500; }
.slot.miss { border-color: #f1c3c1; background: #fdf1f0; }
.slot.miss .pts { background: var(--miss); color: #fff; }
.slot.miss s { color: var(--miss); }
.b-ghost .pts, .ans-all .b-ghost b { background: var(--ghost); color: #fff; }
.b-rare .pts, .ans-all .b-rare b { background: var(--rare); color: #fff; }
.b-uncommon .pts, .ans-all .b-uncommon b { background: var(--uncommon); color: #fff; }
.b-common .pts, .ans-all .b-common b { background: var(--common); color: var(--ink); }
.b-obvious .pts, .ans-all .b-obvious b { background: var(--obvious); color: var(--ink); }
.slot.b-ghost { border-color: #cfc1ff; background: #f4f0ff; }
.g-form { display: flex; gap: 8px; }
.g-form input { flex: 1; min-width: 0; font: inherit; font-size: 1.05rem; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--ink); background: #fff; color: var(--ink); }
.g-form input:focus { outline: 3px solid #cbbdfd; outline-offset: 1px; }
.g-form button, .btn { border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 12px 18px; border-radius: 12px; text-decoration: none; display: inline-block; }
.g-form button:hover, .btn:hover { filter: brightness(1.08); }
.g-msg { min-height: 1.6em; margin: 10px 2px 4px; font-size: .95rem; }
.g-msg.good { color: #5a3fd0; font-weight: 600; }
.g-msg.bad { color: var(--miss); }
.g-msg.warn { color: #9a6a00; }
.g-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.ghost-btn { background: transparent; border: 1.5px solid var(--ink); color: var(--ink); border-radius: 10px; padding: 7px 12px; font-weight: 600; }
.ghost-btn:disabled { opacity: .4; cursor: default; }
.btn.ghost-btn { padding: 11px 16px; }
.hints { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 6px; }
.hints li { border: 1px dashed var(--ghost); border-radius: 10px; padding: 8px 10px; background: #f7f4ff; }
.hints li.used { opacity: .6; }
.hint-pat { font: 700 1.05rem/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; white-space: pre-wrap; overflow-wrap: anywhere; }
.hints small { display: block; color: var(--muted); }
.g-back { text-align: center; }

.g-result { margin-top: 14px; text-align: center; }
.grade-name { font: 700 2rem/1.1 var(--display); margin: 4px 0; color: var(--accent); }
.grade-line { margin: 0 0 6px; color: var(--muted); }
.grade-total { margin: 0; font-size: 1.1rem; }
.grade-total b { font: 700 1.6rem var(--display); }
.emoji-row { font-size: 1.7rem; letter-spacing: 4px; margin: 8px 0; }
.result-btns { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 10px; }
.countdown { margin: 0; color: var(--muted); }
.countdown b { color: var(--ink); font-variant-numeric: tabular-nums; }
.share-note { min-height: 1.2em; color: var(--muted); margin: 6px 0; }
.share-note textarea { width: 100%; font: inherit; }
.mini-stats { color: var(--muted); font-size: .9rem; margin: 2px 0 10px; }
.fact { background: #f4f0ff; border-radius: 10px; padding: 10px 12px; text-align: left; font-size: .95rem; }
.cols { display: grid; gap: 14px; text-align: left; margin-top: 10px; }
.cols h3 { font-size: .95rem; margin: 0 0 6px; }
.ans-mini { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.ans-mini li, .ans-all li { display: flex; justify-content: space-between; gap: 8px; padding: 5px 9px; background: #faf7f1; border-radius: 8px; }
.ans-mini b { font-variant-numeric: tabular-nums; }
.all-answers { margin-top: 14px; text-align: left; }
.all-answers summary { cursor: pointer; font-weight: 600; color: var(--accent); padding: 6px 0; }
.ans-all { list-style: none; padding: 0; margin: 8px 0 0; display: grid; grid-template-columns: 1fr; gap: 4px; }
.ans-all li { align-items: center; }
.ans-all li span { overflow-wrap: anywhere; min-width: 0; }
.ans-all li b { min-width: 34px; text-align: center; border-radius: 6px; padding: 1px 4px; font-variant-numeric: tabular-nums; }
.ans-all li.mine { outline: 2px solid var(--ink); }
@media (min-width: 560px) {
  .cols { grid-template-columns: 1fr 1fr; }
  .ans-all { grid-template-columns: 1fr 1fr; }
  .g-card, .g-result { padding: 24px 26px; }
  .g-q { font-size: 2rem; }
}
.new-day { background: var(--ink); color: #fff; border-radius: 12px; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 10px; }

/* dialogs */
dialog { border: 0; border-radius: 18px; padding: 0; max-width: min(440px, calc(100vw - 24px)); width: 100%; color: var(--ink); background: var(--card); box-shadow: 0 20px 60px rgba(36, 31, 58, .3); }
dialog::backdrop { background: rgba(36, 31, 58, .45); }
.dlg-in { padding: 20px 20px 18px; position: relative; }
.dlg-in h2 { font: 700 1.4rem var(--display); margin: 0 34px 10px 0; }
.dlg-x { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 50%; border: 0; background: #ebe5da; font-size: 1.2rem; line-height: 1; }
.step p { margin: 0 0 10px; }
.step .demo { list-style: none; padding: 0; margin: 10px 0; display: grid; gap: 5px; }
.demo li { display: flex; justify-content: space-between; padding: 6px 10px; border-radius: 8px; background: #faf7f1; }
.demo li b { min-width: 34px; text-align: center; border-radius: 6px; }
.demo .b-obvious b { background: var(--obvious); } .demo .b-common b { background: var(--common); }
.demo .b-rare b { background: var(--rare); color: #fff; } .demo .b-ghost b { background: var(--ghost); color: #fff; }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }
.dots { display: flex; gap: 6px; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--accent); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; text-align: center; }
.stat-grid div { background: #faf7f1; border-radius: 10px; padding: 8px 4px; }
.stat-grid b { display: block; font: 700 1.5rem var(--display); }
.stat-grid span { font-size: .78rem; color: var(--muted); }
.grade-bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.grade-bars li { display: grid; grid-template-columns: 110px 1fr 28px; align-items: center; gap: 8px; font-size: .88rem; }
.grade-bars i { height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--accent) var(--w), #ebe5da var(--w)); }
.muted { color: var(--muted); font-size: .88rem; }

/* text pages */
.doc-text, .home-text { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; margin-top: 18px; }
.doc-text h1 { font: 700 1.9rem/1.2 var(--display); margin: 0 0 10px; }
.doc-text h2, .home-text h2 { font: 700 1.35rem/1.25 var(--display); margin: 26px 0 8px; }
.home-text h2:first-child { margin-top: 0; }
.doc-text h3, .home-text h3 { margin: 18px 0 4px; font-size: 1.05rem; }
.lede { font-size: 1.1rem; color: var(--muted); }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0 0 6px; }
.crumbs a { color: var(--muted); }
.band-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: .95rem; }
.band-table th, .band-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.faq details { border-bottom: 1px solid var(--line); padding: 8px 0; }
.faq summary { font-weight: 600; cursor: pointer; }
.faq p { margin: 6px 0 4px; }
.months { list-style: none; padding: 0; display: grid; gap: 6px; }
.day-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.day-list a { display: flex; justify-content: space-between; gap: 10px; padding: 10px 12px; background: #faf7f1; border-radius: 10px; color: var(--ink); text-decoration: none; }
.day-list a:hover { background: #ebe5da; }
.day-list small { color: var(--muted); white-space: nowrap; }
.play-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0; }
.band-group h3 { display: flex; align-items: center; gap: 8px; }
.band-group .ans-all li b { min-width: 34px; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* contact form (markup shared with the feedback relay script) */
form[data-feedback-form] { display: grid; gap: 12px; margin-top: 14px; }
.fb-row { display: grid; gap: 12px; }
@media (min-width: 560px) { .fb-row { grid-template-columns: 1fr 1fr; } }
.fb-field { display: grid; gap: 4px; }
.fb-field label { font-weight: 600; font-size: .92rem; }
.fb-field input, .fb-field textarea { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; color: var(--ink); width: 100%; }
.fb-field textarea { min-height: 150px; resize: vertical; }
.fb-hint { color: var(--muted); font-weight: 400; }
form[data-feedback-form] button[type="submit"] { justify-self: start; border: 0; background: var(--accent); color: #fff; font-weight: 700; padding: 12px 22px; border-radius: 12px; }

.site-foot { border-top: 1px solid var(--line); padding: 18px 16px 26px; text-align: center; color: var(--muted); font-size: .88rem; }
.foot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; margin-bottom: 8px; }
.foot-links a { color: var(--ink); }
.site-foot p { margin: 4px auto; max-width: 620px; }
