.tt { --tt-x: #55d6ff; --tt-o: #ffd166; --tt-xr: 85, 214, 255; --tt-or: 255, 209, 102;
  max-width: 640px; margin: 0 auto; padding: 8px 6px 14px; color: #dfe9ff; display: flex; flex-direction: column; gap: 12px;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.tt [hidden] { display: none !important; }
.tt button { font-family: inherit; touch-action: manipulation; }
.tt-panel { display: flex; flex-direction: column; gap: 10px; }
.tt-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tt-modes { display: inline-flex; background: #0b1328; border: 1px solid #1c2b4a; border-radius: 12px; padding: 3px; gap: 2px; }
.tt-mode { min-height: 38px; padding: 0 16px; border: 0; border-radius: 9px; background: transparent; color: #8aa3c4; font-weight: 700; font-size: 14px; cursor: pointer; transition: background .2s, color .2s; }
.tt-mode[aria-selected="true"] { background: #1c2b4a; color: #fff; box-shadow: 0 1px 0 rgba(255,255,255,0.06) inset; }
@media (hover: hover) { .tt-mode:hover:not([aria-selected="true"]) { color: #dfe9ff; } }
.tt-mode:focus-visible, .tt-ibtn:focus-visible, .tt-btn:focus-visible { outline: 2px solid #55d6ff; outline-offset: 2px; }
.tt-ibtn { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 12px; border: 1px solid #1c2b4a; background: #0b1328; color: #dfe9ff; cursor: pointer; padding: 0; }
.tt-ibtn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
@media (hover: hover) { .tt-ibtn:hover { border-color: #55d6ff; } }
.tt-opts { display: flex; gap: 8px; }
.tt-opts label { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; font-weight: 600; color: #8aa3c4; letter-spacing: .02em; }
.tt-opts select { width: 100%; min-height: 36px; background: #0b1328; color: #dfe9ff; border: 1px solid #1c2b4a; border-radius: 8px; padding: 4px 8px; font-size: 14px; font-family: inherit; cursor: pointer; }
.tt-opts select:focus-visible { outline: 2px solid #55d6ff; outline-offset: 1px; }

/* scoreboard: also shows whose turn it is */
.tt-score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; }
.tt-tile { position: relative; display: flex; align-items: center; gap: 8px; min-width: 0; background: #0b1328; border: 1px solid #1c2b4a; border-radius: 12px; padding: 7px 12px; transition: border-color .25s, box-shadow .25s; }
.tt-tile b { margin-left: auto; font-size: 20px; line-height: 1; color: #fff; font-variant-numeric: tabular-nums; }
.tt-tile-o { flex-direction: row-reverse; } .tt-tile-o b { margin: 0 auto 0 0; }
.tt-tile-d { flex-direction: column; justify-content: center; gap: 2px; padding: 5px 14px; }
.tt-tile-d b { margin: 0; font-size: 16px; color: #8aa3c4; }
.tt-tile-d .tt-tname { font-size: 11px; }
.tt-tname { font-size: 13px; font-weight: 700; color: #8aa3c4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tt-tmark { flex: none; width: 24px; height: 24px; }
.tt-tmark svg { width: 100%; height: 100%; display: block; fill: none; stroke-width: 13; stroke-linecap: round; }
.tt-tile-x path { stroke: var(--tt-x); } .tt-tile-o circle { stroke: var(--tt-o); }
.tt-tile::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px; border-radius: 3px; background: currentColor; opacity: 0; transform: scaleX(.3); transition: opacity .25s, transform .3s cubic-bezier(.2,.8,.2,1); }
.tt-tile-x { color: var(--tt-x); } .tt-tile-o { color: var(--tt-o); }
.tt-tile.tt-turn { border-color: rgba(var(--tt-xr), .5); } .tt-tile-o.tt-turn { border-color: rgba(var(--tt-or), .5); }
.tt-tile.tt-turn::after { opacity: 1; transform: none; }
.tt-tile.tt-turn .tt-tname { color: #dfe9ff; }
.tt-tile.tt-won { box-shadow: 0 0 0 1px rgba(var(--tt-xr), .6), 0 0 22px rgba(var(--tt-xr), .25); } .tt-tile-o.tt-won { box-shadow: 0 0 0 1px rgba(var(--tt-or), .6), 0 0 22px rgba(var(--tt-or), .25); }
.tt-tile.tt-won b { animation: tt-bump .5s cubic-bezier(.2,1.6,.4,1); }
@keyframes tt-bump { 40% { transform: scale(1.35); } }

/* board */
.tt-boardwrap { display: flex; justify-content: center; min-width: 0; min-height: 0; }
.tt-board { position: relative; width: min(100%, 440px, max(280px, calc(100vh - 330px))); aspect-ratio: 1; border-radius: 20px; background: radial-gradient(120% 90% at 30% 15%, #0f1a36 0%, #0a1229 55%, #070d1f 100%); border: 1px solid #1c2b4a; box-shadow: 0 18px 40px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.03);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; outline: none; }
.tt-board.tt-ult { width: min(100%, 600px, max(320px, calc(100vh - 330px))); border-radius: 16px; }
.tt-board * { touch-action: none; }
.tt-grid, .tt-winsvg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.tt-grid path, .tt-winsvg path, .tt-mark path, .tt-sline path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.tt-grid path { stroke: #2d4775; stroke-width: 5; }
.tt-ult .tt-grid .tt-gs { stroke: #22375c; stroke-width: 3.5; }
.tt-ult .tt-grid .tt-gb { stroke: #3e5d8e; stroke-width: 8; }
.tt-winsvg { z-index: 4; }
.tt-small { position: absolute; pointer-events: none; z-index: 3; }
.tt-small .tt-sline { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.tt-sline path { stroke-width: 6; opacity: .5; }
.tt-zone { position: absolute; border-radius: 14px; transition: background-color .3s, box-shadow .3s; pointer-events: none; }
.tt-zone.tt-on { --zc: var(--tt-xr); background: rgba(var(--zc), .09); box-shadow: inset 0 0 0 2px rgba(var(--zc), .55), 0 0 22px rgba(var(--zc), .16); }
.tt-turn-o .tt-zone.tt-on { --zc: var(--tt-or); }
.tt-zone.tt-on.tt-any { background: rgba(var(--zc), .045); box-shadow: inset 0 0 0 1.5px rgba(var(--zc), .28); }
.tt-zone.tt-wonx { background: rgba(var(--tt-xr), .06); } .tt-zone.tt-wono { background: rgba(var(--tt-or), .06); }
.tt-zone.tt-shake { animation: tt-shake .32s; }

.tt-cell { position: absolute; z-index: 2; padding: 0; margin: 0; border: 0; background: transparent; border-radius: 14px; color: inherit; cursor: default; transition: background-color .15s; }
.tt-ult .tt-cell { border-radius: 8px; }
.tt-live .tt-cell.tt-can { cursor: pointer; }
.tt-cell:focus { outline: none; }
.tt-cell:focus-visible { box-shadow: inset 0 0 0 3px #55d6ff; }
.tt-cell.tt-last { background: rgba(255,255,255,0.045); }
.tt-cell.tt-press.tt-can { background: rgba(255,255,255,0.08); }
.tt-cell.tt-pend { background: rgba(var(--tt-xr), .06); }
.tt-cell.tt-hint { box-shadow: inset 0 0 0 3px var(--tt-o); animation: tt-glow 1s ease-in-out infinite alternate; }
@keyframes tt-glow { to { box-shadow: inset 0 0 0 3px rgba(var(--tt-or), .35); } }
.tt-cell.tt-shake { animation: tt-shake .32s; }
@keyframes tt-shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
/* hover preview of the mark about to be played */
@media (hover: hover) and (pointer: fine) {
  .tt-live .tt-cell.tt-can:hover { background-color: rgba(255,255,255,0.04); }
  .tt-live .tt-cell.tt-can:hover::after { content: ""; position: absolute; inset: 22%; opacity: .22; background: no-repeat center / contain; }
  .tt-live.tt-turn-x .tt-cell.tt-can:hover::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M18 18L82 82M82 18L18 82' stroke='%2355d6ff' stroke-width='12' stroke-linecap='round' fill='none'/%3E%3C/svg%3E"); }
  .tt-live.tt-turn-o .tt-cell.tt-can:hover::after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='36' stroke='%23ffd166' stroke-width='12' fill='none'/%3E%3C/svg%3E"); }
}

/* hand-drawn marks: each stroke is drawn with the pen (stroke-dashoffset on a path of length 1) */
.tt-mark { position: absolute; left: 6%; top: 6%; width: 88%; height: 88%; overflow: visible; pointer-events: none; transition: opacity .35s; }
.tt-mark path { stroke-width: 9.5; }
.tt-ult .tt-cell .tt-mark path { stroke-width: 11; }
.tt-x path { stroke: var(--tt-x); } .tt-o path { stroke: var(--tt-o); }
.tt-x { filter: drop-shadow(0 0 5px rgba(var(--tt-xr), .35)); } .tt-o { filter: drop-shadow(0 0 5px rgba(var(--tt-or), .3)); }
.tt-ult .tt-cell .tt-mark { filter: none; }
.tt-draw path { stroke-dasharray: 1 2; stroke-dashoffset: 1; animation: tt-pen .2s cubic-bezier(.45,.05,.35,1) forwards; }
.tt-x.tt-draw .tt-s2 { animation-delay: .17s; }
.tt-o.tt-draw path { animation-duration: .4s; }
.tt-grid.tt-draw path { animation-duration: .38s; animation-delay: var(--dl, 0ms); }
.tt-big { left: 9%; top: 9%; width: 82%; height: 82%; }
.tt-big path { stroke-width: 10; }
.tt-big.tt-late path { animation-delay: .32s; } .tt-big.tt-x.tt-late .tt-s2 { animation-delay: .5s; }
.tt-sline.tt-draw path { animation-duration: .28s; }
.tt-xl { stroke: var(--tt-x); } .tt-ol { stroke: var(--tt-o); }
.tt-wl { stroke-width: 10; }
.tt-wl-glow { stroke-width: 22; opacity: .3; filter: blur(4px); }
.tt-ult .tt-wl { stroke-width: 24; } .tt-ult .tt-wl-glow { stroke-width: 54; filter: blur(9px); }
.tt-winsvg.tt-draw path { animation-duration: .5s; animation-delay: .38s; }
.tt-winsvg.tt-draw.tt-late path { animation-delay: .85s; }
@keyframes tt-pen { to { stroke-dashoffset: 0; } }
/* finished boards fade back; the winning marks stay bright */
.tt-cell.tt-dead .tt-mark { opacity: .22; }
.tt-over .tt-cell .tt-mark { opacity: .38; }
.tt-over .tt-cell.tt-win .tt-mark { opacity: 1; animation: tt-winpop .5s .5s cubic-bezier(.2,1.6,.4,1) backwards; }
@keyframes tt-winpop { 50% { transform: scale(1.12); } }
.tt-drawn.tt-classic .tt-cell .tt-mark { opacity: .5; }
.tt-over .tt-small .tt-big { opacity: .55; }

/* status and tools */
.tt-foot { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tt-status { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 24px; font-weight: 700; font-size: 16px; color: #fff; text-align: center; }
.tt-sdot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.tt-sd-x { background: var(--tt-x); box-shadow: 0 0 10px rgba(var(--tt-xr), .6); } .tt-sd-o { background: var(--tt-o); box-shadow: 0 0 10px rgba(var(--tt-or), .6); } .tt-sd-n { display: none; }
.tt-thinking { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #55d6ff; animation: tt-pulse .7s infinite alternate; }
@keyframes tt-pulse { to { opacity: .2; } }
.tt-tools { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.tt-btn { min-height: 40px; padding: 0 16px; background: #0b1328; color: #dfe9ff; border: 1px solid #1c2b4a; border-radius: 10px; font-weight: 700; font-size: 14px; cursor: pointer; transition: border-color .15s, background-color .15s; }
@media (hover: hover) { .tt-btn:hover:not(:disabled) { border-color: #55d6ff; } }
.tt-btn:disabled { opacity: .4; cursor: default; }
.tt-btn:active:not(:disabled) { transform: translateY(1px); }
.tt-btn-primary { background: #ffd166; color: #1a1200; border-color: #ffd166; }
@media (hover: hover) { .tt-btn-primary:hover:not(:disabled) { background: #ffe08a; border-color: #ffe08a; } }
.tt-btn-quiet { background: transparent; color: #8aa3c4; }

/* dialogs */
.tt-overlay { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(2,5,14,0.78); }
.tt-dialog { position: relative; width: min(100%, 380px); max-height: min(88vh, 720px); overflow: auto; overscroll-behavior: contain; background: #0d1630; border: 1px solid #22345a; border-radius: 18px; padding: 22px; text-align: center; box-shadow: 0 30px 80px rgba(0,0,0,0.6); animation: tt-pop .22s cubic-bezier(.2,.8,.2,1); }
.tt-dialog:focus { outline: none; }
@keyframes tt-pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.tt-dialog h3 { margin: 0 0 6px; color: #fff; font-size: 22px; letter-spacing: -0.01em; }
.tt-dialog p { margin: 0 0 12px; color: #8aa3c4; line-height: 1.5; }
.tt-dialog .tt-tally { color: #dfe9ff; font-weight: 700; font-variant-numeric: tabular-nums; }
.tt-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.tt-dialog-help { width: min(100%, 470px); text-align: left; user-select: text; -webkit-user-select: text; }
.tt-dialog-help h3 { margin-right: 40px; }
.tt-close { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; border-radius: 10px; background: rgba(255,255,255,0.06); color: #dfe9ff; font-size: 24px; line-height: 1; cursor: pointer; }
.tt-how { border-top: 1px solid #1c2b4a; padding-top: 12px; margin-top: 12px; }
.tt-how h4 { margin: 0 0 6px; color: #fff; font-size: 15px; }
.tt-how p, .tt-how li { font-size: 14px; color: #b4c6e0; }
.tt-how ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.45; }
.tt-how-row { display: flex; gap: 14px; align-items: flex-start; }
.tt-how-svg { width: 118px; flex: none; margin-top: 2px; }
.tt-how-grid path { stroke: #3e5d8e; stroke-width: 3; fill: none; stroke-linecap: round; }
.tt-how-grid .tt-how-thin { stroke: #22375c; stroke-width: 1.5; }
.tt-how-zone rect { fill: rgba(255,209,102,0.12); stroke: rgba(255,209,102,0.7); stroke-width: 2; }
.tt-how-x { stroke: var(--tt-x); stroke-width: 3.5; stroke-linecap: round; fill: none; }
.tt-how-arrow, .tt-how-head { stroke: #ffd166; stroke-width: 2; fill: none; stroke-dasharray: 4 3; stroke-linecap: round; stroke-linejoin: round; }
.tt-how-head { stroke-dasharray: none; }
.tt-how-note { margin: 8px 0 0 !important; font-size: 13px !important; }
.tt-how kbd { display: inline-block; min-width: 20px; padding: 1px 5px; margin: 0 1px; border-radius: 4px; background: #16213a; color: #bfe9ff; font: 600 12px/1.4 inherit; text-align: center; }
.tt-dialog-help .tt-actions { justify-content: flex-start; margin-top: 16px; }

@media (max-width: 420px) {
  .tt { gap: 10px; padding-inline: 2px; }
  .tt-mode { padding: 0 12px; }
  .tt-tile { padding: 6px 9px; gap: 6px; }
  .tt-tname { font-size: 12px; }
  .tt-how-row { flex-direction: column; }
  .tt-how-svg { width: 130px; align-self: center; }
}

/* full screen (.tt-fit, set by game.js inside the site's immersive stage): no page scroll, the board as big as fits */
.tt.tt-fit { max-width: none; width: 100%; height: 100%; margin: 0; padding: 8px; overflow: hidden; gap: 8px; justify-content: center; }
.tt-fit .tt-board, .tt-fit .tt-board.tt-ult { width: var(--tt-bs); flex: none; }
.tt-fit .tt-panel { width: min(100%, 560px); align-self: center; }
.tt-fit .tt-foot { gap: 8px; }
.tt.tt-land { display: grid; grid-template-columns: var(--tt-bs) var(--tt-pw, 260px); grid-template-rows: auto 1fr; column-gap: 18px; row-gap: 10px; justify-content: center; align-content: center; }
.tt-land .tt-boardwrap { grid-column: 1; grid-row: 1 / 3; }
.tt-land .tt-panel { grid-column: 2; grid-row: 1; width: auto; gap: 8px; }
.tt-land .tt-foot { grid-column: 2; grid-row: 2; align-self: end; align-items: stretch; }
.tt-land .tt-opts { flex-direction: column; gap: 6px; }
.tt-land .tt-opts label { flex-direction: row; align-items: center; justify-content: space-between; gap: 8px; }
.tt-land .tt-opts select { width: 62%; min-height: 34px; }
.tt-land .tt-modes { flex: 1 1 auto; } .tt-land .tt-mode { flex: 1 1 0; padding: 0 6px; font-size: 13px; white-space: nowrap; }
.tt-land .tt-tile-x .tt-tname, .tt-land .tt-tile-o .tt-tname { display: none; }
.tt-land .tt-tile b { margin: 0 auto; }
.tt-land .tt-tile-d { justify-content: center; } .tt-land .tt-tile-d b { margin: 0; }
.tt-land .tt-score { grid-template-columns: 1fr 1fr; }
.tt-land .tt-tile-d { grid-column: 1 / -1; grid-row: 2; flex-direction: row; gap: 8px; padding: 4px 10px; }
.tt-land .tt-status { justify-content: flex-start; text-align: left; font-size: 15px; }
.tt-land .tt-tools { flex-wrap: nowrap; } .tt-land .tt-tools .tt-btn { flex: 1 1 auto; padding: 0 8px; }
@media (max-height: 430px) {
  .tt-land .tt-mode { min-height: 34px; } .tt-land .tt-ibtn { width: 36px; height: 36px; }
  .tt-land .tt-panel { gap: 6px; } .tt-land .tt-opts { gap: 4px; } .tt-land .tt-opts select { min-height: 32px; }
  .tt-land .tt-tile { padding: 5px 9px; } .tt-land .tt-tile b { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  .tt *, .tt *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
  .tt-draw path { stroke-dashoffset: 0; }
}

/* touch screens: every control is at least 40px tall */
@media (pointer: coarse) {
  .tt-mode, .tt-land .tt-mode { min-height: 40px; }
  .tt-ibtn, .tt-land .tt-ibtn { width: 40px; height: 40px; }
  .tt-opts select, .tt-land .tt-opts select { min-height: 40px; }
}
/* the how-to sheet scrolls on small screens: its close button stays in reach */
.tt-dialog-help .tt-close { position: sticky; top: 0; float: right; z-index: 1; margin: -12px -12px 0 8px; background: #1a2644; }
.tt-dialog-help h3 { margin-right: 0; }
@media (pointer: coarse) and (max-height: 430px) {
  .tt.tt-land { row-gap: 6px; }
  .tt-land .tt-tile-d { padding: 2px 10px; }
  .tt-land .tt-foot { gap: 6px; }
}
