/* Tic-Tac-Toe: one-screen play area, themed to match rtwl.fun (body.fx). */
html:has(body.ttt-page), body.ttt-page {
  height: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  color-scheme: dark;
}
body.ttt-page { min-height: 0; touch-action: manipulation; }
body.ttt-page, body.ttt-page * { box-sizing: border-box; }
body.ttt-page .game-wrap {
  width: min(1180px, calc(100% - 16px));
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 auto;
  padding: max(6px, env(safe-area-inset-top)) 0 max(8px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  box-sizing: border-box;
}

.ttt-top { display: flex; align-items: center; gap: 10px 14px; flex-shrink: 0; min-height: 0; }
.ttt-top .back { margin: 0; flex-shrink: 0; color: var(--fx-neon, #3dff8a); font-size: 0.92rem; }
body.ttt-page .ttt-top .gg-head { flex: 1 1 auto; min-width: 0; align-items: center; }
body.ttt-page .ttt-top h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw + 0.4rem, 1.75rem);
  line-height: 1.1;
  filter: drop-shadow(0 0 12px rgba(25, 193, 85, 0.4));
}
body.ttt-page .gg-links a,
body.ttt-page .ttt-boards-btn,
body.ttt-page .ttt-boards-close {
  font-weight: 600;
  color: var(--fx-text, #e6fff0);
  text-decoration: none;
  padding: 4px 12px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--fx-edge, rgba(61, 255, 138, 0.24));
  border-radius: 999px;
  background: rgba(25, 193, 85, 0.08);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
body.ttt-page .gg-links a:hover,
body.ttt-page .gg-links a:focus-visible,
body.ttt-page .ttt-boards-btn:hover,
body.ttt-page .ttt-boards-close:hover {
  background: rgba(25, 193, 85, 0.16);
  border-color: var(--fx-neon, #3dff8a);
  outline: none;
}
body.ttt-page .ttt-boards-btn,
body.ttt-page .ttt-boards-close { display: none; }
body.ttt-page .ttt-boards-close { font-size: 0.9rem; }
.ttt-boards-mask { display: none; }
.ttt-boards-check {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  border: 0; padding: 0; margin: -1px;
}

body.ttt-page .setup { flex-shrink: 0; margin: 0; padding: 8px 12px; }
body.ttt-page .setup .row { flex-wrap: nowrap; gap: 8px 10px; align-items: flex-end; }
body.ttt-page .setup .row > * { flex: 1 1 0; min-width: 0; }
body.ttt-page .setup .row > .btn { flex: 0 0 auto; }
body.ttt-page .setup .field { margin-bottom: 0; color: var(--fx-neon, #3dff8a); font-size: 0.72rem; letter-spacing: 0.1em; }
body.ttt-page input[type=text],
body.ttt-page select {
  margin-top: 3px; padding: 6px 10px; color: var(--fx-text, #e6fff0);
  background: rgba(3, 15, 9, 0.72); border: 1px solid rgba(61, 255, 138, 0.3); border-radius: 12px;
}
body.ttt-page input::placeholder { color: #7fae96; }
body.ttt-page input:focus,
body.ttt-page select:focus { outline: 2px solid var(--fx-neon, #3dff8a); outline-offset: 1px; border-color: var(--fx-neon, #3dff8a); }
body.ttt-page .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; padding: 8px 16px; border-radius: 999px;
  background: linear-gradient(180deg, #3dff8a, #19c155); color: #03140b; box-shadow: 0 0 18px rgba(25, 193, 85, 0.45);
}
body.ttt-page .btn:active { transform: translateY(1px); box-shadow: 0 0 10px rgba(25, 193, 85, 0.35); }
body.ttt-page .btn.ghost {
  background: rgba(25, 193, 85, 0.08); color: var(--fx-text, #e6fff0); box-shadow: none;
  border: 1px solid var(--fx-edge, rgba(61, 255, 138, 0.24));
}
body.ttt-page .btn:disabled { opacity: .5; cursor: default; }

.ttt-layout {
  flex: 1 1 auto; min-height: 0; display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  gap: 10px; align-items: stretch;
}
.ttt-play { display: flex; flex-direction: column; min-height: 0; overflow: hidden; padding: 8px 12px 10px; }
body.ttt-page .ttt-side { min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
body.ttt-page .ttt-side > .panel {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 12px 14px;
  overscroll-behavior: contain; display: flex; flex-direction: column;
}
.ttt-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
body.ttt-page .ttt-side h3 { color: #fff; text-shadow: 0 0 14px rgba(25, 193, 85, 0.35); margin: 0 0 8px; font-size: 1.15rem; }
.ttt-board-table { font-size: 0.9rem; overflow: auto; min-height: 0; flex: 0 1 auto; }
body.ttt-page .ttt-rules { font-size: 0.8rem; line-height: 1.35; margin: 10px 0 0; color: var(--fx-dim, #a6d8bb); }
body.ttt-page .tab { background: rgba(3, 15, 9, 0.55); color: var(--fx-dim, #a6d8bb); border-color: var(--fx-edge, rgba(61, 255, 138, 0.24)); padding: 4px 10px; }
body.ttt-page .tab.on { background: rgba(25, 193, 85, 0.16); color: #7dffb0; border-color: var(--fx-neon, #3dff8a); }
body.ttt-page .muted { color: var(--fx-dim, #a6d8bb); }
body.ttt-page .msg { color: #7dffb0; margin: 4px 0 0; min-height: 1.15em; font-size: 0.95rem; }
body.ttt-page .msg.bad { color: #ffb4ab; }

.hud { display: flex; justify-content: space-around; text-align: center; margin-bottom: 6px; flex-shrink: 0; }
.hud .k { display: block; font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fx-neon, #3dff8a); font-weight: 600; }
.hud .v { font-family: Chango, Georgia, serif; font-size: clamp(1.05rem, 2.2vh, 1.5rem); font-variant-numeric: tabular-nums; color: #fff; }

.ttt-wrap {
  flex: 1 1 auto; min-height: 0; width: 100%;
  display: grid; place-items: center; container-type: size;
}
.b3 {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(6px, 1.6cqi, 10px);
  width: 100%;
  max-width: 420px;
  max-height: 100%;
  aspect-ratio: 1;
}
@supports not (container-type: size) {
  .b3 { width: min(100%, 70vw, calc(100dvh - 16rem)); }
}
.sq {
  aspect-ratio: 1; min-width: 0; min-height: 0; border-radius: 16px;
  background: rgba(3, 15, 9, 0.72);
  border: 2px solid var(--fx-edge, rgba(61, 255, 138, 0.24));
  cursor: pointer;
  font-family: Chango, Georgia, serif;
  font-size: clamp(2rem, 22cqi, 4rem);
  color: var(--fx-text, #e6fff0);
  display: grid; place-items: center;
  transition: background .1s, transform .05s, box-shadow .1s;
}
.sq:hover:not(:disabled) { background: rgba(25, 193, 85, 0.16); border-color: var(--fx-neon, #3dff8a); }
.sq:active:not(:disabled) { transform: scale(.97); }
.sq:disabled { cursor: default; }
.sq.x { color: var(--fx-neon, #3dff8a); text-shadow: 0 0 12px rgba(61, 255, 138, 0.45); }
.sq.o { color: #ffe27a; text-shadow: 0 0 12px rgba(240, 180, 0, 0.4); }
.sq.win { background: var(--fx-neon, #3dff8a); color: #03140b; border-color: #19c155; box-shadow: 0 0 18px rgba(61, 255, 138, 0.55); text-shadow: none; }
.sq:focus-visible { outline: 3px solid var(--fx-neon, #3dff8a); outline-offset: 2px; }

.ttt-foot { flex-shrink: 0; text-align: center; }
.status-line { text-align: center; font-weight: 600; font-size: clamp(0.92rem, 1.8vh, 1.1rem); margin: 6px 0 0; min-height: 1.3em; color: #fff; }
.quip { text-align: center; margin: 0; min-height: 1.2em; color: var(--fx-dim, #a6d8bb); font-style: italic; font-size: 0.92rem; }
.tools { justify-content: center; margin-top: 4px; }
.tools .btn { flex: 0 1 auto; }

@media (min-width: 800px) { body.ttt-page .ggc-fab { right: 20px; } }
@media (max-width: 799px), (orientation: portrait) and (max-width: 899px) {
  .ttt-layout { grid-template-columns: 1fr; }
  body.ttt-page .ttt-boards-btn { display: inline-flex; }
  body.ttt-page .ttt-side {
    display: none; position: fixed;
    inset: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
    z-index: 90; max-width: 420px; margin: 0 auto; overflow: hidden;
  }
  body.ttt-page .ttt-side > .panel {
    background: linear-gradient(160deg, rgba(10, 46, 28, 0.98), rgba(3, 15, 9, 0.98) 55%);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.7), 0 0 30px rgba(25, 193, 85, 0.25);
  }
  #ttt-show-boards:checked ~ .ttt-boards-mask {
    display: block; position: fixed; inset: 0; z-index: 85; background: rgba(0, 0, 0, 0.62); cursor: pointer;
  }
  body.ttt-page .ttt-boards-close { display: inline-flex; }
  #ttt-show-boards:checked ~ .ttt-layout .ttt-side { display: flex; }
  #ttt-show-boards:checked ~ .ttt-top .ttt-boards-btn { border-color: var(--fx-neon, #3dff8a); background: rgba(25, 193, 85, 0.2); }
}
@media (max-width: 640px) {
  .back-full { display: none; }
  body.ttt-page .setup .row { flex-wrap: wrap; }
  body.ttt-page .setup .row > * { flex: 1 1 calc(50% - 10px); }
  body.ttt-page .setup .row > .btn { flex: 1 1 100%; }
  body.ttt-page .ttt-top { flex-wrap: wrap; gap: 4px 8px; }
  body.ttt-page .ttt-top .gg-head { display: contents; }
  body.ttt-page .ttt-top h1 { font-size: 1.12rem; flex: 1 1 auto; min-width: 0; }
  body.ttt-page .ttt-top .gg-links { width: 100%; justify-content: center; flex-wrap: nowrap; gap: 6px; }
  body.ttt-page .gg-links a, body.ttt-page .ttt-boards-btn { min-height: 30px; padding: 3px 10px; font-size: 0.88rem; }
  body.ttt-page .game-wrap { width: calc(100% - 12px); gap: 6px; }
}
@media (max-height: 520px) {
  body.ttt-page .game-wrap { padding-top: 4px; padding-bottom: 4px; gap: 4px; }
  body.ttt-page .setup { padding: 4px 10px; }
  body.ttt-page .setup .field { font-size: 0; letter-spacing: 0; }
  body.ttt-page .setup input, body.ttt-page .setup select { padding: 4px 8px; font-size: 0.88rem; letter-spacing: 0; text-transform: none; }
  .hud { margin-bottom: 2px; }
  .hud .v { font-size: 1rem; }
  .quip { display: none; }
  .ttt-rules { display: none; }
  .status-line { margin-top: 2px; font-size: 0.88rem; }
  body.ttt-page .ttt-top h1 { font-size: 1.05rem; }
  body.ttt-page .ttt-play { padding: 4px 8px 6px; }
  body.ttt-page .btn { padding: 6px 12px; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body.ttt-page .setup .row { flex-wrap: nowrap; }
  body.ttt-page .setup .row > * { flex: 1 1 0; }
  body.ttt-page .setup .row > .btn { flex: 0 0 auto; }
  .ttt-layout { grid-template-columns: minmax(0, 1fr) minmax(180px, 230px); }
  body.ttt-page .ttt-side { display: flex; position: static; inset: auto; max-width: none; margin: 0; }
  body.ttt-page .ttt-boards-btn, body.ttt-page .ttt-boards-close { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .sq:active:not(:disabled) { transform: none; }
  body.ttt-page .btn:active { transform: none; }
}