.ttt-page{--panel:#fcfaf8;--text:#173d40;--edge:#00000018;--accent:#4a7a66;--x:#f05c57;--o:#3bba96;background:#f3f7f4;color:var(--text)}.ttt-page.dark{--panel:#1d2123;--text:#fff;--edge:#ffffff16;background:#141819}.ttt-page .header-inner{max-width:1800px;padding:0 24px}.ttt-layout{width:100%;max-width:1800px;margin:auto;display:grid;grid-template-columns:302px minmax(0,1fr);gap:18px;padding:20px;min-height:0}.ttt-sidebar{order:0;grid-column:auto;display:flex;flex-direction:column;gap:14px;min-width:0}.ttt-panel{border:1px solid var(--edge);background:var(--panel);border-radius:20px;padding:18px}.ttt-panel h2{font-size:18px;margin:0 0 14px}.ttt-options{display:flex;gap:8px}.ttt-options button{flex:1;border:1px solid var(--edge);background:#ffffffa6;border-radius:10px;min-height:42px;font-size:13px;font-weight:600;display:grid;place-items:center}.dark .ttt-options button{background:#ffffff0a}.ttt-options button.selected{background:var(--accent);color:white;border-color:#69a98a}.ttt-primary{display:flex;align-items:center;justify-content:center;gap:9px;background:var(--accent);color:white;border:0;border-radius:12px;min-height:44px;padding:10px 18px;font-weight:700}.ttt-primary svg{width:18px;height:18px;fill:currentColor}#new-game{width:100%;margin-top:14px}.ttt-mark{width:30px;height:30px;display:block;fill:none;stroke:currentColor;stroke-width:7;stroke-linecap:round}.ttt-mark.x{color:var(--x)}.ttt-mark.o{color:var(--o)}.ttt-mark.draw{color:var(--muted)}.ttt-stats{display:flex;justify-content:space-around;text-align:center}.ttt-stats>div{display:grid;justify-items:center;gap:8px;flex:1}.ttt-stats strong{font-size:25px;font-variant-numeric:tabular-nums}.ttt-panel small{font-size:12px;color:var(--muted)}#reset-stats{display:block;width:100%;background:#8881;border:1px solid var(--edge);border-radius:8px;padding:8px;margin:16px 0;color:var(--muted);font-size:12px}.ttt-panel hr{border:0;border-top:1px solid var(--edge);margin:16px 0}.ttt-status{display:flex;align-items:center;gap:12px;min-height:52px}.ttt-status strong,.ttt-status small{display:block}.ttt-status strong{font-size:15px;margin-bottom:5px}.ttt-status small{line-height:1.4}.ttt-surface{display:grid;place-items:center;border:1px solid var(--edge);border-radius:22px;background:var(--panel);padding:25px;min-width:0;min-height:0}#ttt-board{width:min(100%,680px);aspect-ratio:1;display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:repeat(3,minmax(0,1fr));gap:12px}.ttt-cell{display:grid;place-items:center;aspect-ratio:1;min-width:0;border:1.4px solid var(--edge);border-radius:14px;background:#ffffffb8;padding:0;touch-action:manipulation}.dark .ttt-cell{background:#263033}.ttt-cell .ttt-mark{width:66%;height:66%;stroke-width:7;animation:ttt-pop .16s ease-out}.ttt-cell.won{box-shadow:inset 0 0 0 3px var(--win-color)}.ttt-cell:disabled{opacity:1}.ttt-page dialog{background:var(--panel);color:var(--text);max-height:85dvh;overflow:auto}.ttt-page dialog p{line-height:1.6;color:var(--muted)}.dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:24px}.dialog-actions button{border:0;border-radius:10px;padding:12px 18px}.dialog-actions #cancel{background:#8882;color:inherit}.sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0,0,0,0)}.sound-option{display:flex;gap:10px;align-items:center}.sound-option input{width:18px;height:18px;accent-color:var(--accent)}@keyframes ttt-pop{from{opacity:.3;transform:scale(.8)}to{opacity:1;transform:scale(1)}}
@media(min-width:1000px){.ttt-page{height:100dvh;min-height:620px;display:grid;grid-template-rows:66px minmax(0,1fr)}.ttt-page header{height:66px}.ttt-layout{height:100%}.ttt-surface{height:100%}#ttt-board{width:min(100%,680px,calc(100dvh - 158px));}.ttt-sidebar{overflow:auto}}
@media(max-width:999px){.ttt-layout{display:flex;flex-direction:column;padding:14px;gap:14px}.ttt-sidebar{display:grid;grid-template-columns:1fr 1fr;gap:10px}.ttt-sidebar>section:last-child{grid-column:1/-1}.ttt-panel{padding:14px}.ttt-stats{float:left;width:45%}.ttt-stats .ttt-mark{width:22px;height:22px}.ttt-stats strong{font-size:20px}#reset-stats{width:50%;margin:0 0 10px auto}.ttt-panel hr{display:none}.ttt-status{padding-left:15px}.ttt-surface{padding:18px}#ttt-board{max-width:600px}.ttt-options button{font-size:12px}.ttt-page .header-inner{padding:0 16px}}
@media(max-width:430px){.ttt-layout{padding:10px}.ttt-panel{padding:12px}.ttt-options{gap:5px}.ttt-options button{font-size:11px}.ttt-panel h2{font-size:16px}.ttt-status small{font-size:10px}.ttt-status{gap:6px;padding-left:8px}.ttt-status .ttt-mark{width:23px}.ttt-surface{padding:12px}#ttt-board{gap:8px}}
@media(prefers-reduced-motion:reduce){.ttt-cell .ttt-mark{animation:none}}

.ttt-side-row{display:contents}#ttt-mobile-status-title{display:none}
.ttt-mobile-bar,#ttt-mobile-thinking{display:none}
#ttt-settings-dialog{max-width:420px;width:calc(100% - 28px);padding:20px}.mobile-settings-heading{display:flex;align-items:center;justify-content:space-between;gap:16px;margin-bottom:18px}.mobile-settings-heading h2{margin:0;font-size:22px}.mobile-settings-heading button{border:0;background:none;color:inherit;font-size:28px;padding:4px 8px}.mobile-settings-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:14px 0;border-top:1px solid var(--edge);font-size:15px}.mobile-settings-row button,.mobile-settings-links button,.mobile-settings-links a{border:1px solid var(--edge);background:var(--panel);color:inherit;border-radius:10px;padding:10px 16px;font-weight:600}.mobile-settings-row button.selected,#ttt-mobile-sound[aria-pressed=true]{background:var(--accent);color:white}.mobile-theme-options{display:flex;gap:6px}.mobile-settings-links{display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:12px}.mobile-settings-links a{text-align:center;text-decoration:none;font-size:13px}
@media(max-width:600px){
 .ttt-page{height:var(--ttt-viewport-height,100dvh);min-height:0;min-width:0;-webkit-text-size-adjust:100%;--panel:#f4f6f1;--edge:#d7dfd9;background:#edf1ec}
 .ttt-page.dark{--panel:#1d2224;--edge:#303637;--muted:#989e9d;background:#141819}
 .ttt-page>header{display:none}
 .ttt-page .ttt-mobile-bar{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;flex:none;min-height:64px;padding:8px max(12px,env(safe-area-inset-right)) 8px max(12px,env(safe-area-inset-left));border-bottom:1px solid var(--edge);background:var(--panel)}
 .dark .ttt-mobile-bar{background:#191e20}
 .ttt-mobile-bar h1{font-size:20px;line-height:1.2;font-weight:700;letter-spacing:0;margin:0}
 .ttt-back{display:inline-flex;align-items:center;gap:5px;width:max-content;min-height:44px;color:inherit;text-decoration:none;font-size:17px}.ttt-back svg{width:17px;height:24px;fill:none;stroke:currentColor;stroke-width:2.6;stroke-linecap:round;stroke-linejoin:round}
 #ttt-settings{justify-self:end;display:grid;place-items:center;width:44px;height:44px;border:0;padding:8px;background:none;color:inherit}#ttt-settings svg{width:28px;height:28px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}

 .ttt-page .ttt-layout{display:flex;flex-direction:column;flex:1;min-height:0;width:100%;margin:0;gap:8px;padding:12px max(11px,env(safe-area-inset-right)) max(24px,env(safe-area-inset-bottom)) max(11px,env(safe-area-inset-left))}
 .ttt-sidebar{display:contents}.ttt-sidebar>.ttt-panel:nth-child(1){order:1;display:grid;grid-template-columns:56px minmax(0,1fr);align-items:center;gap:2px;flex:none;min-height:48px;padding:4px 9px;border-radius:16px}
 .ttt-panel h2{font-size:13px;margin:0;font-weight:600;line-height:1.3;letter-spacing:0}.ttt-options{gap:5px;min-width:0}.ttt-page .ttt-options button{min-width:0;height:38px;min-height:38px;padding:4px 2px;font-size:13px;border-radius:11px;background:transparent;white-space:nowrap}.ttt-page .ttt-options button.selected{background:var(--accent);border-color:#32a35b;box-shadow:inset 0 0 0 1px #ffffff10}
 .ttt-sidebar>.ttt-panel:nth-child(2){display:contents}.ttt-side-row{order:2;display:grid;grid-template-columns:56px minmax(0,1fr);align-items:center;gap:2px;min-height:48px;flex:none;padding:4px 9px;border:1px solid var(--edge);border-radius:16px;background:var(--panel)}.ttt-side-row:has(#sides[hidden]){display:none}.ttt-options .ttt-mark{width:31px;height:31px;stroke-width:10px}
 .ttt-page #new-game{order:3;flex:none;margin:0;width:100%;height:48px;min-height:48px;font-size:17px;border-radius:15px;padding:0 12px}
 .ttt-page .ttt-surface{order:4;flex:1;min-height:0;height:auto;width:100%;position:relative;padding:8px;margin:12px 0;border-radius:24px}
 .ttt-page #ttt-board{width:min(100%,var(--ttt-board-size,100%));max-width:100%;gap:10px;min-height:0}.ttt-cell{border-radius:15px;border:1px solid var(--edge);background:#e4eae6}.dark .ttt-cell{background:#252e32;box-shadow:inset 0 0 0 1px #ffffff05}.ttt-cell .ttt-mark{stroke-width:9px}
 .ttt-sidebar>.ttt-panel:nth-child(3){order:5;flex:none;display:flex;flex-direction:column;gap:0;padding:8px 10px;border-radius:18px;width:100%;grid-column:auto}.ttt-sidebar>.ttt-panel:nth-child(3)>h2{display:none}
 .ttt-page .ttt-status{order:1;min-height:24px;gap:8px;padding:0;width:100%}.ttt-status .ttt-mark{width:20px;height:20px;stroke-width:11px}.ttt-status>div{display:flex;align-items:center;gap:7px;flex:1;min-width:0;justify-content:space-between}
 .ttt-page #status-title{display:none}.ttt-page #ttt-mobile-status-title{display:block;font-size:12px;color:var(--muted);margin:0;font-weight:500;white-space:nowrap}.ttt-page #status-detail{font-size:11px;line-height:1.25;text-align:right;min-width:0}
 .ttt-page .ttt-panel hr{display:block;order:2;border:0;border-top:1px solid var(--edge);margin:7px 0 8px}
 .ttt-page #stats{order:3;float:none;width:100%;display:flex;min-height:55px;align-items:center}.ttt-stats>div{gap:6px;min-width:0}.ttt-stats>div+div{border-left:1px solid var(--edge)}.ttt-stats small{display:none}.ttt-page .ttt-stats .ttt-mark{width:22px;height:22px;stroke-width:12px}.ttt-page .ttt-stats strong{font-size:22px;line-height:1.15}
 .ttt-page #reset-stats{order:6;flex:none;width:100%;height:41px;min-height:41px;padding:0 10px;margin:0;border-radius:14px;font-size:14px;color:var(--text);background:#8881}
 .ttt-page .dialog-actions{gap:8px}.ttt-page .dialog-actions button{font-size:14px;min-height:44px;padding:10px 13px}
}
@media(max-width:600px) and (max-height:760px){
 .ttt-page .ttt-mobile-bar{min-height:52px;padding-top:4px;padding-bottom:4px}.ttt-page .ttt-layout{gap:6px;padding-top:8px;padding-bottom:max(12px,env(safe-area-inset-bottom))}.ttt-sidebar>.ttt-panel:nth-child(1),.ttt-side-row{min-height:40px;padding-top:3px;padding-bottom:3px}.ttt-page .ttt-options button{height:32px;min-height:32px}.ttt-options .ttt-mark{width:27px;height:27px}.ttt-page #new-game{height:40px;min-height:40px}.ttt-page .ttt-surface{margin:8px 0;padding:7px;border-radius:22px}.ttt-page #ttt-board{gap:8px}.ttt-sidebar>.ttt-panel:nth-child(3){padding:6px 9px}.ttt-page .ttt-status{min-height:21px}.ttt-page .ttt-panel hr{margin:5px 0 6px}.ttt-page #stats{min-height:47px}.ttt-page .ttt-stats strong{font-size:20px}.ttt-page #reset-stats{height:36px;min-height:36px}
}
@media(max-width:350px){.ttt-page #status-detail{font-size:10px}.ttt-status>div{gap:4px}.ttt-page #ttt-mobile-status-title{font-size:11px}.ttt-mobile-bar h1{font-size:18px}.ttt-back{font-size:16px}}
/* Keep the winning line visible above phone cell decoration, including dark mode. */
@media(max-width:600px){
 .ttt-page .ttt-cell.won{border-color:var(--win-color);box-shadow:inset 0 0 0 3px var(--win-color);animation:ttt-winning-cell .45s ease-in-out 3}
 .ttt-page .ttt-cell.won .ttt-mark{animation:ttt-winning-mark .45s ease-in-out 3}
 @keyframes ttt-winning-cell{0%,100%{box-shadow:inset 0 0 0 3px var(--win-color)}50%{box-shadow:inset 0 0 0 6px var(--win-color)}}
 @keyframes ttt-winning-mark{0%,100%{transform:scale(1)}50%{transform:scale(1.1)}}
}
@media(max-width:600px) and (prefers-reduced-motion:reduce){.ttt-page .ttt-cell.won,.ttt-page .ttt-cell.won .ttt-mark{animation:none}}
