/* Tic Tac Toe: a chalkboard. Deep green-teal board, chalk lines, X in coral chalk, O in yellow chalk. */
:root {
    --board: #0f3b3f; --board2: #14484d; --chalk: #f3f6f1; --dim: #b7cdc8; --line: rgba(243,246,241,.22);
    --x: #ff7a6b; --o: #ffd166; --mint: #7ee2b8; --ink: #07302a;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; color: var(--chalk); min-height: 100vh;
    background-color: var(--board);
    background-image: radial-gradient(1100px 600px at 50% -10%, #1d6a70 0%, transparent 70%), radial-gradient(800px 500px at 100% 100%, rgba(0,0,0,.25), transparent 70%);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--o); outline-offset: 2px; }

.site-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 18px; min-height: 46px; background: #003a7a; box-shadow: 0 2px 10px rgba(0,0,0,.25); }
.site-bar a { text-decoration: none; color: #dbe7fb; font-weight: 700; font-size: 14px; }
.site-bar a:hover { color: #fff; }
.site-bar .brand { font-size: 20px; font-weight: 800; color: #fff; letter-spacing: .2px; white-space: nowrap; }
.site-bar nav { display: flex; gap: 4px 18px; flex-wrap: wrap; justify-content: flex-end; }
.site-bar nav a.on { color: #fff; box-shadow: 0 3px 0 var(--mint); }

.shell { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 760px) minmax(0, 1fr); gap: 18px; max-width: 1420px; margin: 0 auto; padding: 14px 12px 0; align-items: start; }
.rail { max-width: 300px; width: 100%; justify-self: center; margin-top: 8px; }
.stage { grid-column: 2; min-width: 0; }

/* ---------- buttons ---------- */
.btn { border: 0; border-radius: 12px; background: var(--chalk); color: var(--ink); font-family: 'Patrick Hand', 'Nunito', sans-serif; font-size: 22px; padding: 9px 20px; box-shadow: 0 4px 0 rgba(0,0,0,.35); transition: transform .08s, box-shadow .08s, filter .15s; text-decoration: none; display: inline-block; text-align: center; line-height: 1.2; }
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.35); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.go { background: var(--mint); width: 100%; font-size: 26px; padding: 11px 16px; }
.btn.sun { background: var(--o); } .btn.coral { background: var(--x); }
.btn.ghost { background: transparent; color: var(--chalk); box-shadow: inset 0 0 0 2px var(--line); }
.btn.small { font-size: 19px; padding: 7px 14px; }
.btn.wa { background: #25d366; color: #05361a; }
.btn.icon { font-size: 18px; }

/* ---------- the start screen ---------- */
.home { text-align: center; padding: 8px 0 20px; }
.logo { display: flex; align-items: center; justify-content: center; gap: 10px; font-family: 'Patrick Hand', sans-serif; font-size: clamp(46px, 9vw, 78px); line-height: 1; text-shadow: 0 4px 0 rgba(0,0,0,.28); }
.logo .mark { width: 1em; height: 1em; fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; }
.logo .mark.x { stroke: var(--x); } .logo .mark.o { stroke: var(--o); }
.logo .mark path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .7s .15s ease forwards; }
.logo .mark path + path { animation-delay: .5s; }
.logo .mark.o path { animation-delay: .9s; }
@keyframes draw { to { stroke-dashoffset: 0; } }
.tag { margin: 8px auto 20px; max-width: 480px; color: var(--dim); font-size: 17px; }
.modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; text-align: left; }
.mode { background: var(--board2); border: 2px dashed var(--line); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 8px 0 rgba(0,0,0,.2); }
.mode h2 { margin: 0; font-family: 'Patrick Hand', sans-serif; font-weight: 400; font-size: 26px; line-height: 1.1; }
.mode .mtext { margin: 0; color: var(--dim); font-size: 14.5px; line-height: 1.5; }
.mode .btn.go { margin-top: auto; }
.field { display: grid; gap: 6px; }
.lab { font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--dim); }
.hint { color: var(--dim); font-size: 13px; line-height: 1.4; min-height: 2.8em; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg button { border: 2px solid var(--line); background: transparent; border-radius: 10px; padding: 8px 4px; font-weight: 800; font-size: 14px; line-height: 1.2; }
.seg button.on { background: var(--chalk); color: var(--ink); border-color: var(--chalk); }
.field input { height: 44px; border: 2px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.18); padding: 0 12px; font-size: 16px; font-weight: 700; }
.field input:focus { border-color: var(--o); outline: none; }
.err { margin: 14px 0 0; background: #ffe3df; color: #8c2314; border-radius: 10px; padding: 10px 14px; font-weight: 700; }

/* ---------- the game ---------- */
.game { display: grid; justify-items: center; gap: 12px; padding: 4px 0 18px; }
.score { display: grid; grid-template-columns: 1fr 0.8fr 1fr; gap: 10px; width: min(100%, 520px); }
.sc { background: var(--board2); border: 2px solid var(--line); border-radius: 14px; padding: 8px 10px; text-align: center; display: grid; gap: 0; transition: border-color .2s, background .2s; }
.sc .who { font-size: 13px; font-weight: 800; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sc b { font-family: 'Patrick Hand', sans-serif; font-weight: 400; font-size: 36px; line-height: 1.1; }
.sc.x b { color: var(--x); } .sc.o b { color: var(--o); }
.sc.turn { border-color: var(--chalk); background: #1b5c62; }
.status { margin: 0; min-height: 34px; font-family: 'Patrick Hand', sans-serif; font-size: 28px; text-align: center; }
.status.win { color: var(--mint); }
.boardwrap { width: min(100%, 480px); }
.board { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); aspect-ratio: 1 / 1; width: 100%; }
.board .grid, .board .winline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.board .grid path { fill: none; stroke: var(--chalk); stroke-width: 6; stroke-linecap: round; opacity: .85; }
.cell { position: relative; border: 0; background: transparent; padding: 10%; border-radius: 12px; z-index: 1; }
.cell:hover:not(.full):not(:disabled) { background: rgba(255,255,255,.06); }
.cell.last { background: rgba(255,255,255,.07); }
.cell svg { width: 100%; height: 100%; display: block; fill: none; stroke-width: 9; stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.cell.X svg { stroke: var(--x); } .cell.O svg { stroke: var(--o); }
.cell.new path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw .32s ease forwards; }
.cell.new path + path { animation-delay: .18s; }
.cell.dim svg { opacity: .35; }
.winline line { stroke: var(--mint); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0; }
.winline.on line { opacity: 1; animation: draw .45s .1s ease forwards; }
.acts { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.acts .btn.go { width: auto; font-size: 24px; padding: 9px 26px; }
.invite { width: min(100%, 520px); background: var(--board2); border: 2px dashed var(--line); border-radius: 16px; padding: 12px 14px; display: grid; gap: 10px; }
.invtitle { margin: 0; font-family: 'Patrick Hand', sans-serif; font-size: 22px; text-align: center; }
.invrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.invrow input { height: 40px; border: 2px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.2); padding: 0 10px; font-size: 14px; min-width: 0; }
.invrow2 { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 50; background: #07302a; color: #fff; padding: 10px 18px; border-radius: 12px; font-weight: 800; box-shadow: 0 6px 20px rgba(0,0,0,.4); max-width: 90vw; text-align: center; }
.netbar { position: fixed; left: 0; right: 0; top: 0; z-index: 60; background: #b91c1c; color: #fff; text-align: center; padding: 6px; font-weight: 800; font-size: 14px; }

/* ---------- ads and the footer ---------- */
.adbox { background: rgba(255,255,255,.06); border-radius: 12px; padding: 6px 8px 8px; overflow: hidden; min-width: 0; }
.adbox small { display: block; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; }
.adbox ins { min-height: 90px; }
.rail .adbox ins { min-height: 250px; }
.adbottom { width: calc(100% - 24px); max-width: 980px; margin: 18px auto 0; }
.site-foot { background: #072427; color: #a9c4bf; text-align: center; padding: 22px 16px 26px; font-size: 14px; line-height: 1.6; }
.site-foot p { margin: 4px 0; }
.site-foot a { color: #fff; text-decoration: none; font-weight: 700; }
.site-foot a:hover { text-decoration: underline; }
.site-foot .copy { font-size: 12px; opacity: .7; }

/* ---------- the text under the start screen ---------- */
.about { background: #f4f7f5; color: #12302b; margin-top: 30px; padding: 30px 16px 40px; }
body.in-game .about { display: none; }
.abwrap { max-width: 760px; margin: 0 auto; }
.about h2 { font-family: 'Patrick Hand', sans-serif; font-weight: 400; font-size: 30px; margin: 26px 0 10px; }
.about h2:first-child { margin-top: 0; }
.about p { line-height: 1.65; }
.feat { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; }
.feat li { background: #fff; border: 2px solid #dbe7e3; border-radius: 12px; padding: 12px 14px; display: grid; gap: 4px; }
.feat li span { color: #3d5a54; font-size: 14.5px; line-height: 1.5; }
details { border: 2px solid #dbe7e3; background: #fff; border-radius: 12px; padding: 10px 14px; margin: 8px 0; }
summary { font-weight: 800; cursor: pointer; }
details p { margin: 8px 0 2px; color: #3d5a54; }
.note { margin-top: 24px; color: #4d6a64; font-size: 14px; }

/* ---------- a tablet and a phone ---------- */
@media (max-width: 1180px) {
    .shell { grid-template-columns: minmax(0, 760px); justify-content: center; }
    .rail { display: none; }
    .stage { grid-column: 1; }
}
@media (max-width: 760px) {
    .modes { grid-template-columns: minmax(0, 1fr); }
    .hint { min-height: 0; }
}
@media (max-width: 480px) {
    .site-bar { padding: 0 12px; }
    .site-bar nav a:first-child { display: none; }
    .status { font-size: 24px; }
    .sc b { font-size: 30px; }
    .btn.go { font-size: 24px; }
}
@media (prefers-reduced-motion: reduce) {
    .logo .mark path, .cell.new path, .winline.on line { animation-duration: .01s; animation-delay: 0s !important; }
    .btn { transition: none; }
}
