:root {
  color-scheme: dark;
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background: #090d13;
  color: #f2efe9;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; min-width: 320px; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible { outline: 3px solid #86ecde; outline-offset: 4px; }
button:disabled { cursor: not-allowed; }
[hidden] { display: none !important; }

.app-shell { position: relative; isolation: isolate; min-height: 100svh; overflow: clip; padding: 0 3.1vw; background: radial-gradient(ellipse 72% 85% at 45% 52%, #17242a 0%, #0b131a 46%, #080c12 100%); }
.app-shell::before { content: ""; position: absolute; inset: 0; z-index: -2; opacity: .16; background-image: linear-gradient(#acc9b90a 1px, transparent 1px), linear-gradient(90deg, #acc9b90a 1px, transparent 1px); background-size: 64px 64px; mask-image: radial-gradient(ellipse at center, #000, transparent 80%); pointer-events: none; }
.ambient { position: absolute; z-index: -1; width: 45vw; height: 45vw; border-radius: 50%; filter: blur(90px); opacity: .12; pointer-events: none; }
.ambient-one { top: -29vw; left: 6vw; background: #b9a16b; }
.ambient-two { bottom: -30vw; right: 18vw; background: #3b9f9a; }

.topbar { max-width: 1770px; min-height: 83px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid #c6d4c71d; }
.brand { display: inline-flex; align-items: center; gap: 15px; color: inherit; text-decoration: none; }
.brand-symbol { display: grid; place-items: center; width: 35px; height: 35px; border: 1px solid #d5c49a; border-radius: 50%; transform: rotate(-32deg); box-shadow: 0 0 22px #ceb37d24; }
.brand-symbol span { display: block; width: 19px; height: 19px; border-radius: 50%; background: linear-gradient(90deg, #e9e4d8 0 50%, #1a2529 50% 100%); box-shadow: inset 0 0 0 1px #d1c2a5; }
.brand-type { display: flex; flex-direction: column; letter-spacing: .14em; font-size: 20px; font-weight: 600; line-height: 1.05; white-space: nowrap; }
.brand-type strong { font-weight: normal; color: #d8c394; }
.brand-type small { margin-top: 5px; color: #8f9c9e; font-size: 8px; font-weight: 400; letter-spacing: .19em; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.sound-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 7px 12px; border: 1px solid #b9c9c353; background: #ffffff0a; color: #d9e5df; font-size: 16px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: border-color .2s, background .2s, color .2s; }
.sound-toggle:hover { border-color: #d6c796b5; color: #fff; }
.sound-toggle[aria-pressed="true"] { border-color: #d6c796b5; background: #d4bc8521; color: #f0dfb6; }
.sound-toggle-icon { position: relative; display: inline-block; font-size: 22px; font-weight: 400; line-height: 1; }
.sound-toggle[aria-pressed="false"] .sound-toggle-icon::after { content: ""; position: absolute; top: 11px; left: 0; width: 20px; height: 2px; background: #d9e5df; box-shadow: 0 0 0 1px #111a20; transform: rotate(-42deg); }
.text-button { border: none; background: none; color: #eeeae0; cursor: pointer; }
.help-open { font-size: 18px; padding: 12px 0 12px 16px; }
.help-open span { margin-left: 14px; color: #ceb989; }
.help-open:hover, .view-toggle:hover, .result-close:hover { color: #87e3d8; }

.layout { max-width: 1770px; margin: 25px auto 12px; display: grid; grid-template-columns: minmax(0, 1fr) 315px; gap: 20px; align-items: stretch; }
.stage-panel, .control-panel { position: relative; border: 1px solid #c6d4c721; background: linear-gradient(145deg, #ffffff05, #ffffff00 40%, #ffffff03); box-shadow: inset 0 1px #ffffff08, 0 25px 70px #0000001c; }
.stage-panel { min-width: 0; padding: 31px 35px 23px; overflow: hidden; }
.stage-panel::before { content: ""; position: absolute; top: -1px; left: 35px; width: 126px; height: 1px; background: #d5c28f; box-shadow: 0 0 20px #d5c28f9a; }
.stage-heading { display: flex; justify-content: space-between; align-items: end; gap: 18px; }
.eyebrow { margin: 0 0 14px; color: #c9b789; font-size: 11px; line-height: 1.2; letter-spacing: .31em; }
.stage-heading h1 { margin: 0; font-size: clamp(29px, 2.9vw, 48px); font-weight: 600; letter-spacing: .075em; line-height: 1.3; text-shadow: 0 0 25px #d9e6e11a; }
.glitch-title { text-shadow: -1px 0 #61d8e85c, 1px 0 #e27b9a45, 0 0 25px #d9e6e11a; }
.glitch-title > .glitch-line { position: relative; display: inline-block; white-space: nowrap; animation: glitch-main 6.4s steps(1, end) infinite; }
.glitch-title > .glitch-line:nth-child(2) { animation-delay: -3.2s; }
.glitch-layer { position: absolute; inset: 0; display: block; opacity: 0; pointer-events: none; user-select: none; white-space: nowrap; }
.glitch-layer-cyan { color: #7de0e7; text-shadow: -2px 0 #77e9e7; animation: glitch-cyan 6.4s steps(1, end) infinite; }
.glitch-layer-pink { color: #dd85ad; text-shadow: 2px 0 #e481ab; animation: glitch-pink 6.4s steps(1, end) infinite; }
.glitch-line:nth-child(2) .glitch-layer { animation-delay: -3.2s; }
@keyframes glitch-main {
  0%, 7.5%, 13%, 48.5%, 54%, 100% { transform: translate(0, 0); }
  8%, 50% { transform: translate(-2px, 0); }
  9.5%, 51.5% { transform: translate(2px, 0); }
  11%, 53% { transform: translate(-1px, 0); }
}
@keyframes glitch-cyan {
  0%, 7.5%, 13%, 48.5%, 54%, 100% { opacity: 0; transform: translate(0, 0); clip-path: inset(0); }
  8%, 50% { opacity: .9; transform: translate(-5px, -1px); clip-path: inset(10% 0 67% 0); }
  9.5%, 51.5% { opacity: .75; transform: translate(4px, 1px); clip-path: inset(54% 0 26% 0); }
  11%, 53% { opacity: .65; transform: translate(-3px, 0); clip-path: inset(29% 0 51% 0); }
}
@keyframes glitch-pink {
  0%, 7.5%, 13%, 48.5%, 54%, 100% { opacity: 0; transform: translate(0, 0); clip-path: inset(0); }
  8%, 50% { opacity: .75; transform: translate(4px, 1px); clip-path: inset(43% 0 39% 0); }
  9.5%, 51.5% { opacity: .85; transform: translate(-4px, -1px); clip-path: inset(73% 0 8% 0); }
  11%, 53% { opacity: .6; transform: translate(2px, 0); clip-path: inset(8% 0 75% 0); }
}
.stage-index { display: flex; align-items: center; gap: 12px; padding-bottom: 6px; color: #95a6a7; font-size: 11px; letter-spacing: .15em; }
.stage-index span:first-child { color: #d1bd90; font-size: 23px; }
.stage-index-line { width: 48px; height: 1px; background: #a7b6ae68; }

.board-wrap { position: relative; height: clamp(400px, calc(100svh - 180px), 690px); min-width: 0; margin: 0 -18px; }
.board-halo { position: absolute; top: 17%; left: 15%; width: 70%; height: 68%; border-radius: 50%; background: #8be0ce0d; filter: blur(55px); pointer-events: none; }
#board-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: manipulation; cursor: crosshair; }
.board-caption { position: absolute; bottom: 17px; left: 20px; font-size: 10px; letter-spacing: .24em; color: #b8c3bf59; pointer-events: none; }
.corner-mark { position: absolute; width: 14px; height: 14px; border-color: #d3c09354; pointer-events: none; }
.corner-mark-tl { top: 20px; left: 19px; border-top: 1px solid; border-left: 1px solid; }
.corner-mark-tr { top: 20px; right: 19px; border-top: 1px solid; border-right: 1px solid; }
.corner-mark-bl { bottom: 20px; left: 19px; border-bottom: 1px solid; border-left: 1px solid; }
.corner-mark-br { bottom: 20px; right: 19px; border-bottom: 1px solid; border-right: 1px solid; }
.stage-foot { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 39px; }
.stage-instruction { display: inline-flex; align-items: center; gap: 12px; font-size: 17px; color: #b6c7c6; }
.instruction-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #76decf; box-shadow: 0 0 15px #76decf; }
.view-toggle { border: 0; border-bottom: 1px solid #aab9b57e; border-radius: 0; padding: 7px 0; background: transparent; color: #d6ded8; font-size: 16px; white-space: nowrap; cursor: pointer; }

.control-panel { display: flex; flex-direction: column; padding: 27px 24px 20px; }
.panel-head { display: flex; align-items: start; justify-content: space-between; gap: 8px; }
.panel-head .eyebrow { margin-bottom: 9px; }
.panel-head h2 { margin: 0; font-weight: 600; font-size: 29px; letter-spacing: .08em; }
.match-indicator { display: inline-flex; align-items: center; gap: 7px; margin-top: 4px; color: #a9c4bb; font-size: 16px; white-space: nowrap; }
.match-indicator span:first-child { width: 6px; height: 6px; border-radius: 50%; background: #91e1c3; box-shadow: 0 0 11px #91e1c3; }
.turn-card { min-height: 146px; margin-top: 32px; padding: 18px 17px; border: 1px solid #d8bd8254; background: radial-gradient(circle at 10% 0%, #d4bd8120, transparent 62%), linear-gradient(145deg, #c8b47b0e, #ffffff02); box-shadow: inset 0 1px #ffffff12; }
.turn-kicker { color: #d2c08e; font-size: 16px; letter-spacing: .2em; }
.turn-main { display: flex; align-items: center; gap: 13px; margin-top: 15px; font-size: 22px; font-weight: 600; letter-spacing: .03em; }
.turn-disc, .score-disc { display: inline-block; flex: none; border-radius: 50%; }
.turn-disc { width: 25px; height: 25px; border: 2px solid #bbab8e; box-shadow: 0 5px 9px #0008, inset 0 2px 3px #ffffff30; }
.turn-disc.black, .score-disc.black { background: radial-gradient(circle at 30% 24%, #48545a, #111920 60%, #070d11 100%); }
.turn-disc.white, .score-disc.white { background: radial-gradient(circle at 30% 22%, white, #eee7d8 57%, #c7c2b4 100%); }
.turn-card p { margin: 12px 0 0; color: #bbcac6; font-size: 16px; line-height: 1.5; }
.score-head, .mode-head { display: flex; align-items: baseline; justify-content: space-between; margin-top: 27px; }
.score-head h3, .mode-head h3 { margin: 0; font-size: 18px; font-weight: 500; letter-spacing: .05em; }
.score-head > span { color: #7d9696; font-size: 10px; letter-spacing: .12em; }
.scoreboard { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 13px; }
.score-card { display: grid; grid-template-columns: 1fr auto; gap: 4px; min-width: 0; min-height: 102px; padding: 12px 11px 10px; border: 1px solid #c6d4c72b; background: #ffffff06; transition: border-color .2s, background .2s; }
.score-card.active { border-color: #d3bf8d99; background: #d3bf8d0d; }
.score-name { display: inline-flex; align-items: center; align-self: start; gap: 7px; font-size: 16px; }
.score-disc { width: 16px; height: 16px; border: 1px solid #b9aa92; }
.score-card strong { align-self: center; grid-column: 2; grid-row: 1 / 3; font-size: 37px; line-height: 1.2; font-weight: 600; color: #f3f0e9; font-variant-numeric: tabular-nums; }
.score-player { grid-column: 1 / -1; align-self: end; color: #9eb2b0; font-size: 16px; }
.control-divider { height: 1px; margin-top: 28px; background: linear-gradient(90deg, #b6c7c650, transparent); }
.mode-head { margin-top: 23px; }
.mode-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-top: 13px; padding: 4px; border: 1px solid #c6d4c72c; background: #00000029; }
.mode-button { min-height: 48px; padding: 8px 5px; border: 1px solid transparent; background: transparent; color: #b8c7c3; font-size: 16px; cursor: pointer; }
.mode-button.selected { border-color: #c7b98654; background: #bdaa791b; color: #f1eadb; }
.mode-button:hover { color: white; background: #ffffff12; }
.mode-note { margin: 11px 0 0; color: #9cadac; font-size: 16px; line-height: 1.5; }
.new-game { display: flex; align-items: center; justify-content: center; gap: 12px; min-height: 58px; width: 100%; margin-top: 26px; padding: 10px; border: 1px solid #dfc997; background: linear-gradient(115deg, #d8c69c, #bba573); color: #111923; font-size: 18px; font-weight: 600; cursor: pointer; box-shadow: 0 10px 25px #0004; }
.new-game:hover, .dialog-action:hover { filter: brightness(1.12); transform: translateY(-1px); }
.new-game-icon { font-size: 25px; font-weight: 400; line-height: 1; }
.panel-signature { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 35px; color: #718483; font-size: 10px; letter-spacing: .12em; }
.panel-signature span { color: #c7b17c; font-size: 20px; }
.page-foot { display: flex; justify-content: space-between; gap: 20px; max-width: 1770px; margin: 0 auto; padding: 10px 0 20px; color: #879b9a; font-size: 16px; }
.page-foot span:first-child { color: #b8a77d; font-size: 11px; letter-spacing: .16em; }

.board-grid { position: absolute; z-index: 3; top: 50%; left: 50%; display: grid; grid-template-columns: repeat(8, 1fr); width: min(90%, 530px); aspect-ratio: 1; padding: 7px; border: 7px solid transparent; background: linear-gradient(#142021, #142021) padding-box, radial-gradient(ellipse at 26% 18%, #7f858b 0%, transparent 30%) border-box, repeating-linear-gradient(137deg, #eeeee9 0 16px, #afb3b8 18px, #f8f8f4 22px, #a8adb1 23px, #e6e7e4 26px, #f5f4ef 49px) border-box; box-shadow: 0 25px 80px #000b, 0 0 0 1px #d9dce0, inset 0 0 0 1px #a8adaf; transform: translate(-50%, -50%); }
.grid-cell { display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 1px solid #d5dbcb20; background: #243c38; cursor: default; }
.grid-cell:nth-child(16n + 2), .grid-cell:nth-child(16n + 4), .grid-cell:nth-child(16n + 6), .grid-cell:nth-child(16n + 8), .grid-cell:nth-child(16n + 9), .grid-cell:nth-child(16n + 11), .grid-cell:nth-child(16n + 13), .grid-cell:nth-child(16n + 15) { background: #203632; }
.grid-cell.legal { cursor: pointer; box-shadow: inset 0 0 0 3px #81e1cd9e; }
.grid-cell.legal:hover, .grid-cell.legal:focus-visible { background: #3c6861; }
.grid-stone { display: block; width: 69%; height: 69%; border-radius: 50%; border: 2px solid #b6aa89; box-shadow: 0 4px 8px #0008, inset 0 2px 3px #ffffff36; }
.grid-stone.black { background: radial-gradient(circle at 30% 22%, #4b5759, #10191f 68%, #071014); }
.grid-stone.white { background: radial-gradient(circle at 30% 18%, white, #eee7d9 65%, #aaa99f); }
.grid-cell.legal::after { content: ""; width: 16%; height: 16%; border-radius: 50%; background: #8ce9d4; box-shadow: 0 0 12px #8ce9d4; }
.grid-cell:has(.grid-stone)::after { display: none; }
.grid-cell:disabled { opacity: 1; }

.help-dialog { width: min(560px, calc(100vw - 32px)); max-height: min(88svh, 750px); overflow: auto; padding: 26px 30px 31px; border: 1px solid #c9b781; background: #111a20; color: #eeeae2; box-shadow: 0 30px 90px #000b; }
.help-dialog::backdrop { background: #05090dce; backdrop-filter: blur(8px); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; }
.dialog-head .eyebrow { margin: 4px 0 0; }
.dialog-close { border: 0; background: transparent; color: #e5e2dc; font-size: 32px; line-height: 1; cursor: pointer; }
.help-dialog h2 { margin: 8px 0 15px; font-size: 34px; font-weight: 600; }
.help-dialog ol { padding-left: 1.5em; }
.help-dialog li, .help-dialog p { font-size: 18px; line-height: 1.78; }
.help-dialog li + li { margin-top: 9px; }
.dialog-action { min-height: 55px; width: 100%; margin-top: 13px; border: 1px solid #dec795; background: linear-gradient(120deg, #d7c397, #baa36e); color: #111820; font-size: 18px; font-weight: 600; cursor: pointer; }
.result-overlay { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 16px; background: #061016c7; backdrop-filter: blur(12px); }
.result-card { width: min(440px, 100%); padding: 38px 30px 25px; border: 1px solid #d4bf8d; background: radial-gradient(circle at 50% 20%, #d0b77d1b, transparent 44%), #111a21; text-align: center; box-shadow: 0 25px 100px #000b; }
.result-card .eyebrow { margin-bottom: 27px; }
.result-disc { width: 80px; height: 80px; margin: auto; border: 4px solid #bbab8d; border-radius: 50%; background: radial-gradient(circle at 30% 20%, #4c595b, #111a20 67%); box-shadow: 0 12px 24px #0007, 0 0 42px #d7c49738; }
.result-disc.white { background: radial-gradient(circle at 30% 20%, white, #e8e1d2 66%, #bbb8ac); }
.result-disc.draw { background: linear-gradient(90deg, #141b21 0 50%, #eee8db 50% 100%); }
.result-card h2 { margin: 23px 0 7px; font-size: 36px; font-weight: 600; }
.result-card p:not(.eyebrow) { margin: 0 0 24px; color: #cad6d1; font-size: 20px; }
.result-close { border: 0; padding: 15px; margin-top: 7px; background: transparent; color: #b9c7c4; font-size: 16px; cursor: pointer; }
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.noscript { position: fixed; z-index: 40; top: 100px; left: 16px; right: 16px; padding: 20px; background: #19222a; font-size: 18px; }

@media (max-width: 1020px) {
  .app-shell { padding: 0 22px; }
  .layout { grid-template-columns: minmax(0, 1fr) 288px; gap: 13px; }
  .stage-panel { padding: 25px 22px 20px; }
  .stage-panel::before { left: 22px; }
  .stage-heading h1 { font-size: clamp(27px, 3.4vw, 40px); }
  .stage-index { display: none; }
  .control-panel { padding: 23px 17px 18px; }
}

@media (min-width: 761px) and (max-height: 760px) {
  .topbar { min-height: 64px; }
  .layout { margin-top: 14px; }
  .stage-panel { padding-top: 20px; }
  .stage-heading .eyebrow { margin-bottom: 8px; }
  .stage-heading h1 { font-size: clamp(29px, 2.7vw, 39px); }
}

@media (max-width: 760px) {
  .app-shell { padding: 0 16px; }
  .topbar { min-height: 70px; }
  .brand-type { font-size: 17px; }
  .brand-type small { font-size: 7px; }
  .brand-symbol { width: 31px; height: 31px; }
  .topbar-actions { gap: 12px; }
  .sound-toggle { min-width: 42px; min-height: 42px; padding: 5px; }
  .sound-toggle-label { display: none; }
  .help-open { font-size: 16px; }
  .help-open span { margin-left: 4px; }
  .layout { grid-template-columns: 1fr; margin-top: 14px; }
  .stage-panel { padding: 23px 19px 16px; }
  .stage-heading h1 { font-size: clamp(26px, 6vw, 38px); }
  .glitch-title > .glitch-line { display: block; width: fit-content; }
  .board-wrap { height: clamp(320px, 86vw, 560px); margin: 6px -17px 0; }
  .stage-foot { flex-wrap: wrap; }
  .stage-instruction { font-size: 16px; }
  .control-panel { display: grid; grid-template-columns: 1fr 1fr; column-gap: 16px; padding: 21px; }
  .panel-head, .turn-card, .score-head, .scoreboard, .control-divider, .mode-head, .mode-switch, .mode-note, .new-game { grid-column: 1 / -1; }
  .turn-card { margin-top: 20px; min-height: 130px; }
  .score-card { min-height: 90px; }
  .control-divider { margin-top: 23px; }
  .panel-signature { display: none; }
  .new-game { margin-top: 18px; }
  .page-foot { padding: 15px 0 22px; }
}

@media (max-width: 390px) {
  .app-shell { padding: 0 11px; }
  .brand { gap: 9px; }
  .brand-type { font-size: 16px; }
  .brand-type small { font-size: 6px; }
  .topbar { gap: 8px; }
  .topbar-actions { gap: 7px; }
  .help-open { padding-left: 0; }
  .stage-panel { padding: 20px 14px 15px; }
  .stage-panel::before { left: 14px; }
  .stage-heading h1 { font-size: 25px; }
  .board-wrap { height: max(310px, 90vw); margin-left: -12px; margin-right: -12px; }
  .stage-foot { gap: 6px; }
  .control-panel { padding: 20px 15px; }
  .page-foot span:last-child { display: none; }
  .board-grid { width: 96%; }
}

@media (prefers-reduced-motion: reduce) {
  .glitch-title > .glitch-line { animation: none !important; }
  .glitch-layer { display: none; animation: none !important; }
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
