/* Stylish Reversi — deep navy × gold, the same look as the test-play.
   Six themes (royal / emerald / sakura / noir / blue-orange /
   high-contrast), switched in settings and saved in the browser.
   The board itself stays green in every theme. */
:root{
 --bg:#1a2742;--bg2:#131c31;--navy:#24365e;--navy2:#2e4572;
 --gold:#bfa05e;--gold2:#ecd79a;--ivory:#f2ecdb;--muted:#b8c0cf;
 --line:rgba(191,160,94,.5);--card:#24365e;
 --cell:#789c6a;--board-bg:#23472e;
 --wood1:#7a4e2c;--wood2:#3a2010;--wood3:#5c371d;
}
html[data-theme="royal"]{--bg:#1a2742;--bg2:#131c31;--navy:#24365e;--navy2:#2e4572;--gold:#bfa05e;--gold2:#ecd79a;--ivory:#f2ecdb;--muted:#b8c0cf;--line:rgba(191,160,94,.5);--card:#24365e}
html[data-theme="emerald"]{--bg:#123b31;--bg2:#0d2d25;--navy:#1a4d3f;--navy2:#236052;--gold:#d2ab52;--gold2:#eedca8;--ivory:#f1f7f1;--muted:#b0c8bc;--line:rgba(210,171,82,.5);--card:#1a4d3f}
html[data-theme="sakura"]{--bg:#3a2436;--bg2:#2c1b29;--navy:#4e3046;--navy2:#613d57;--gold:#e2abb9;--gold2:#f6d3dc;--ivory:#faf0f2;--muted:#c6aab5;--line:rgba(226,171,185,.5);--card:#4e3046}
html[data-theme="noir"]{--bg:#1e1e22;--bg2:#141416;--navy:#2b2b2f;--navy2:#36363b;--gold:#d2ab52;--gold2:#ecd79a;--ivory:#f0f0f0;--muted:#b2b2ba;--line:rgba(210,171,82,.55);--card:#2b2b2f}
html[data-theme="blueorange"]{--bg:#173050;--bg2:#10243d;--navy:#1f4168;--navy2:#2b5382;--gold:#e89a4e;--gold2:#f8c47e;--ivory:#f1f5f9;--muted:#b1c1d7;--line:rgba(232,154,78,.5);--card:#1f4168}
html[data-theme="highcontrast"]{--bg:#1c1c1c;--bg2:#121212;--navy:#232323;--navy2:#2c2c2c;--gold:#ffd700;--gold2:#fff2a0;--ivory:#fff;--muted:#e2e2e2;--line:#ffd700;--card:#232323}
*{box-sizing:border-box}
/* The page background is one flat colour: no radial glow at the top,
   so the top of the title screen (the back/settings row and the
   background of the top stone row) is the same colour as the rest
   of the page instead of a different tint. */
body{margin:0;background:var(--bg);color:var(--ivory);font-family:'Zen Kaku Gothic New',system-ui,sans-serif}
main{max-width:980px;margin:auto;padding:20px 16px 32px;position:relative;z-index:1}
/* Top bar (like the test play): back on the left, language and
   settings on the right. It stays on every screen. */
.topbar{display:flex;align-items:center;justify-content:space-between;gap:10px;min-height:48px;position:relative;z-index:3}
.topbar .tb-r{display:flex;align-items:center;gap:10px}
.topbar .lang-top{display:flex;align-items:center;gap:6px;margin:0}
.topbar .lang-top select{width:auto;margin:0}
/* During a match the language select is hidden from the top bar, so
   the match screen has nothing above the board but the exit button.
   The language itself is still changed in settings. */
body.in-match .topbar .lang-top{display:none}
#nav-back,#nav-settings{width:auto;padding:10px 16px}
/* Title screen: logo, title, one gold start button and the small
   online-count status, centred like the test play. No card here. */
#title{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:28px;min-height:60vh;background:none;border:0;box-shadow:none}
#start{font-size:1.25rem;font-weight:700;padding:16px 44px}
#online-now{font-weight:bold;color:var(--gold);min-height:1.5em;text-align:center}
/* Title screen: gold 2×2-stone logo, large gold title, stone parade. */
.hero{text-align:center;padding:10px 0 4px}
.logo{display:grid;grid-template-columns:repeat(2,20px);gap:3px;width:50px;height:50px;margin:0 auto 10px;padding:4px;background:var(--navy);border:2px solid var(--gold);border-radius:12px;box-shadow:0 4px 14px rgba(0,0,0,.4)}
.logo .st,.parade .st{border-radius:50%}
.st.b{background:radial-gradient(circle at 35% 30%,#5a5a5a,#161616 55%,#000)}
.st.w{background:radial-gradient(circle at 35% 30%,#fff,#ececec 55%,#c8c8c8);border:1px solid #999}
h1{font-family:'Cinzel','Shippori Mincho B1',serif;font-size:clamp(1.8rem,6vw,2.6rem);color:var(--gold2);letter-spacing:.06em;margin:.15em 0;text-shadow:0 2px 12px rgba(0,0,0,.5)}
h2,h3{font-family:'Shippori Mincho B1','Cinzel',serif;color:var(--gold)}
/* Stone parade: a fixed backdrop with two rows of true-circle stones
   (top and bottom), like the test play. Every stone is a square tile
   (width = height, aspect-ratio 1/1) with border-radius 50%, so the
   circle can never squash into an ellipse. It is dimmed on the menu
   and settings screens and hidden while a game is on. */
.parade{position:fixed;inset:0;z-index:0;pointer-events:none;overflow:hidden;-webkit-mask:linear-gradient(90deg,transparent,#000 12%,#000 88%,transparent);mask:linear-gradient(90deg,transparent,#000 12%,#000 88%,transparent);animation:sway 9s ease-in-out infinite alternate}
.prow{position:absolute;left:0;display:flex;gap:12px;justify-content:center;width:100%}
.prow.r0{top:9%}
.prow.r1{bottom:9%}
.prow .st{flex:none;width:36px;height:36px;aspect-ratio:1/1;border-radius:50%}
body[data-screen="menu"] .parade,body[data-screen="settings"] .parade{opacity:.25}
body[data-screen="game"] .parade{display:none}
@media (prefers-reduced-motion:reduce){.parade{animation:none}}
/* Cards: each screen sits on a soft navy card with a thin gold line. */
section{background:linear-gradient(180deg,var(--navy),var(--bg2));border:1px solid var(--line);border-radius:16px;padding:18px;margin:16px 0;box-shadow:0 8px 24px rgba(0,0,0,.35)}
button,input,select,textarea{font:inherit;padding:10px;margin:4px 0}
button{cursor:pointer;background:var(--navy2);color:var(--ivory);border:1px solid var(--gold);border-radius:999px;padding:12px 20px;box-shadow:0 2px 8px rgba(0,0,0,.3)}
button:disabled{cursor:default;opacity:.45}
button:hover:not(:disabled){filter:brightness(1.15)}
/* The lobby is the menu screen: its main actions are gold pills. */
#lobby button{width:100%}
#play-two,#play-online,#play-nearby,#play-far,#local-start,#spectate-open,#play-go,#far-go,#start,#cpu-play,#cpu-start{background:linear-gradient(180deg,var(--gold2),var(--gold));color:#241a05;border-color:var(--gold2);font-weight:700}
#play-screen button{width:100%}
#far-screen button{width:100%}
#twoplayer-screen button{width:100%}
#local-screen button{width:100%}
#cpu-screen button,#cpu-shape-screen button{width:100%}
/* CPU play: the five strength rows show the name and the description
   side by side, like the test play. */
#cpu-levels .cpu-level{display:flex;justify-content:space-between;align-items:center;gap:12px;text-align:left}
#cpu-levels .cpu-level span{font-weight:700}
#cpu-levels .cpu-level small{color:var(--muted);font-size:.9em}
label{display:block}
input,select,textarea{display:block;width:100%;background:var(--navy);color:var(--ivory);border:1px solid var(--line);border-radius:10px}
input[type=checkbox]{display:inline;width:auto}
a{color:var(--gold2)}
#room-id{overflow-wrap:anywhere;font-family:monospace}
#board{display:grid;grid-template-columns:repeat(8,1fr);width:var(--board-size,min(100%,640px));gap:2px;background:linear-gradient(135deg,var(--wood1),var(--wood2) 45%,var(--wood3));padding:10px;border-radius:14px;box-shadow:0 12px 32px rgba(0,0,0,.5),inset 0 0 0 2px rgba(0,0,0,.35);touch-action:manipulation}
#board button{position:relative;aspect-ratio:1;border:0;border-radius:2px;background:var(--cell);margin:0;padding:0;min-width:0;box-shadow:none}
#board button.black:after,#board button.white:after{content:"";position:absolute;inset:10%;border-radius:50%;background:radial-gradient(circle at 35% 30%,#5a5a5a,#161616 55%,#000)}
#board button.white:after{background:radial-gradient(circle at 35% 30%,#fff,#ececec 55%,#c8c8c8);border:1px solid #555}
#board button.hint:before{content:"";position:absolute;inset:40%;border-radius:50%;background:var(--board-bg)}
button:focus-visible{outline:3px solid var(--gold2);outline-offset:-3px}
[hidden]{display:none!important}
#message{min-height:1.5em}
#move-timer,#pool{font-weight:bold;min-height:1.5em}
/* Move timer: one bar directly above the board, in normal flow, so the
   seconds can never cover a cell. It is hidden while there is no
   countdown (local two-player and CPU play have no timer), so it leaves
   no empty strip above the board. */
#timer-bar{margin:0 0 10px;padding:8px 12px;text-align:center;background:var(--navy);border:1px solid var(--line);border-radius:12px}
#timer-bar p{margin:0}
/* The board wrapper takes whatever height is left on the game screen,
   so the board can shrink to fit one viewport instead of pushing the
   page into a scroll. */
/* The exit button sits at the very top of the game screen, at the
   left, far from the board, so a tap meant for the top row of the
   board can never land on it by mistake. */
#game #leave{align-self:flex-start;margin-bottom:16px}
#board-wrap{flex:1 1 auto;min-height:0;display:flex;align-items:center;justify-content:center}
/* A match must never slide: while the game screen itself is shown, the
   page cannot scroll and the whole match (top bar, player lines, timer
   bar, board, controls) fits in one viewport. The game section takes
   the rest of the viewport and the board wrapper takes the height that
   is left (fitBoard sizes the board to it). The lock applies only while
   the game screen is shown: settings opened mid-game can still scroll. */
body.in-match{overflow:hidden;overscroll-behavior:none}
body.in-match main{height:100vh;height:100svh;height:100dvh;display:flex;flex-direction:column;padding:20px 8px 12px}
body.in-match #game{flex:1;min-height:0;display:flex;flex-direction:column;overflow:hidden;margin:8px 0 0;padding:12px}
/* The game banner is a direct child of main, not of the game section:
   main gives it its full height (it never shrinks) and the game section
   shrinks instead, so a short window can never clip the banner — only
   the board gives way, through fitBoard. */
body.in-match #ad-game{flex:none}
/* The status lines are plain <p> elements with the browser's default
   1em top and bottom margins; in a flex column those margins do not
   collapse, so each line costs a line of text plus 32px of air. During
   a match, shrink them to a hairline so the board gets the height. */
body.in-match #game p{margin:2px 0}
body.in-match #message{margin:4px 0}
#rank-ladder div{padding:2px 0}
#rank-ladder .rank-now{font-weight:bold;background:var(--gold);color:var(--bg)}
#ranking-list .me-row{font-weight:bold;background:var(--gold);color:var(--bg)}
#my-rating,#rating-change{font-weight:bold}
#rankings ol{margin:4px 0;padding-left:24px}
#board .void{aspect-ratio:1;background:transparent;box-shadow:none}
#board button.confirm{outline:3px solid var(--gold2);outline-offset:-3px}
#confirm-bar{font-weight:bold;min-height:1.5em}
#greet-line{min-height:1.5em;font-weight:bold}
#greet-panel button{margin:2px;padding:8px 14px}
#rematch-line{min-height:1.5em}
#settings label{margin:6px 0}
ruby rt{font-size:.62em}
#settings select,#settings input[type=range]{display:block;width:100%}
#settings input[type=checkbox]{display:inline;width:auto}
#se-preview-others button{margin:2px}
/* Banner ads (AdSense): one slot per screen, shown only after the review
   passes and the slot number is set in ads.js. The 150px top margin keeps
   the ad 150px or more from every button and from the board, so a tap on
   a control can never land on the ad. The min-height reserves the banner
   space before the ad fills, so the page does not jump when it loads. */
.ad-banner{margin:150px 0 32px;min-height:100px;text-align:center}
.ad-banner small{display:block;margin-bottom:8px;color:var(--muted)}
.ad-banner:has(>ins[data-ad-status="unfilled"]){display:none}
/* Turnstile (robot check) box on the two room-creation screens: the
   widget is centred, with its height reserved so the screen does not
   jump when the challenge loads. */
.turnstile-box{display:flex;justify-content:center;margin:12px 0;min-height:65px}
@media print{.ad-banner{display:none}}
/* Contact form: same block layout as the settings screen. */
#contact label{margin:6px 0}
#contact select{display:block;width:100%}
#contact textarea{display:block;width:100%;min-height:120px;font:inherit;padding:10px;margin:4px 0}
#contact-status{min-height:1.5em;font-weight:bold}
/* Phones: the board goes to the bottom of the game screen, so the
   controls stay at the top and the banner (the farthest thing from
   the board) goes to the very top, 150px from the controls below it.
   The banner is a direct child of main now, so it is ordered between
   the top bar and the game screen, and the game screen after it.
   Desktop keeps the DOM order. The timer bar sits just above the
   board so the seconds stay visible during a game, and the confirm
   bar sits just above the board so it stays next to the cell it
   confirms. */
@media (max-width:640px){
 #game{display:flex;flex-direction:column}
 #ad-game{order:1;margin-bottom:150px}
 #game{order:2}
 #game #timer-bar{order:8}
 #game #confirm-bar{order:9}
 #game #result-window{order:9}
 #game #board-wrap{order:10}
 section{padding:14px}
}
/* Move numbers (棋譜): a small number on each placed stone. Light on black
 stones, dark on white stones, above the stone but below any hint dot. */
#board .move-no{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;z-index:1;font-size:clamp(10px,3vw,16px);font-weight:bold;pointer-events:none;color:var(--ivory)}
#board button.white .move-no{color:#222}
/* End-of-game ceremony （勝負が終わったときの演出）: when a game ends,
   after a short pause the board stones come off one by one, from the
   top-left, until the board is empty, while the stones are lined up
   in two trays — black stones in one tray, white stones in the other —
   black and white taking turns, and the black and white totals tick
   up big. When every stone is counted, 勝ち / 負け / 引き分け
   appears big in the centre of the screen. The counting window is one
   fixed-size panel, shown at its full size from the start, so it never
   grows while the stones line up: the totals row is a fixed height
   and each tray is tall enough for five rows of stones (the most a
   64-stone tray needs even on a narrow phone), with any overflow
   clipped instead of growing the window. The overlay never takes
   taps (pointer-events:none), so もう一戦 and 退出 stay usable while
   it shows. */
#game{position:relative}
#result-overlay{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;pointer-events:none;z-index:5}
#result-window{flex:none;display:flex;flex-direction:column;gap:10px;height:274px;box-sizing:border-box;margin:0 0 10px;padding:12px;background:var(--navy);border:1px solid var(--line);border-radius:12px}
#result-window[hidden]{display:none}
#result-counts{display:flex;gap:28px;justify-content:center;align-items:center;flex:none;height:66px;margin:0;font-size:40px;font-weight:bold}
.result-count{display:flex;align-items:center;gap:10px}
.result-stone{display:inline-block;width:30px;height:30px;border-radius:50%;background:radial-gradient(circle at 35% 30%,#5a5a5a,#161616 55%,#000)}
.result-stone.white{background:radial-gradient(circle at 35% 30%,#fff,#ececec 55%,#c8c8c8);border:1px solid #555}
#result-tray-black,#result-tray-white{display:flex;flex-wrap:wrap;gap:3px;justify-content:center;align-items:flex-start;flex:none;height:82px;overflow:hidden;margin:0;padding:0}
#result-tray-black .result-stone,#result-tray-white .result-stone{width:14px;height:14px;flex:none;animation:tray-pop .25s ease-out}
@keyframes tray-pop{from{transform:scale(.3);opacity:0}to{transform:scale(1);opacity:1}}
#result-word{margin:0;font-size:clamp(52px,15vw,88px);font-weight:bold;color:var(--gold2);text-shadow:0 2px 0 rgba(0,0,0,.6),0 0 24px rgba(0,0,0,.8);visibility:hidden}
#result-word.show{visibility:visible;animation:result-pop .45s ease-out}
@keyframes result-pop{from{transform:scale(.5);opacity:0}to{transform:scale(1);opacity:1}}
@media (prefers-reduced-motion:reduce){#result-word.show{animation:none}#result-tray-black .result-stone,#result-tray-white .result-stone{animation:none}}
/* Spectating list: one button per game in progress. */
#spectate-list button{display:block;width:100%;text-align:left}
/* Rankings: the period (this week / this month / all) is one joined
   segment, and the rank filter is a single dropdown next to its
   label, so the screen is not a wall of buttons. */
#rank-scope{display:flex}
#rank-scope button{flex:1;margin:0;border-radius:0}
#rank-scope button:first-child{border-radius:999px 0 0 999px}
#rank-scope button:last-child{border-radius:0 999px 999px 0}
#rank-scope button+button{margin-left:-1px}
#rank-scope button.seg-active{background:linear-gradient(180deg,var(--gold2),var(--gold));color:#241a05;font-weight:700}
#rankings #rank-filter{display:inline-block;width:auto;min-width:150px;margin-left:8px}
/* Quick match: the waiting line and its cancel button. The button
   stays small instead of the full-width play-screen button. */
#quick-waiting{font-weight:bold;min-height:1.5em}
#quick-waiting button{width:auto}

/* The record showcase: a big gold rating that counts up, the rank big
   with stars, the streaks and the score, titles as gold chips. */
#my-showcase{margin:12px 0;padding:16px;background:var(--navy);border:1px solid var(--line);border-radius:12px;text-align:center}
#my-showcase p{margin:6px 0}
#my-rating-num{font-size:2.6rem;font-weight:700;color:var(--gold2)}
#my-rank-big{font-size:1.3rem;font-weight:700;color:var(--gold2)}
#my-streak-line{font-weight:700}
.title-chip{display:inline-block;margin:2px;padding:4px 10px;background:var(--gold);color:#241a05;font-weight:700;border-radius:999px}
/* The crown for the streak kings: a gold crown drawn with CSS only
   (a clip-path polygon), never an emoji. */
.crown{display:inline-block;width:1.2em;height:.9em;margin:0 .3em;background:linear-gradient(180deg,var(--gold2),var(--gold));clip-path:polygon(0% 100%,0% 45%,18% 62%,32% 12%,50% 58%,68% 12%,82% 62%,100% 45%,100% 100%);vertical-align:-.1em}
/* Streak news on the title screen, and the kings / today's stars on
   the rankings screen. A missing person shows an honest empty line,
   so these rows stay quiet until the server has someone to show.
   The news panel sits above the stone parade: the parade is a fixed
   z-index:0 layer, and a positioned layer paints over non-positioned
   content, so without this the bottom stone row would cover the lower
   news rows on a narrow screen. The panel keeps its solid navy
   background, so the stones stay visible around it, not over the text. */
#streak-news{position:relative;z-index:1;margin:8px 0;padding:12px;background:var(--navy);border:1px solid var(--line);border-radius:12px;text-align:left}
#streak-news h2{margin:0 0 6px}
#news-list{margin:0;padding-left:20px}
#news-list li{margin:4px 0}
#streak-kings p,#today-star p{margin:4px 0}
#streak-kings .king-label,#today-star .king-label{font-weight:700;color:var(--gold2);margin-right:.4em}
/* The current month's champion on the title screen: a gold border and
   title, a bigger crown, centred. Hidden until the server has a
   champion for this month. */
#month-champ{margin:12px 0;padding:16px;background:var(--navy);border:1px solid var(--gold);border-radius:12px;text-align:center}
#month-champ h2{margin:0 0 8px;color:var(--gold2);font-size:1.25em}
#month-champ-line{margin:0;font-size:1.15em;font-weight:700}
#month-champ-line .crown{width:1.4em;height:1.05em}
