:root {
  color-scheme: light;
  --ink: #222f3b;
  --muted: #56636b;
  --teal: #087971;
  --coral: #cc593f;
  --paper: #fffaf0;
  --edge: #c8c7b9;
  --shadow: 4px 5px 0 #273743;
  font-family: "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #f4f0e4;
}
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background-image: linear-gradient(#5165540c 1px, transparent 1px),linear-gradient(90deg,#5165540c 1px,transparent 1px);
  background-size: 26px 26px;
}
button,input { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: default; opacity: .48; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #0969ae; outline-offset: 3px; }
[hidden] { display: none !important; }
.shell { max-width: 1104px; margin: auto; padding: 0 36px 28px; }
.topbar { min-height: 84px; border-bottom: 1px solid var(--edge); display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font-weight: 760; text-decoration: none; color: inherit; letter-spacing: -.035em; background: none; border: 0; padding: 0; }
.brand-mark { display: inline-flex; gap: 3px; align-items: center; padding: 8px; border: 1.5px solid var(--ink); border-radius: 9px; background: var(--paper); box-shadow: 2px 2px var(--ink); }
.brand-mark span { width: 13px; height: 13px; }
main { min-width: 0; }
h1,h2,h3,p { margin-top: 0; }
h1,h2,h3 { text-wrap: balance; }
h2,h3 { letter-spacing: -.045em; line-height: 1.12; }
p { line-height: 1.55; }
.welcome { display: grid; grid-template-columns: 1.12fr .88fr; align-items: center; gap: 32px; padding: clamp(42px,6vw,86px) 0; }
.eyebrow,.step-count,.orbit-label,.counter,.symbol-label { font-family: Consolas,"Courier New",monospace; font-weight: 700; text-transform: uppercase; font-size: .76rem; letter-spacing: .105em; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--teal); margin-bottom: 16px; }
.eyebrow::before { content: ""; width: 23px; height: 2px; background: currentColor; }
.hero-title,.settings-intro h1 { font: 700 clamp(3.8rem,7.7vw,6.5rem)/.95 Georgia,"Times New Roman",serif; letter-spacing: -.075em; margin: 0 0 23px; }
.hero-title span { display: inline-block; }
.hero-title .and-word { font-style: italic; font-size: .59em; font-weight: normal; }
.subtitle,.settings-intro p { color: var(--muted); font-size: clamp(1rem,1.6vw,1.15rem); max-width: 40ch; margin-bottom: 0; }
.hero-art { position: relative; display: grid; place-items: center; min-height: 260px; isolation: isolate; }
.mini-board { width: clamp(194px,19vw,246px); aspect-ratio: 1; display: grid; grid-template-columns: repeat(6,1fr); grid-template-rows: repeat(6,1fr); transform: rotate(8deg); border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--ink); gap: 1px; box-shadow: 6px 7px var(--ink); }
.mini-cell { display: grid; place-items: center; background: var(--paper); }
.orbit-label { position: absolute; padding: 5px 9px; border: 1.5px solid var(--ink); border-radius: 4px; background: #cde8d9; box-shadow: 2px 2px var(--ink); z-index: 1; }
.order-label { left: 7%; top: 13%; transform: rotate(-8deg); }
.chaos-label { right: 6%; bottom: 9%; transform: rotate(-6deg); background: #ffcfaf; }
.mark,.brand-mark span { position: relative; display: inline-block; flex: none; font-size: 0; }
.mark { width: 55%; aspect-ratio: 1; }
.mark.x::before,.mark.x::after,.brand-mark .x::before,.brand-mark .x::after { content: ""; position: absolute; left: 42%; top: -4%; width: 16%; height: 108%; background: var(--teal); transform: rotate(45deg); border-radius: 8px; }
.mark.x::after,.brand-mark .x::after { transform: rotate(-45deg); }
.mark.o,.brand-mark .o { background: var(--coral); border-radius: 50%; mask: radial-gradient(circle closest-side,transparent 66%,#000 69%); }
.choice-panel,.settings-card,.info-card,.result-card,.tutorial-card,.share-panel { background: var(--paper); border: 1.5px solid var(--ink); border-radius: 20px; box-shadow: var(--shadow); padding: clamp(20px,3vw,34px); }
.choice-panel h2 { margin-bottom: 20px; font-size: clamp(1.5rem,3vw,2rem); }
.choice-grid,.role-cards,.rule-options,.segmented { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; }
.choice-card { display: flex; align-items: center; gap: 14px; text-align: left; padding: 22px; border: 1.5px solid var(--ink); border-radius: 13px; background: #d7e9dd; }
.friend-choice { background: #f6d6bf; }
.choice-title { font-size: 1.08rem; font-weight: 750; }
.choice-arrow { margin-left: auto; font-size: 1.35rem; }
.choice-icon svg { width: 27px; height: 27px; display: block; }
.text-btn,.tutorial-link,.back-btn { background: transparent; border: 0; padding: 8px 0; font-weight: 650; text-decoration: underline; text-underline-offset: 4px; }
.tutorial-link { margin-top: 14px; }
.footer-note { color: var(--muted); font: .76rem/1.5 Consolas,monospace; margin: 28px 0 0; }
.menu-btn,.primary,.secondary,.undo-btn,.tutorial-actions button,.share-actions button { border: 1.5px solid var(--ink); border-radius: 9px; background: var(--paper); padding: 10px 16px; min-height: 42px; font-weight: 700; }
.primary,.tutorial-actions .primary,.share-actions .primary { background: var(--ink); color: var(--paper); }
.settings-layout,.game-layout { padding: clamp(26px,5vw,56px) 0; display: grid; gap: clamp(22px,5vw,60px); align-items: start; grid-template-columns: .82fr 1.18fr; }
.settings-intro h1 { font-size: clamp(2.6rem,5vw,4.4rem); }
.field-group { margin: 0 0 24px; border: 0; padding: 0; min-width: 0; }
.field-group legend { margin-bottom: 9px; font-weight: 740; }
.segmented { grid-template-columns: repeat(auto-fit,minmax(82px,1fr)); gap: 6px; }
.option,.rule-option,.symbol-btn { background: #f4f0e4; border: 1px solid var(--edge); border-radius: 8px; padding: 10px; font-weight: 650; }
.option[aria-pressed=true],.rule-option[aria-pressed=true],.symbol-btn[aria-pressed=true] { box-shadow: inset 0 0 0 1px var(--ink); border-color: var(--ink); background: #d7e9dd; }
.field-hint { color: var(--muted); font-size: .9rem; margin: 8px 0 0; }
.game-layout { grid-template-columns: minmax(288px,480px) minmax(220px,1fr); }
.game-main,.game-aside { min-width: 0; }
.game-aside { display: grid; gap: 18px; }
.role-cards { gap: 9px; }
.role-card { padding: 12px; border: 1px solid var(--edge); border-radius: 12px; background: var(--paper); }
.role-card.active { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: #e2eee1; }
.role-person,.role-goal { display: block; }
.role-person { font-weight: 750; }
.role-goal { color: var(--muted); font-size: .83rem; }
.role-token,.rule-badge { display: inline-flex; border-radius: 5px; background: #eadfc8; padding: 3px 7px; font-weight: 700; font-size: .8rem; }
.board-toolbar,.symbol-controls,.game-actions,.tutorial-actions,.share-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.board-toolbar { justify-content: space-between; margin: 17px 0 10px; }
.turn-label { font-weight: 740; }
.turn-dot { display: inline-block; width: 9px; height: 9px; background: var(--teal); border-radius: 50%; }
.counter { color: var(--muted); }
.symbol-controls { margin: 10px 0; }
.symbol-btn { display: inline-flex; min-width: 48px; min-height: 42px; align-items: center; justify-content: center; gap: 8px; }
.symbol-btn .mark { width: 18px; }
.symbol-btn.o[aria-pressed=true] { background: #f6d6bf; }
.board-wrap { position: relative; width: 100%; max-width: 480px; }
.board { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); grid-template-rows: repeat(6,minmax(0,1fr)); aspect-ratio: 1; outline: 2px solid var(--ink); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; background: var(--paper); }
.cell { min-width: 0; min-height: 0; padding: 0; display: grid; place-items: center; position: relative; background: var(--paper); border: 0; border-radius: 0; box-shadow: inset -1px -1px #b9bbad; }
.cell:nth-child(6n) { box-shadow: inset 0 -1px #b9bbad; }
.cell:disabled { opacity: 1; }
.cell.last-move { background: #e7e9d5; }
.cell.hint,.cell.target { background: #f8dfa2; }
.cell.focus-line { background: #dceadc; }
.cell:focus-visible { z-index: 1; outline-offset: -4px; }
.cell .preview { opacity: 0; }
.cell.playable:is(:hover,:focus-visible,.press-preview) .preview { opacity: .35; }
.cell .preview:not(.mark) { position: absolute; inset: 0; display: grid; place-items: center; }
.win-overlay { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.win-overlay line { stroke: var(--ink); stroke-width: 1.3%; stroke-linecap: round; opacity: .8; }
.game-actions { margin-top: 18px; }
.info-card,.result-card,.tutorial-card,.share-panel { padding: 22px; }
.info-card p:last-child,.result-card p:last-child,.tutorial-card p:last-child { margin-bottom: 0; }
.result-card { background: #d9eadc; }
.tutorial-card { background: #faf0d4; }
.status-banner { padding: 10px 14px; margin: 12px 0; border-radius: 8px; background: #e2eadf; }
.share-panel input { width: 100%; border: 1px solid var(--edge); border-radius: 7px; padding: 10px; margin-bottom: 10px; }
.spinner { display: inline-block; width: 1em; height: 1em; border: 2px solid #9ba99b; border-top-color: var(--teal); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.toast { position: fixed; z-index: 8; bottom: 18px; left: 50%; transform: translateX(-50%); max-width: calc(100% - 24px); padding: 10px 18px; background: var(--ink); color: white; border-radius: 8px; }
@media (hover:hover) {
  .choice-card:hover,.primary:hover,.secondary:hover,.menu-btn:hover,.undo-btn:hover { transform: translateY(-2px); box-shadow: 2px 3px var(--ink); }
}
@media (max-width: 720px) {
  .shell { padding-inline: 20px; }
  .topbar { min-height: 66px; }
  .welcome { gap: 12px; grid-template-columns: 1.2fr .8fr; }
  .hero-art { min-height: 184px; }
  .mini-board { width: 150px; }
  .orbit-label { font-size: .58rem; }
  .settings-layout,.game-layout { grid-template-columns: 1fr; }
  .game-main,.game-aside { width: 100%; max-width: 480px; margin-inline: auto; }
  .choice-card { padding: 14px; gap: 8px; }
}
@media (max-width: 490px) {
  .shell { padding-inline: 12px; }
  .welcome { padding-block: 28px; grid-template-columns: 1fr; gap: 10px; }
  .hero-title { font-size: clamp(3.25rem,13vw,4.1rem); margin-bottom: 12px; }
  .hero-art { min-height: 140px; }
  .mini-board { width: 116px; border-radius: 6px; box-shadow: 3px 4px var(--ink); }
  .order-label { left: calc(50% - 96px); }
  .chaos-label { right: calc(50% - 98px); }
  .choice-grid { grid-template-columns: 1fr; gap: 9px; }
  .choice-panel,.settings-card { padding: 18px; }
  .choice-panel h2 { margin-bottom: 12px; }
  .rule-options { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  *,*::before,*::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
@media (max-width: 360px) {
  .shell { padding-inline: 8px; }
}
.symbol-btn { min-height: 48px; min-width: 68px; }

.hero-title .and-word { margin-inline: .16em .2em; }
.choice-icon { display: grid; place-items: center; flex: none; }
.choice-icon svg { stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.choice-title,.choice-description { display: block; }
.choice-description { margin-top: 3px; font-size: .87rem; line-height: 1.4; color: #394a51; }
.full-width { width: 100%; }
.settings-symbols { display: flex; gap: 13px; margin: 28px 0 0; }
.settings-symbols .mark { width: 36px; }
.role-card { display: flex; position: relative; align-items: center; gap: 9px; padding: 12px 16px 12px 10px; }
.role-card p { margin: 0; line-height: 1.35; }
.role-card .role-token { display: grid; place-items: center; flex: none; width: 27px; height: 27px; font-size: 1rem; background: #c8e2d2; }
.role-token.chaos { background: #f4d1bb; }
.role-card .turn-dot { position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; }
.turn-label { margin: 0; display: flex; gap: 7px; align-items: center; }
.board-row { display: contents; }
.grid-cell { min-width: 0; min-height: 0; }
.grid-cell .cell { width: 100%; height: 100%; }
.grid-cell:last-child .cell { box-shadow: inset 0 -1px #b9bbad; }
.cell.last-move .mark { animation: place-mark .2s ease-out both; }
@keyframes place-mark { from { transform: scale(.7); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.cell.target.playable { background: #ffdf85; outline: 3px solid #98620e; outline-offset: -4px; box-shadow: inset 0 0 14px #efa71f88; }
.cell.target.playable:focus-visible { outline-color: #0969ae; }
.keyboard-tip { font-size: .8rem; color: var(--muted); }
.info-card .eyebrow { display: flex; }
.info-card .rule-badge { margin-bottom: 12px; }
.info-card h2,.result-card h2 { margin-bottom: 12px; }
.info-divider { border-top: 1px solid var(--edge); margin: 15px 0; }
.result-card .full-width + .full-width { margin-top: 9px; }
.result-symbol { display: block; color: var(--teal); font-size: 2rem; }
@media (max-width: 490px) {
  .settings-symbols { display: none; }
  .role-card { gap: 5px; padding: 10px 9px 10px 6px; }
  .role-card .role-token { width: 21px; height: 24px; }
  .role-person { font-size: .88rem; }
  .role-goal { font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) { .cell.last-move .mark { animation: none; } }
