:root{color-scheme:dark;--bg:#141720;--surface:#1d222e;--panel:#242a37;--muted:#858d9f;--text:#f4f5f7;--lime:#c5f562;--purple:#a994ff;--gap:clamp(10px,1.5dvh,14px);font-family:ui-rounded,'SF Pro Rounded','Arial Rounded MT Bold',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;font-synthesis:none}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}body{margin:0;min-width:280px;background:var(--bg);color:var(--text);overflow-x:hidden}button{font:inherit;color:inherit;border:0;cursor:pointer;touch-action:manipulation}button:focus-visible{outline:3px solid #fff;outline-offset:4px}button:disabled{cursor:default}button,svg{user-select:none;-webkit-user-select:none}svg{width:24px;height:24px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;flex-shrink:0}.svg-defs{position:absolute;width:0;height:0;overflow:hidden}[hidden]{display:none!important}
.ambient{position:fixed;inset:0;overflow:hidden;pointer-events:none;background:radial-gradient(ellipse at 28% 22%,#2635254a,transparent 45%),radial-gradient(ellipse at 80% 82%,#31234055,transparent 42%)}.grid-texture{position:absolute;inset:0;opacity:.14;background-image:linear-gradient(#626a7a22 1px,transparent 1px),linear-gradient(90deg,#626a7a22 1px,transparent 1px);background-size:56px 56px;mask-image:radial-gradient(ellipse,transparent 25%,#000 100%)}.ambient-x,.ambient-o{position:absolute;font-weight:200;line-height:1;color:#c5f56206;transform:rotate(-15deg)}.ambient-x{font-size:490px;top:-50px;left:calc(50% - 730px)}.ambient-o{font-size:560px;bottom:-160px;right:calc(50% - 740px);color:#a994ff08}
.app{position:relative;max-width:440px;margin:0 auto;height:100svh;height:100dvh;min-height:570px;max-height:920px;display:flex;flex-direction:column;gap:var(--gap);padding:clamp(16px,2.5dvh,26px) 22px;padding-top:max(clamp(16px,2.5dvh,26px),env(safe-area-inset-top));padding-bottom:max(16px,env(safe-area-inset-bottom))}.header{display:flex;align-items:center;justify-content:space-between;min-height:44px;margin-bottom:5px}.brand{display:flex;align-items:center;gap:10px}.brand-icon{display:flex;align-items:center;width:40px;height:40px;position:relative}.brand-icon svg{position:absolute;width:31px;height:31px;stroke-width:8}.brand-icon svg:first-child{color:var(--lime);top:-1px;left:-4px}.brand-icon svg:last-child{color:var(--purple);right:-3px;bottom:-3px;width:25px;height:25px;stroke-width:7}.eyebrow{display:block;font-size:8px;letter-spacing:2.2px;font-weight:750;color:var(--muted);margin-bottom:4px}h1{font-size:24px;font-weight:800;letter-spacing:-1px;line-height:1.05;margin:0}h1>span{color:var(--lime)}.icon-button{display:inline-flex;align-items:center;justify-content:center;background:var(--surface);border:1px solid #ffffff0b;border-radius:15px;min-width:44px;min-height:44px;transition:background .2s,transform .15s}.icon-button:hover{background:#303747}.icon-button:active{transform:scale(.93)}.settings-button svg{width:21px;height:21px;color:#bfc5d2}
.mode-switch{display:grid;grid-template-columns:1fr 1fr;background:#0e1118;border:1px solid #ffffff05;border-radius:17px;padding:5px;gap:5px;flex-shrink:0}.mode-switch button{display:flex;align-items:center;justify-content:center;gap:9px;border-radius:12px;background:transparent;color:var(--muted);font-size:12px;min-height:39px;font-weight:700;transition:background .2s,color .2s,box-shadow .2s}.mode-switch button svg{width:19px;height:19px}.mode-switch button[aria-pressed=true]{background:#303644;color:#f5f7fa;box-shadow:0 2px 7px #0004,inset 0 1px 0 #ffffff0e}
.scoreboard{display:grid;grid-template-columns:1fr 62px 1fr;gap:8px;flex-shrink:0}.score-card{position:relative;display:flex;align-items:center;gap:10px;min-height:76px;padding:12px 14px;background:var(--surface);border:1px solid #ffffff08;border-radius:17px;transition:background .3s,border-color .3s}.score-avatar{display:flex;align-items:center;justify-content:center;width:30px}.score-avatar svg{width:34px;height:34px;stroke-width:8}.x-card .score-avatar{color:var(--lime)}.o-card .score-avatar{color:var(--purple)}.score-detail{display:flex;flex-direction:column;gap:3px}.score-detail>span,.draw-card>span{font-size:9px;letter-spacing:1.3px;font-weight:700;color:var(--muted)}.score-detail strong,.draw-card strong{font-size:28px;font-weight:750;line-height:1}.o-card{justify-content:flex-end}.o-card .score-detail{text-align:right}.draw-card{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px}.draw-card strong{font-size:23px;color:#aab1bf}.draw-card>span{font-size:8px;letter-spacing:1px}.active-dot{position:absolute;top:10px;right:10px;width:4px;height:4px;border-radius:50%;opacity:0}.x-card.is-active{border-color:#c5f5623d;background:linear-gradient(135deg,#c5f5620d,#1d222e)}.o-card.is-active{border-color:#a994ff50;background:linear-gradient(135deg,#a994ff0e,#1d222e)}.is-active .active-dot{opacity:1;background:var(--lime);box-shadow:0 0 7px #c5f5626b}.o-card.is-active .active-dot{background:var(--purple);box-shadow:0 0 7px #a994ff6b}
.game-status{display:flex;align-items:center;justify-content:space-between;min-height:30px;flex-shrink:0;padding:0 3px;margin-bottom:-5px}.turn-text{display:flex;align-items:center;gap:8px;font-size:12px;font-weight:650}.turn-dot{width:6px;height:6px;border-radius:50%;background:var(--lime);box-shadow:0 0 10px #c5f56245}.turn-text.o-turn .turn-dot{background:var(--purple);box-shadow:0 0 10px #a994ff45}.turn-text.thinking .turn-dot{animation:pulse 1s infinite}.turn-text.draw-turn .turn-dot{background:var(--muted);box-shadow:none}.difficulty-trigger{background:transparent;display:flex;align-items:center;color:var(--muted);font-size:9px;letter-spacing:1.2px;font-weight:750;min-height:32px;gap:2px;padding:0 0 0 8px}.difficulty-trigger svg{width:18px;height:18px}.difficulty-trigger:hover{color:var(--text)}.local-hint{font-size:9px;letter-spacing:1.4px;color:var(--muted)}
.board-zone{position:relative;flex:1;min-height:180px;display:grid;place-items:center;container-type:size}.board{width:min(100%,calc(100dvh - 402px));width:min(100cqw,100cqh);aspect-ratio:1;position:relative;display:grid;grid-template-columns:repeat(3,1fr);grid-template-rows:repeat(3,1fr);gap:10px;padding:0}.cell{display:grid;place-items:center;background:linear-gradient(145deg,#272e3c,#202632);border:1px solid #ffffff08;box-shadow:inset 0 1px 0 #ffffff06,0 4px 0 #0d111a;border-radius:19%;padding:12%;position:relative;transition:background .2s,border-color .2s,transform .12s}.cell:not([aria-disabled=true]):hover{background:#303a48;border-color:#c5f56235}.cell:not([aria-disabled=true]):active{transform:translateY(3px);box-shadow:0 1px 0 #0d111a}.cell svg{width:100%;height:100%;stroke-width:7.5;overflow:visible;filter:drop-shadow(0 4px 0 #0002)}.cell.mark-x{color:var(--lime)}.cell.mark-o{color:var(--purple)}.cell.last-move:after{content:'';position:absolute;right:12%;bottom:12%;width:4px;height:4px;background:currentColor;border-radius:50%;opacity:.5}.cell.placed svg{animation:mark-in .26s cubic-bezier(.1,1.7,.4,1)}.cell.winner{border-color:color-mix(in srgb,currentColor 30%,transparent);background:color-mix(in srgb,currentColor 8%,#242b37)}.board.finished .cell:not(.winner){opacity:.5}.board.drawn .cell{opacity:.65}.win-line{pointer-events:none;position:absolute;inset:0;width:100%;height:100%;stroke-width:3;filter:drop-shadow(0 0 8px currentColor);display:none}.win-line.show{display:block;animation:line-in .35s .1s both;stroke-dasharray:400;stroke-dashoffset:0}.board[data-winner=X] .win-line{color:var(--lime)}.board[data-winner=O] .win-line{color:var(--purple)}.round-note{min-height:22px;text-align:center;font-size:11px;color:#737e92;letter-spacing:.15px;display:flex;align-items:center;justify-content:center;margin-top:-4px;flex-shrink:0}.round-note.result-note{color:var(--text);font-size:13px;font-weight:600}.actions{display:flex;gap:12px;flex-shrink:0}.undo-button{width:54px;height:54px;flex-shrink:0;border-radius:16px;color:#c0c7d4}.undo-button svg{width:22px;height:22px}.undo-button:disabled{opacity:.3}.primary-button{display:flex;align-items:center;justify-content:center;gap:10px;background:var(--lime);color:#1b2810;border-radius:16px;min-height:54px;padding:0 20px;font-size:14px;font-weight:800;box-shadow:0 4px 0 #769e31,0 6px 20px #c5f5620c;transition:background .15s,transform .15s,box-shadow .15s;flex:1}.primary-button:hover{background:#d4ff81}.primary-button:active{transform:translateY(3px);box-shadow:0 1px 0 #769e31}.primary-button svg{width:20px;height:20px;stroke-width:2}.button-arrow{font-size:23px;margin-left:auto;line-height:1;font-weight:500}.actions .primary-button>svg{margin-right:auto}.footer{display:flex;align-items:center;justify-content:center;gap:16px;min-height:30px;flex-shrink:0;margin-top:3px}.footer button{display:flex;align-items:center;gap:6px;font-size:10px;color:var(--muted);background:none;min-height:30px;padding:0 5px}.footer button:hover{color:var(--text)}.footer svg{width:15px;height:15px;stroke-width:1.6}.footer-dot{color:#414959;font-size:12px}
.sheet{color:var(--text);background:#1c212d;border:1px solid #ffffff12;border-radius:28px;padding:12px 25px 28px;width:calc(100% - 28px);max-width:406px;max-height:calc(100dvh - 40px);box-shadow:0 24px 100px #0008;overscroll-behavior:contain}.sheet::backdrop{background:#080b13b8;backdrop-filter:blur(10px)}.sheet[open]{animation:sheet-in .2s ease-out}.sheet-handle{width:34px;height:4px;background:#424958;border-radius:5px;margin:0 auto 22px}.sheet-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:24px}.sheet-header .eyebrow{font-size:8px;letter-spacing:1.7px;margin-bottom:7px}h2{font-size:25px;letter-spacing:-.8px;margin:0}.close-button{width:36px;height:36px;border-radius:50%;background:#2b3240;color:#a9b2c2;font-size:25px;font-weight:300;line-height:1}.sheet fieldset{border:0;margin:0 0 22px;padding:0}.sheet legend{font-size:12px;font-weight:650;margin-bottom:10px}.options{display:flex;gap:7px}.options button{flex:1;min-height:64px;border:1px solid #ffffff08;border-radius:13px;background:#272e3b;font-size:12px;font-weight:650;transition:background .2s,border-color .2s}.options button>span{display:block;font-size:9px;font-weight:400;color:var(--muted);margin-top:6px;white-space:nowrap}.options button[aria-pressed=true]{background:#c5f56213;border-color:#c5f56288;color:var(--lime)}.options button[aria-pressed=true]>span{color:#b0bf9c}.mark-options button{display:flex;align-items:center;justify-content:center;gap:9px;min-height:50px}.mark-options svg{stroke-width:7;width:27px;height:27px}.mark-options [data-mark=O][aria-pressed=true]{color:var(--purple);background:#a994ff12;border-color:#a994ff88}.settings-note{color:var(--muted);font-size:10px;line-height:1.6;margin:-8px 0 18px}.setting-row{display:flex;align-items:center;justify-content:space-between;padding:18px 0;border-top:1px solid #ffffff0b;border-bottom:1px solid #ffffff0b}.setting-row strong{display:block;font-size:12px;font-weight:600}.setting-row div>span{display:block;font-size:10px;color:var(--muted);margin-top:5px}.toggle{background:#3b4453;width:42px;height:25px;border-radius:25px;padding:3px;transition:background .2s}.toggle span{display:block;width:19px;height:19px;background:#d1d6df;border-radius:50%;transition:transform .2s}.toggle[aria-checked=true]{background:var(--lime)}.toggle[aria-checked=true] span{background:#1b2810;transform:translateX(17px)}.reset-scores{font-size:11px;background:transparent;color:#d4a0a0;display:block;margin:18px auto 0;min-height:36px}.reset-message{text-align:center;color:var(--muted);font-size:10px;min-height:14px;margin:0 0 10px}.sheet-done{width:100%;min-height:49px;font-size:13px}.sheet-done svg{margin-left:auto}.help-sheet p{font-size:12px;line-height:1.8;color:#a5aebe}.help-sheet strong{color:var(--text)}.help-board{width:123px;height:123px;display:grid;grid-template:repeat(3,1fr)/repeat(3,1fr);gap:5px;margin:0 auto 20px;transform:rotate(-5deg)}.help-board span{background:#2a3140;border-radius:8px;display:grid;place-items:center;font-size:31px;color:var(--purple);line-height:1}.help-board span:nth-child(4n+1){color:var(--lime);background:#c5f56214}.help-tip{display:flex;align-items:center;gap:12px;background:#272e3b;border-radius:13px;padding:14px;font-size:10px;color:#b2bbcb;line-height:1.7;margin-top:18px}.help-tip svg{width:20px;color:var(--lime)}.help-sheet .keyboard-tip{font-size:10px;color:var(--muted);text-align:center;margin:18px 0 5px}.help-sheet .help-save{font-size:9px;color:var(--muted);text-align:center;margin:0 0 20px}
.confetti{position:absolute;inset:0;pointer-events:none;overflow:visible}.confetti i{position:absolute;top:45%;left:50%;height:8px;width:5px;border-radius:2px;background:var(--c);animation:confetti .85s ease-out forwards;transform:translate(-50%,-50%)}
@keyframes mark-in{from{opacity:0;transform:scale(.45) rotate(-10deg)}to{opacity:1;transform:scale(1) rotate(0)}}@keyframes pulse{50%{opacity:.35}}@keyframes line-in{from{stroke-dashoffset:400;opacity:0}to{stroke-dashoffset:0;opacity:1}}@keyframes sheet-in{from{opacity:0;transform:translateY(18px)}to{opacity:1;transform:translateY(0)}}@keyframes confetti{to{transform:translate(var(--tx),var(--ty)) rotate(var(--rot));opacity:0}}
@media(min-width:650px){body{min-height:100dvh;display:grid;place-items:center}.app{width:440px;border-left:1px solid #ffffff05;border-right:1px solid #ffffff05;background:#14172088;box-shadow:0 0 100px #0002;padding-left:28px;padding-right:28px}.header{margin-bottom:8px}.eyebrow{font-size:8px}.keyboard-tip{display:block}}
@media(max-width:350px){.app{padding-left:16px;padding-right:16px;gap:10px}.scoreboard{grid-template-columns:1fr 46px 1fr;gap:6px}.score-card{padding:10px;gap:6px;min-height:65px}.score-avatar svg{width:29px;height:29px}.score-detail strong{font-size:24px}.board{gap:8px}.mode-switch button{font-size:11px}.sheet{padding-left:18px;padding-right:18px}}
@media(max-height:700px){.app{gap:10px;padding-top:max(14px,env(safe-area-inset-top));padding-bottom:max(10px,env(safe-area-inset-bottom))}.header{min-height:39px;margin-bottom:0}.mode-switch button{min-height:34px}.score-card{min-height:62px;padding-top:8px;padding-bottom:8px}.score-detail strong{font-size:25px}.game-status{min-height:26px}.round-note{font-size:10px;min-height:17px}.actions .primary-button,.undo-button{min-height:48px;height:48px}.footer{min-height:25px;margin-top:0}.footer button{min-height:25px}.board-zone{min-height:170px}}
@media(max-width:600px){.sheet{position:fixed;inset:auto 0 0;margin:0 auto;width:100%;max-width:440px;max-height:calc(100dvh - 20px);border-radius:28px 28px 0 0;padding-bottom:max(25px,env(safe-area-inset-bottom))}.keyboard-tip{display:none}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important}.confetti{display:none}}
/* Board selection and Caro touch surface. */
#game-title{color:var(--text)}
.game-switch{display:flex;align-items:center;gap:20px;border-bottom:1px solid #ffffff0b;flex-shrink:0;min-height:39px;margin-top:-8px}
.game-switch button{position:relative;min-height:39px;background:none;padding:0 0 10px;font-size:12px;font-weight:750;color:var(--muted)}
.game-switch button>span{font-size:8px;color:#788398;margin-left:5px;letter-spacing:.1px;font-weight:500}
.game-switch button[aria-pressed=true]{color:var(--text)}
.game-switch button[aria-pressed=true]:after{position:absolute;content:'';height:2px;bottom:-1px;left:0;right:0;border-radius:2px;background:var(--lime)}
.game-switch button[aria-pressed=true]>span{color:#a9bd8f}
.board-zone{display:flex;flex-direction:column;container-type:normal;overflow:hidden}
.board-tools{display:flex;justify-content:space-between;align-items:center;height:32px;flex-shrink:0;width:100%;padding:0 4px 5px}
.board-tools>span{font-size:8px;font-weight:700;color:var(--muted);letter-spacing:1.3px}
.zoom-tools{display:flex;align-items:center;gap:2px;padding:1px;border:1px solid #ffffff0a;border-radius:8px;background:#0e1118}
.zoom-tools button{display:grid;place-items:center;width:29px;height:26px;padding:0;background:none;border-radius:6px;font-size:18px;color:#cbd2df}
.zoom-tools button:hover{background:#303747}.zoom-tools #zoom-fit{width:43px;font-size:8px;font-weight:650;letter-spacing:.4px;color:var(--muted)}
.board-viewport{position:relative;flex:1;width:100%;min-height:0;overflow:hidden;container-type:size}
.board-surface{width:100%;height:100%;display:grid;place-items:center}
.board{flex-shrink:0;width:min(100cqw,100cqh)}
.app.is-caro .board-zone{min-height:170px;background:#10151e;border:1px solid #ffffff09;border-radius:15px;padding:5px}
.app.is-caro .board-tools{padding-left:7px;padding-right:3px}
.app.is-caro .board-viewport{overflow:auto;touch-action:none;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#495064 #11161f;container-type:normal;border-radius:8px}
.app.is-caro .board-surface{width:max(100%,calc(var(--caro-side,300px) + 12px));height:max(100%,calc(var(--caro-side,300px) + 12px));padding:6px}
.app.is-caro .board{aspect-ratio:1;grid-template-columns:repeat(15,1fr);grid-template-rows:repeat(15,1fr);gap:0;padding:0;background:#202936;border:1px solid #4a586b;border-radius:2px;box-shadow:0 6px 20px #0002}
.app.is-caro .cell{min-width:0;min-height:0;border:0;border-right:1px solid #45536a70;border-bottom:1px solid #45536a70;border-radius:0;background:transparent;box-shadow:none;padding:7%;color:var(--text)}
.app.is-caro .cell:nth-child(15n){border-right:0}.app.is-caro .cell:nth-child(n+211){border-bottom:0}
.app.is-caro .cell:not([aria-disabled=true]):hover{background:#c5f5620a;border-color:#45536a70}
.app.is-caro .cell:not([aria-disabled=true]):active{transform:none;box-shadow:none}
.app.is-caro .cell.mark-x{color:var(--lime)}.app.is-caro .cell.mark-o{color:var(--purple)}
.app.is-caro .cell svg{stroke-width:6.5;filter:none}
.app.is-caro .cell.last-move{background:#ffffff09}.app.is-caro .cell.last-move:after{width:3px;height:3px;right:10%;bottom:10%;opacity:.8}
.app.is-caro .cell.aimed{outline:2px solid var(--lime);outline-offset:-2px;background:#c5f56216;z-index:1;color:var(--lime)}
.app.is-caro .board[data-turn=O] .cell.aimed{color:var(--purple);outline-color:var(--purple);background:#a994ff16}
.app.is-caro .cell.aimed svg{opacity:.38}
.app.is-caro .cell.winner{background:color-mix(in srgb,currentColor 16%,#202936)}
.app.is-caro .win-line{stroke-width:1.8;filter:drop-shadow(0 0 3px currentColor)}
.app.is-caro .board.finished .cell:not(.winner){opacity:.7}
.app.is-caro .round-note{font-size:10px;line-height:1.4;letter-spacing:0}
.primary-button:disabled{cursor:default;background:#343f30;color:#8c9e7d;box-shadow:0 3px 0 #202a20;transform:none}
.restart-button{width:48px;height:54px;border-radius:16px;flex-shrink:0;color:#a8b3c5}
.restart-button svg{width:19px;height:19px}
.app.is-caro .actions{gap:9px}.app.is-caro .undo-button{width:48px}.app.is-caro .primary-button{padding:0 14px;font-size:12px;gap:7px}
.app.is-caro .primary-button>svg{margin-right:0;stroke-width:7;width:23px;height:23px}
.app.is-caro .primary-button.round-action>svg{stroke-width:2;width:20px;height:20px}
.app.is-caro .primary-button .button-arrow{font-size:18px;margin-left:auto}
.caro-rule-setting{margin-bottom:20px;border-top:0;padding-top:0}
.help-sheet.is-caro .help-board{width:175px;height:35px;grid-template:1fr/repeat(5,1fr);gap:4px;transform:rotate(-4deg);margin-bottom:16px}
.help-sheet.is-caro .help-board span{font-size:29px;color:var(--lime);background:#c5f56214}
@media(max-height:700px){.game-switch{min-height:31px;margin-top:-4px}.game-switch button{min-height:31px;padding-bottom:7px}.board-tools{height:30px}.app.is-caro .round-note{min-height:15px;font-size:9px}.restart-button{height:48px}.app.is-caro .score-card{min-height:57px}.app.is-caro .header{min-height:35px}.app.is-caro .mode-switch button{min-height:30px}.app.is-caro .board-zone{min-height:150px}}
/* Reserve most of the portrait screen for the Caro board. */
.app.is-caro{gap:10px;padding-top:max(18px,env(safe-area-inset-top));padding-bottom:max(12px,env(safe-area-inset-bottom))}
.app.is-caro .header{min-height:40px;margin-bottom:0}
.app.is-caro .game-switch{min-height:34px;margin-top:0}
.app.is-caro .game-switch button{min-height:34px;padding-bottom:8px}
.app.is-caro .mode-switch{padding:4px}.app.is-caro .mode-switch button{min-height:32px}
.app.is-caro .score-card{min-height:58px;padding-top:7px;padding-bottom:7px}
.app.is-caro .score-detail strong{font-size:24px}.app.is-caro .draw-card strong{font-size:21px}
.app.is-caro .score-detail>span{font-size:8px}.app.is-caro .score-avatar svg{width:29px;height:29px}
.app.is-caro .game-status{min-height:26px;margin-bottom:-3px}.app.is-caro .round-note{min-height:18px}
.app.is-caro .footer{min-height:24px;margin-top:0}.app.is-caro .footer button{min-height:24px}
.app.is-caro .actions .primary-button,.app.is-caro .actions .icon-button{height:50px;min-height:50px}
@media(max-height:700px){.app.is-caro{gap:8px;padding-top:max(14px,env(safe-area-inset-top));padding-bottom:max(10px,env(safe-area-inset-bottom))}.app.is-caro .header{min-height:35px}.app.is-caro .game-switch,.app.is-caro .game-switch button{min-height:30px}.app.is-caro .score-card{min-height:52px}.app.is-caro .mode-switch button{min-height:29px}.app.is-caro .actions .primary-button,.app.is-caro .actions .icon-button{height:46px;min-height:46px}.app.is-caro .round-note{min-height:14px}}
