@import url('willow-scrollbar.css');
/* Tic-tac-toe live class */
html { box-sizing: border-box; }
*, *::before, *::after { box-sizing: inherit; }

.tt-join-wrap { max-width: 32rem; }
.tt-join-card {
    background: #fff; border: 1px solid #e2e8f0; border-radius: 1.2rem; padding: 1.2rem 1.15rem 1.3rem;
    box-shadow: 0 16px 40px rgba(0, 26, 114, 0.08);
}
.tt-kicker { margin: 0; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: #001A72; }
.tt-join h2, .tt-panel h2, .tt-done h2 { margin: 0.25rem 0 0.6rem; color: #0f172a; font-size: 1.6rem; }
.tt-join-form { display: grid; gap: 0.35rem; }
.tt-join-form label { font-weight: 800; font-size: 0.88rem; margin-top: 0.45rem; }
.tt-join-form input, .tt-rename input {
    width: 100%; border: 1px solid #cbd5e1; border-radius: 0.75rem; padding: 0.7rem 0.8rem; font: inherit; background: #fff;
}
.tt-done-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.55rem; }
.tt-done-actions[hidden] { display: none !important; }
.tt-again.is-quiet { background: #fff; color: #001A72; box-shadow: inset 0 0 0 2px #001A72; }
.tt-again:disabled { opacity: 0.55; cursor: default; }
a.tt-again { display: inline-block; text-decoration: none; text-align: center; }
a.tt-again[hidden] { display: none !important; }
.tt-join-submit, .tt-rename button, .tt-pair-tools button, .tt-again {
    margin-top: 0.7rem; border: 0; border-radius: 0.8rem; background: #001A72; color: #fff;
    font-weight: 800; padding: 0.75rem 1rem; cursor: pointer; font: inherit;
}
.tt-pair-tools button:disabled { opacity: 0.45; cursor: default; }
.tt-hint, .tt-lead { color: #475569; line-height: 1.45; }
.tt-error { color: #b91c1c; font-weight: 700; }
.tt-theme-btn {
    border: 1px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.14); color: #fff;
    border-radius: 999px; padding: 0.4rem 0.75rem; font-weight: 800; cursor: pointer;
}
html[data-tt-theme="dark"] .tt-theme-btn { color: #e5e7eb; }

.tt-play-page {
    margin: 0; min-height: 100dvh; color: #0f172a;
    background:
        radial-gradient(ellipse at top, rgba(255, 215, 0, 0.22), transparent 46%),
        linear-gradient(180deg, #f8fafc 0%, #e8eefc 100%);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
.tt-play-page button, .tt-play-page input { font-family: inherit; }
.tt-play-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    padding: 0.65rem 0.9rem; background: #001A72; color: #fff;
}
.tt-play-brand { display: inline-flex; align-items: center; gap: 0.45rem; font-weight: 800; min-width: 0; color: inherit; text-decoration: none; }
.tt-play-brand span { overflow-wrap: anywhere; }
.tt-play-brand img { width: 2rem; height: 2rem; border-radius: 999px; object-fit: cover; }
#tt-play, #tt-solo {
    min-height: calc(100dvh - 3.4rem); display: flex; flex-direction: column;
    padding: 0.85rem 0.9rem 1rem; max-width: 40rem; margin: 0 auto; width: 100%;
}
.tt-panel { text-align: center; }
.tt-roster { list-style: none; margin: 0.8rem 0 0; padding: 0; display: grid; gap: 0.45rem; }
.tt-roster button, .tt-roster li {
    width: 100%; text-align: left; border: 1px solid #e2e8f0; background: #fff; color: inherit;
    border-radius: 0.9rem; padding: 0.75rem 0.85rem; font-weight: 800; font: inherit;
}
.tt-roster button { cursor: pointer; }
.tt-roster button.is-pick { border-color: #001A72; box-shadow: 0 0 0 3px rgba(0, 26, 114, 0.15); }
.tt-roster button.is-wants { background: #fffbeb; }
.tt-roster .tt-tag { float: right; font-size: 0.75rem; color: #64748b; font-weight: 800; }
.tt-switch {
    align-self: center; margin: 0.55rem auto 0; display: inline-flex; border: 0; border-radius: 999px;
    background: #fff; color: #001A72; font: inherit; font-weight: 800; padding: 0.45rem 0.95rem;
    box-shadow: inset 0 0 0 2px #001A72; cursor: pointer;
}
.tt-switch.is-offer { background: #fffbeb; }
.tt-switch[hidden] { display: none !important; }
#tt-switch-panel .tt-switch { margin-top: 0.9rem; }

.tt-match { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.tt-series {
    display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 0.45rem; align-items: center;
}
.tt-side { min-width: 0; }
.tt-side-name { margin: 0; font-weight: 800; overflow-wrap: anywhere; }
.tt-side.is-them { text-align: right; }
.tt-side-mark { margin: 0; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; color: #64748b; }
.tt-series-score { text-align: center; }
.tt-series-score p { margin: 0; font-size: clamp(1.6rem, 6vw, 2.4rem); font-weight: 800; color: #001A72; font-variant-numeric: tabular-nums; }
.tt-series-score span { display: block; font-size: 0.75rem; font-weight: 800; color: #64748b; }
.tt-turn { margin: 0.55rem 0 0.15rem; text-align: center; font-weight: 800; font-size: 1.05rem; }
.tt-turn.is-you { color: #001A72; }
.tt-clock { margin: 0; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; color: #b45309; }
.tt-board {
    position: relative; width: min(100%, 28rem); max-width: 100%;
    margin: 0.7rem auto 0; aspect-ratio: 1;
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.55rem;
}
.tt-board[data-size="4"] { gap: 0.4rem; width: min(100%, 32rem); }
.tt-board[data-size="5"] { gap: 0.28rem; width: min(100%, 34rem); }
.tt-board[data-size="4"] .tt-cell { border-radius: 0.75rem; }
.tt-board[data-size="5"] .tt-cell { border-radius: 0.5rem; }
.tt-board[data-size="4"] .tt-mark-x,
.tt-board[data-size="4"] .tt-mark-o { width: 52%; height: 52%; }
.tt-board[data-size="5"] .tt-mark-x,
.tt-board[data-size="5"] .tt-mark-o { width: 48%; height: 48%; }
.tt-cell {
    appearance: none; border: 0; border-radius: 1rem; background: #fff; color: #001A72;
    box-shadow: 0 8px 18px rgba(0, 26, 114, 0.08);
    display: flex; align-items: center; justify-content: center; cursor: pointer; padding: 0;
    font-size: clamp(2.4rem, 12vw, 4.4rem);
}
.tt-cell.is-o { color: #b45309; }
.tt-cell.is-locked { cursor: default; }
.tt-cell:focus-visible { outline: 3px solid #FFD700; outline-offset: 2px; }
.tt-mark-x, .tt-mark-o { display: block; }
.tt-mark-x { position: relative; width: 58%; height: 58%; }
.tt-mark-x::before, .tt-mark-x::after {
    content: ""; position: absolute; left: 0; right: 0; top: 46%; height: 0.12em; min-height: 5px;
    background: currentColor; border-radius: 99px; transform-origin: center;
}
.tt-cell.is-fresh .tt-mark-x::before { animation: tt-stroke 0.28s ease forwards; transform: rotate(45deg) scaleX(0); }
.tt-cell.is-fresh .tt-mark-x::after { animation: tt-stroke 0.28s ease 0.05s forwards; transform: rotate(-45deg) scaleX(0); }
.tt-cell:not(.is-fresh) .tt-mark-x::before { transform: rotate(45deg) scaleX(1); }
.tt-cell:not(.is-fresh) .tt-mark-x::after { transform: rotate(-45deg) scaleX(1); }
.tt-mark-o {
    width: 58%; height: 58%; border-radius: 50%; border: 0.12em solid currentColor; min-height: 0;
    border-width: clamp(5px, 1.5vw, 9px);
}
.tt-cell.is-fresh .tt-mark-o { animation: tt-pop 0.28s ease; }
.tt-winline { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 2; }
.tt-winline[hidden], .tt-winline.is-off { display: none !important; }
.tt-winline line { stroke: #FFD700; stroke-width: 8; stroke-linecap: round; }
.tt-board.is-draw .tt-cell { opacity: 0.55; transition: opacity 0.35s ease; }
.tt-board.is-hot { filter: drop-shadow(0 0 0.4rem rgba(0, 26, 114, 0.18)); }
.tt-done-score { margin: 0.2rem 0; font-size: 2.4rem; font-weight: 800; color: #001A72; }
.tt-rename {
    margin-top: auto; display: grid; gap: 0.35rem; padding: 0.85rem; border-radius: 1rem;
    background: #fff; border: 1px solid #e2e8f0;
}
.tt-rename[hidden], .tt-panel[hidden], .tt-match[hidden], .tt-clock[hidden] { display: none !important; }

.tt-host-page {
    margin: 0; min-height: 100dvh; color: #0f172a;
    background: linear-gradient(165deg, #e0f2fe 0%, #eef2ff 45%, #fff7ed 100%);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
.tt-host-page::before {
    content: ""; position: fixed; inset: 0; pointer-events: none;
    background: radial-gradient(circle at 12% 20%, rgba(255,215,0,0.18), transparent 28%);
}
.tt-blob { position: fixed; border-radius: 999px; filter: blur(10px); opacity: 0.45; pointer-events: none; }
.tt-blob-a { width: 16rem; height: 16rem; background: #bfdbfe; top: 12%; left: -4rem; }
.tt-blob-b { width: 14rem; height: 14rem; background: #fde68a; bottom: 8%; right: -3rem; }
.tt-blob-c { width: 10rem; height: 10rem; background: #ddd6fe; top: 40%; right: 18%; }
.tt-host-bar, .tt-host-main { position: relative; z-index: 1; }
.tt-host-btn[hidden],
#tt-lobby-block[hidden],
#tt-pair-block[hidden],
#tt-host-race[hidden] { display: none !important; }
.tt-host-page button, .tt-host-page input { font-family: inherit; }
.tt-host-bar {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.65rem;
    padding: 0.7rem 1rem; background: #001A72; color: #fff;
    position: sticky; top: 0; z-index: 30;
}
.tt-host-actions { position: relative; z-index: 2; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tt-host-brand { display: inline-flex; align-items: center; gap: 0.45rem; color: #fff; text-decoration: none; font-weight: 800; }
.tt-host-brand img { width: 2rem; height: 2rem; border-radius: 999px; }
.tt-host-title { margin: 0; font-size: 1.05rem; flex: 1; min-width: 8rem; }
.tt-host-btn {
    appearance: none; border: 1px solid rgba(255,255,255,0.28); border-radius: 0.7rem;
    padding: 0.5rem 0.75rem; font-weight: 800; cursor: pointer; color: #fff; background: rgba(255,255,255,0.14);
    text-decoration: none; display: inline-flex; align-items: center;
}
.tt-host-btn-start { background: #16a34a; }
.tt-host-btn-end { background: #dc2626; }
.tt-host-btn:disabled { opacity: 0.45; cursor: default; }
.tt-host-main { padding: 1.2rem 1rem 2.4rem; max-width: 72rem; margin: 0 auto; }
#tt-lobby-block { text-align: center; padding-top: 1.6rem; }
.tt-host-label { margin: 0.8rem 0 0.25rem; font-size: 0.75rem; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: #334155; }
.tt-host-url { margin: 0.2rem 0; font-size: clamp(1.45rem, 3.6vw, 2.6rem); font-weight: 800; color: #001A72; line-height: 1.25; overflow-wrap: break-word; }
.tt-host-code {
    display: inline-block; margin: 0.35rem 0 0.6rem; padding: 0.45rem 0.9rem; border-radius: 0.8rem;
    background: #fff; border: 3px solid #001A72; color: #001A72;
    font-family: ui-monospace, Consolas, monospace; font-size: clamp(1.5rem, 3.4vw, 2.2rem); font-weight: 800; letter-spacing: 0.1em;
}
.tt-host-wait { font-weight: 800; color: #001A72; }
.tt-host-note { font-weight: 700; color: #92400e; }
.tt-host-msg { min-height: 1.1rem; font-weight: 700; color: #b91c1c; }
.tt-host-msg.is-ended {
    margin: 0.8rem auto 0; max-width: 40rem; padding: 0.8rem 1rem; border-radius: 0.9rem;
    background: #fff; color: #001A72; border: 2px solid #001A72; text-align: center; font-size: 1.05rem;
}
.tt-host-names, .tt-locked { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.45rem; list-style: none; margin: 0.35rem 0 0; padding: 0; }
.tt-host-names button, .tt-locked li {
    border: 0; border-radius: 999px; background: #fff; color: #0f172a; font-weight: 800;
    padding: 0.45rem 0.8rem; cursor: pointer; box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}
.tt-host-names button.is-on { outline: 3px solid #001A72; }
.tt-host-names button.is-bye { opacity: 0.7; }
.tt-host-names button.is-cpu { box-shadow: inset 0 0 0 2px #001A72; }
.tt-locked li { cursor: default; }
.tt-pair-block {
    margin-top: 0.6rem; padding: 0.9rem; border-radius: 1.1rem; background: rgba(255,255,255,0.72);
    border: 1px solid rgba(255,255,255,0.8);
}
.tt-pair-head h2 { margin: 0; }
.tt-pair-head p { margin: 0.25rem 0 0; color: #475569; }
.tt-pair-tools { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.tt-pair-tools button { margin-top: 0.55rem; }
.tt-rules-edit {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 0.45rem;
    margin: 0.7rem auto 0; width: min(100%, 36rem);
}
.tt-rules-edit[hidden] { display: none !important; }
.tt-rules-edit label { display: inline-flex; align-items: center; gap: 0.4rem; font-weight: 800; color: #001A72; }
.tt-rules-edit input {
    width: 4.4rem; border: 1px solid #cbd5e1; border-radius: 0.7rem; padding: 0.45rem 0.55rem;
    font: inherit; font-weight: 800; background: #fff; color: #0f172a;
}
.tt-rules-edit button {
    border: 0; border-radius: 0.75rem; background: #001A72; color: #fff; font-weight: 800;
    padding: 0.5rem 0.85rem; cursor: pointer;
}
@media (max-width: 720px) {
    .tt-pair-tools, .tt-rules-edit { width: 100%; }
    .tt-pair-tools button, .tt-rules-edit button, .tt-rules-edit label { flex: 1 1 100%; justify-content: center; }
    .tt-rules-edit input { width: 5rem; }
}

.tt-host-race { --tt-zoom: 1; margin-top: 0.8rem; }
.tt-board-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.7rem; align-items: flex-end; margin-bottom: 0.7rem; }
.tt-board-title-row { display: flex; align-items: center; gap: 0.6rem; }
.tt-board-title-row h2 { margin: 0; font-size: 1.45rem; }
.tt-code-chip {
    border: 0; border-radius: 999px; background: #001A72; color: #fff; padding: 0.35rem 0.7rem;
    display: inline-flex; gap: 0.35rem; align-items: center; font-weight: 800; cursor: pointer;
}
.tt-board-tools { display: flex; flex-wrap: wrap; gap: 0.45rem; align-items: center; }
.tt-view-toggle, .tt-zoom { display: inline-flex; align-items: center; background: #fff; border-radius: 999px; padding: 0.2rem; box-shadow: 0 6px 16px rgba(15,23,42,0.06); }
.tt-view-toggle button, .tt-zoom button {
    border: 0; background: transparent; border-radius: 999px; padding: 0.4rem 0.7rem; font-weight: 800; cursor: pointer; color: #334155;
}
.tt-view-toggle button.is-on { background: #001A72; color: #fff; }
.tt-zoom span { min-width: 3.2rem; text-align: center; font-weight: 800; font-size: 0.85rem; }
.tt-zoom button:disabled { opacity: 0.4; cursor: default; }
.tt-table-wrap { background: #fff; border-radius: 1.1rem; overflow: auto; box-shadow: 0 16px 40px rgba(0, 26, 114, 0.08); zoom: var(--tt-zoom, 1); }
.tt-score-table { width: 100%; border-collapse: collapse; font-size: 1.05rem; }
.tt-score-table th { text-align: center; background: #001A72; color: #fff; padding: 0.85rem 0.9rem; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; }
.tt-score-table th:nth-child(2) { text-align: left; }
.tt-score-table th:nth-child(1), .tt-score-table td.tt-rank { width: 3.4rem; }
.tt-score-table th:nth-child(3), .tt-score-table td.tt-series-cell { width: 12rem; }
.tt-score-table th:nth-child(4), .tt-score-table td.tt-board-slot { width: 9rem; }
.tt-score-table th:nth-child(5), .tt-score-table td.tt-record { width: 7.5rem; }
.tt-score-table td { padding: 0.85rem 0.9rem; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
.tt-score-table tr.is-done { background: #ecfdf5; }
.tt-score-table tr.is-first .tt-rank { color: #b45309; }
.tt-rank, .tt-series-cell, .tt-board-slot, .tt-record { text-align: center; }
.tt-rank { font-weight: 800; font-size: 1.15rem; }
.tt-pair-names { font-weight: 800; font-size: 1.25rem; text-align: left; line-height: 1.3; }
.tt-pair-names span { cursor: context-menu; }
.tt-series-cell { font-weight: 800; font-variant-numeric: tabular-nums; }
.tt-series-cell > span { display: block; font-size: 1.55rem; line-height: 1.1; }
.tt-series-cell small { display: block; font-weight: 700; color: #64748b; font-size: 0.78rem; }
.tt-paused { color: #b45309; font-weight: 800; }
.tt-pair-actions { display: flex; flex-wrap: wrap; gap: 0.3rem; justify-content: center; margin-top: 0.35rem; }
.tt-pair-btn {
    border: 0; border-radius: 0.55rem; background: #001A72; color: #fff;
    font: inherit; font-size: 0.75rem; font-weight: 800; padding: 0.28rem 0.5rem; cursor: pointer;
}
.tt-pair-btn.is-resume { background: #b45309; }
.tt-student-card.is-held, .tt-score-table tr.is-held { box-shadow: inset 4px 0 0 #d97706; }
.tt-board.is-paused { outline: 3px solid #d97706; outline-offset: 3px; }
#tt-turn.is-paused { color: #b45309; font-weight: 800; }
.tt-mini {
    width: 6.6rem; aspect-ratio: 1; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; position: relative; margin-inline: auto;
}
.tt-mini[data-size="4"] { grid-template-columns: repeat(4, 1fr); }
.tt-mini[data-size="5"] { grid-template-columns: repeat(5, 1fr); gap: 2px; }
.tt-mini[data-size="4"] i { font-size: 0.85rem; }
.tt-mini[data-size="5"] i { font-size: 0.62rem; border-radius: 0.15rem; }
.tt-mini i {
    display: flex; align-items: center; justify-content: center; background: #f8fafc; border-radius: 0.3rem;
    font-style: normal; font-weight: 800; font-size: 1.15rem; color: #001A72;
}
.tt-mini i.is-o { color: #b45309; }
.tt-mini .tt-winline line { stroke-width: 6; }
.tt-cards-space { display: none; gap: 0.75rem; }
.tt-host-race[data-view="cards"] .tt-table-wrap { display: none; }
.tt-host-race[data-view="cards"] .tt-cards-space { display: grid; grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); zoom: var(--tt-zoom, 1); }
.tt-student-card {
    background: #fff; border-radius: 1.1rem; padding: 1rem 1rem 0.9rem; text-align: center;
    box-shadow: 0 12px 28px rgba(0, 26, 114, 0.08);
}
.tt-student-card .tt-pair-names { text-align: center; }
.tt-student-card .tt-board-slot { width: auto; }
.tt-student-card.is-done { background: #ecfdf5; }
.tt-student-card.is-first { box-shadow: 0 0 0 2px #f59e0b, 0 12px 28px rgba(245, 158, 11, 0.18); }
.tt-student-card h3 { margin: 0.15rem 0; font-size: 1.15rem; }
.tt-student-card h3 span { cursor: context-menu; }
.tt-card-score { margin: 0.15rem 0 0.35rem; font-size: 1.6rem; font-weight: 800; color: #001A72; }
.tt-card-score > span { font-size: 2.1rem; }
.tt-host-page #tt-host-board { display: table-row-group; }

.tt-ctx {
    position: fixed; z-index: 80; min-width: 12.5rem; background: #fff; color: #0f172a;
    border-radius: 0.9rem; box-shadow: 0 18px 40px rgba(15, 23, 42, 0.2); padding: 0.35rem;
}
.tt-ctx[hidden] { display: none !important; }
.tt-ctx-name { margin: 0; padding: 0.45rem 0.6rem 0.2rem; font-weight: 800; }
.tt-ctx button {
    display: block; width: 100%; text-align: left; border: 0; background: transparent;
    border-radius: 0.6rem; padding: 0.5rem 0.6rem; font-weight: 700; cursor: pointer;
}
.tt-ctx button:hover { background: #eef2ff; }
.tt-ctx-danger { color: #b91c1c; }
.tt-code-modal-panel {
    width: min(28rem, 100%); background: #fff; border-radius: 1.4rem; text-align: center; padding: 1.4rem 1.2rem;
    box-shadow: 0 24px 60px rgba(0, 26, 114, 0.25);
}
.tt-code-modal-kicker { margin: 0; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 800; color: #64748b; font-size: 0.78rem; }
.tt-code-modal-url { margin: 0.4rem 0 0.55rem; font-size: clamp(1.35rem, 3.4vw, 2.3rem); font-weight: 800; color: #001A72; line-height: 1.25; overflow-wrap: break-word; }
.tt-code-modal-code { display: inline-block; margin: 0 0 0.8rem; padding: 0.3rem 0.8rem; border-radius: 0.8rem; background: #eef2ff; border: 3px solid #001A72; font-size: clamp(1.45rem, 3.4vw, 2.15rem); font-weight: 800; letter-spacing: 0.1em; color: #001A72; }
.tt-code-modal-panel button { border: 0; border-radius: 0.75rem; background: #001A72; color: #fff; font-weight: 800; padding: 0.6rem 1rem; cursor: pointer; }
.willow-modal-backdrop[hidden] { display: none !important; }
.willow-modal-backdrop {
    position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center;
    padding: 1rem; background: rgba(15, 23, 42, 0.55);
}
.willow-modal-backdrop.hidden { display: none !important; }
.willow-modal-panel {
    width: min(28rem, 100%); background: #fff; color: #0f172a; border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25); display: flex; flex-direction: column;
}
.willow-modal-header { padding: 1.25rem 1.5rem 0.4rem; }
.willow-modal-header h3 { margin: 0; font-size: 1.25rem; font-weight: 800; }
.willow-modal-body { padding: 0.4rem 1.5rem 1rem; }
.willow-modal-body p { margin: 0; color: #475569; line-height: 1.5; }
.willow-modal-footer { display: flex; justify-content: flex-end; gap: 0.6rem; padding: 0.9rem 1.5rem 1.2rem; border-top: 1px solid #e5e7eb; }
.willow-modal-footer button { border: 0; border-radius: 0.7rem; padding: 0.65rem 1rem; font-weight: 800; cursor: pointer; }
#willow-confirm-cancel { background: #e2e8f0; color: #0f172a; }
#willow-confirm-ok { background: #001A72; color: #fff; }
#willow-confirm-ok.is-danger { background: #dc2626; }

dialog.ah-dialog { width: min(96vw, 42rem); max-width: min(96vw, 42rem); max-height: 92dvh; margin: auto; border: 0; border-radius: 1.2rem; padding: 0; background: transparent; overflow: hidden; }
dialog.ah-dialog[open] { display: block; }
.ah-dialog::backdrop { background: rgba(15, 23, 42, 0.55); }
.ah-dialog:not([open]) { display: none; }
.ah-panel { background: #fff; color: #0f172a; border-radius: 1.2rem; padding: 1.1rem 1.2rem 1rem; max-height: 92dvh; overflow: auto; }
.ah-panel h3 { margin: 0; font-size: 1.25rem; }
.ah-lead, .ah-empty, .ah-meta { color: #64748b; font-size: 0.92rem; }
.ah-tools { display: flex; gap: 0.4rem; margin-top: 0.55rem; }
.ah-tools button, .ah-mini { border: 0; border-radius: 0.6rem; background: #e2e8f0; color: #0f172a; font-weight: 800; font-size: 0.78rem; padding: 0.35rem 0.55rem; cursor: pointer; }
.ah-tools button[disabled] { opacity: 0.45; cursor: default; }
.ah-item { display: flex; align-items: center; gap: 0.45rem; margin-top: 0.45rem; }
.ah-row, .ah-score { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; width: 100%; text-align: left; border: 1px solid #e5e7eb; background: #fff; border-radius: 0.8rem; padding: 0.65rem 0.75rem; color: inherit; }
.ah-row { cursor: pointer; flex: 1; }
.ah-score { margin-top: 0.45rem; min-width: 0; }
.ah-score > span:first-child { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }
.ah-mark { flex: 0 0 auto; text-align: right; }
.ah-count { color: #001A72; font-weight: 800; white-space: nowrap; }
.ah-actions { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 0.45rem; margin-top: 0.9rem; }
.ah-actions button { border-radius: 0.7rem; padding: 0.55rem 0.8rem; border: 1px solid #d1d5db; background: #fff; font-weight: 700; }
#ah-close { background: #001A72; color: #fff; border-color: #001A72; }
.ah-export { display: flex; flex-wrap: wrap; gap: 0.45rem; margin-right: auto; }
.ah-export a { display: inline-flex; align-items: center; border-radius: 0.7rem; padding: 0.5rem 0.75rem; border: 1px solid #c7d2fe; background: #eef2ff; color: #001A72; font-weight: 800; font-size: 0.82rem; line-height: 1.2; text-decoration: none; white-space: nowrap; }
.ah-export a:hover { background: #e0e7ff; }

html[data-tt-theme="dark"] .tt-play-page {
    background: radial-gradient(ellipse at top, rgba(255, 215, 0, 0.08), transparent 42%), #0b1220;
    color: #e5e7eb;
}
html[data-tt-theme="dark"] .tt-switch { background: #111827; color: #e5e7eb; box-shadow: inset 0 0 0 2px #93c5fd; }
html[data-tt-theme="dark"] .tt-switch.is-offer { background: #3f2e12; }
html[data-tt-theme="dark"] .tt-join-card,
html[data-tt-theme="dark"] .tt-roster button,
html[data-tt-theme="dark"] .tt-roster li,
html[data-tt-theme="dark"] .tt-cell,
html[data-tt-theme="dark"] .tt-rename,
html[data-tt-theme="dark"] .tt-host-code,
html[data-tt-theme="dark"] .tt-table-wrap,
html[data-tt-theme="dark"] .tt-student-card,
html[data-tt-theme="dark"] .tt-view-toggle,
html[data-tt-theme="dark"] .tt-zoom,
html[data-tt-theme="dark"] .tt-pair-block,
html[data-tt-theme="dark"] .tt-host-names button,
html[data-tt-theme="dark"] .tt-ctx,
html[data-tt-theme="dark"] .tt-code-modal-panel,
html[data-tt-theme="dark"] .ah-panel,
html[data-tt-theme="dark"] .willow-modal-panel,
html[data-tt-theme="dark"] .tt-join-card { background: #111827; color: #e5e7eb; border-color: #334155; }
html[data-tt-theme="dark"] .tt-host-page { background: #0b1220; color: #e5e7eb; }
html[data-tt-theme="dark"] .tt-blob { opacity: 0.18; }
html[data-tt-theme="dark"] .tt-join h2,
html[data-tt-theme="dark"] .tt-panel h2,
html[data-tt-theme="dark"] .tt-series-score p,
html[data-tt-theme="dark"] .tt-host-msg.is-ended,
html[data-tt-theme="dark"] .tt-host-url,
html[data-tt-theme="dark"] .tt-host-code,
html[data-tt-theme="dark"] .tt-code-modal-code,
html[data-tt-theme="dark"] .tt-done-score,
html[data-tt-theme="dark"] .tt-card-score { color: #f8fafc; }
html[data-tt-theme="dark"] .tt-hint,
html[data-tt-theme="dark"] .tt-lead,
html[data-tt-theme="dark"] .tt-host-label,
html[data-tt-theme="dark"] .tt-pair-head p,
html[data-tt-theme="dark"] .willow-modal-body p { color: #cbd5e1; }
html[data-tt-theme="dark"] .tt-cell { box-shadow: none; }
html[data-tt-theme="dark"] .tt-cell.is-x, html[data-tt-theme="dark"] .tt-mini i { color: #93c5fd; }
html[data-tt-theme="dark"] .tt-score-table td { border-color: #334155; color: #e5e7eb; }
html[data-tt-theme="dark"] .tt-score-table tr.is-done,
html[data-tt-theme="dark"] .tt-student-card.is-done { background: #064e3b; }
html[data-tt-theme="dark"] .tt-join-form input,
html[data-tt-theme="dark"] .tt-rename input,
html[data-tt-theme="dark"] .tt-rules-edit input { background: #0f172a; color: #f8fafc; border-color: #334155; }
html[data-tt-theme="dark"] .tt-rules-edit label { color: #e0e7ff; }
html[data-tt-theme="dark"] .ah-row,
html[data-tt-theme="dark"] .ah-score { background: #1e293b; border-color: #334155; color: #f8fafc; }
html[data-tt-theme="dark"] #willow-confirm-cancel { background: #1e293b; color: #e5e7eb; }
html[data-tt-theme="dark"] .tt-mini i { background: #0f172a; }

@media (max-width: 720px) {
    .tt-host-bar { align-items: flex-start; }
    .tt-host-title { flex-basis: 100%; }
    .tt-score-table thead { display: none; }
    .tt-score-table, .tt-score-table tbody, .tt-score-table tr, .tt-score-table td { display: block; width: auto; }
    .tt-host-page #tt-host-board { display: block; }
    .tt-score-table tr {
        display: grid; grid-template-columns: auto 1fr; gap: 0.25rem 0.65rem;
        padding: 0.75rem 0.8rem; border-bottom: 1px solid #e2e8f0;
    }
    .tt-score-table td { border: 0; padding: 0; }
    .tt-score-table td:nth-child(1) { grid-row: 1; }
    .tt-score-table td:nth-child(2) { grid-row: 1; }
    .tt-score-table td:nth-child(3) { grid-column: 1 / -1; }
    .tt-score-table td:nth-child(4) { grid-column: 1 / -1; text-align: center; }
    .tt-score-table td:nth-child(5) { grid-column: 1 / -1; text-align: center; }
    .tt-score-table td.tt-rank,
    .tt-score-table td.tt-series-cell,
    .tt-score-table td.tt-board-slot,
    .tt-score-table td.tt-record { width: auto; }
    .tt-mini { width: 7.5rem; }
    .tt-host-race[data-view="cards"] .tt-cards-space { grid-template-columns: 1fr; }
    .tt-board { gap: 0.4rem; }
    .tt-cell { border-radius: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) {
    .tt-cell.is-fresh .tt-mark-x::before,
    .tt-cell.is-fresh .tt-mark-x::after,
    .tt-cell.is-fresh .tt-mark-o,
    .tt-board.is-draw .tt-cell { animation: none; transition: none; }
    .tt-cell .tt-mark-x::before { transform: rotate(45deg) scaleX(1); }
    .tt-cell .tt-mark-x::after { transform: rotate(-45deg) scaleX(1); }
    .tt-blob, .tt-host-page::before { display: none; }
}
@keyframes tt-stroke { to { transform: rotate(45deg) scaleX(1); } }
.tt-cell.is-fresh .tt-mark-x::after { animation-name: tt-stroke-b; }
@keyframes tt-stroke-b { to { transform: rotate(-45deg) scaleX(1); } }
@keyframes tt-pop { from { transform: scale(0.4); opacity: 0.4; } to { transform: scale(1); opacity: 1; } }
.tt-lobby { display: flex; flex-direction: column; gap: 0.75rem; }
.tt-lobby[hidden] { display: none !important; }
.tt-lobby-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.tt-lobby-person,
.tt-play-cpu {
    width: 100%;
    border: 0;
    border-radius: 0.9rem;
    padding: 0.9rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}
.tt-lobby-person { text-align: left; background: #fff; color: #001A72; box-shadow: inset 0 0 0 2px #001A72; }
.tt-play-cpu { text-align: center; background: #001A72; color: #fff; }
.tt-play-cpu[hidden] { display: none !important; }
html[data-tt-theme="dark"] .tt-lobby-person { background: #111827; color: #e5e7eb; box-shadow: inset 0 0 0 2px #93c5fd; }
html[data-tt-theme="dark"] .tt-code-modal-url { color: #f8fafc; }
html[data-tt-theme="dark"] .tt-code-modal-code { color: #fde68a; background: #020617; border-color: #fde68a; }
