#game-root {
    --ttt-accent: #10B981;
    --ttt-accent-dark: #0e9c6f;
    --ttt-accent-light: #e3f9ef;
    --ttt-accent-border: #a7f3d0;
    border-radius: var(--kw-radius, 16px);
}

#game-root button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.kwg-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 14px;
}

.ttt-wrap {
    max-width: 440px;
    margin: 0 auto;
}

.ttt-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}

.ttt-header-icon {
    display: flex;
    font-size: 30px;
    line-height: 1;
}

.ttt-header-icon img {
    display: block;
    height: 22px;
    width: auto;
}

.ttt-header-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--ttt-accent);
}

/* ---- Setup screen ---- */

.ttt-setup-card {
    background: #fff;
    border-radius: var(--kw-radius, 16px);
    padding: 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
}

.ttt-setup-section {
    margin-bottom: 20px;
}

.ttt-setup-section-last {
    margin-bottom: 0;
}

.ttt-setup-label {
    font-size: 13px;
    font-weight: 800;
    color: #888;
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: 10px;
}

.ttt-opponent-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.ttt-difficulty-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.ttt-theme-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.ttt-option-card,
.ttt-difficulty-card,
.ttt-theme-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    border: 2px solid var(--ttt-accent-border);
    border-radius: var(--kw-radius, 14px);
    background: #fff;
    padding: 12px 8px;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .06);
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.ttt-option-card:hover,
.ttt-difficulty-card:hover,
.ttt-theme-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 14px rgba(0, 0, 0, .1);
}

.ttt-option-card.ttt-option-selected,
.ttt-difficulty-card.ttt-option-selected,
.ttt-theme-card.ttt-option-selected {
    border-color: var(--ttt-accent);
    background: var(--ttt-accent-light);
    box-shadow: 0 0 0 2px var(--ttt-accent) inset;
}

.ttt-option-selected::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 6px;
    width: 16px;
    height: 16px;
    background: var(--ttt-accent);
    color: #fff;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ttt-option-emoji {
    font-size: 26px;
    line-height: 1;
}

.ttt-option-label {
    font-size: 13px;
    font-weight: 800;
    color: var(--kw-text, #2D2A32);
}

.ttt-option-label small {
    font-weight: 600;
    color: var(--ttt-accent-dark);
}

.ttt-option-sub {
    font-size: 11px;
    color: #888;
    font-weight: 600;
}

.ttt-difficulty-bullets {
    list-style: none;
    margin: 4px 0 0;
    padding: 0;
    font-size: 11px;
    color: #777;
    font-weight: 600;
    line-height: 1.5;
}

.ttt-difficulty-bullets li::before {
    content: '• ';
    color: var(--ttt-accent);
}

.ttt-timed-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.ttt-timed-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.ttt-timed-toggle-track {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--ttt-accent-border);
    border-radius: 999px;
    transition: background .15s ease;
    flex-shrink: 0;
}

.ttt-timed-toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    transition: transform .15s ease;
}

.ttt-timed-checkbox:checked + .ttt-timed-toggle-track {
    background: var(--ttt-accent);
}

.ttt-timed-checkbox:checked + .ttt-timed-toggle-track .ttt-timed-toggle-thumb {
    transform: translateX(20px);
}

.ttt-timed-toggle-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--kw-text, #2D2A32);
}

.ttt-timed-toggle-label small {
    color: #888;
    font-weight: 600;
}

.ttt-start-btn {
    display: block;
    width: 100%;
    text-align: center;
    font-size: 16px;
    padding: 14px;
    margin-top: 20px;
}

/* ---- Match screen ---- */

.ttt-mode-row {
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.ttt-mode-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--ttt-accent-light);
    color: var(--ttt-accent-dark);
    border-radius: 999px;
    padding: 5px 12px;
    font-weight: 700;
    font-size: 12px;
}

.ttt-mode-pill-icon {
    display: inline-flex;
    line-height: 1;
}

.ttt-change-setup-btn {
    border: none;
    background: none;
    color: var(--ttt-accent-dark);
    text-decoration: underline;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    padding: 4px;
}

.ttt-change-setup-btn:hover {
    color: var(--ttt-accent);
}

.ttt-players-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-bottom: 14px;
}

.ttt-player-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 84px;
    padding: 8px 14px;
    border-radius: 14px;
    background: #fff;
    border: 2px solid var(--ttt-accent-border);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.ttt-player-mark {
    font-size: 26px;
    line-height: 1;
}

.ttt-player-name {
    font-size: 11px;
    font-weight: 800;
    color: #999;
}

.ttt-player-chip.ttt-player-active {
    border-color: var(--ttt-accent);
    box-shadow: 0 0 0 2px var(--ttt-accent-light) inset, 0 4px 10px rgba(16, 185, 129, .25);
    transform: translateY(-2px);
}

.ttt-player-chip.ttt-player-active .ttt-player-name {
    color: var(--ttt-accent-dark);
}

.ttt-players-vs {
    font-size: 12px;
    font-weight: 800;
    color: #bbb;
}

.ttt-status-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 14px;
    min-height: 22px;
}

.ttt-status {
    font-size: 15px;
    font-weight: 700;
    color: var(--ttt-accent-dark);
    text-align: center;
}

.ttt-timer {
    font-size: 13px;
    font-weight: 800;
    color: #EF4444;
    background: #fee2e2;
    border-radius: 999px;
    padding: 2px 10px;
}

.ttt-board-card {
    background: var(--ttt-accent-border);
    border-radius: var(--kw-radius, 20px);
    padding: 30px;
}

.ttt-board {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
    max-width: 320px;
    margin: 0 auto;
}

.ttt-cell {
    aspect-ratio: 1;
    font-size: 44px;
    font-weight: 900;
    line-height: 1;
    border-radius: 12px;
    border: none;
    background: #fff;
    box-shadow: 0 2px 0 rgba(0, 0, 0, .08);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .12s ease, box-shadow .12s ease;
    color: var(--kw-text, #2D2A32);
}

.ttt-cell.ttt-mark-x {
    color: #2563EB;
}

.ttt-cell.ttt-mark-o {
    color: #F97316;
}

.ttt-cell:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 0 rgba(0, 0, 0, .08);
}

.ttt-cell:focus {
    outline: none;
}

.ttt-cell:disabled {
    cursor: default;
    opacity: 1;
    -webkit-text-fill-color: currentColor;
}

.ttt-cell.ttt-mark-x,
.ttt-cell.ttt-mark-o {
    animation: ttt-pop .2s ease;
}

.ttt-cell.ttt-win-cell {
    background: var(--ttt-accent-light);
    box-shadow: 0 0 0 3px var(--ttt-accent) inset, 0 3px 0 rgba(0, 0, 0, .08);
    animation: ttt-win-pulse .6s ease infinite alternate;
}

/* ---- Done screen ---- */

.ttt-done-card {
    text-align: center;
    background: #fff;
    border-radius: var(--kw-radius, 16px);
    padding: 32px 20px;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .07);
    animation: ttt-pop .3s ease;
    border: 2px solid transparent;
}

.ttt-done-card.ttt-done-win {
    border-color: var(--ttt-accent-border);
    box-shadow: 0 3px 16px rgba(16, 185, 129, .22);
}

.ttt-done-card.ttt-done-draw {
    border-color: #fde68a;
}

.ttt-done-card.ttt-done-loss {
    border-color: #fecaca;
}

.ttt-done-emoji {
    font-size: 56px;
    margin-bottom: 8px;
}

.ttt-done-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--ttt-accent-dark);
    margin-bottom: 8px;
}

.ttt-done-score {
    font-size: 16px;
    font-weight: 600;
    color: #555;
    margin-bottom: 10px;
}

.ttt-done-stars {
    font-size: 24px;
    letter-spacing: 4px;
}

.ttt-done-share {
    justify-content: center;
    margin-top: 16px;
}

.ttt-done-actions {
    justify-content: center;
    margin-top: 20px;
}

.ttt-btn-primary,
.ttt-btn-secondary {
    border: none;
    padding: 12px 22px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 14px;
    cursor: pointer;
    transition: transform .1s ease;
}

.ttt-btn-primary {
    background: var(--ttt-accent);
    color: #fff;
    box-shadow: 0 3px 0 var(--ttt-accent-dark);
}

.ttt-btn-primary:hover {
    transform: translateY(-1px);
}

.ttt-btn-secondary {
    background: var(--ttt-accent-light);
    color: var(--ttt-accent-dark);
}

.ttt-btn-secondary:hover {
    background: var(--ttt-accent-border);
}

@keyframes ttt-pop {
    0% { transform: scale(.7); }
    100% { transform: scale(1); }
}

@keyframes ttt-win-pulse {
    0% { box-shadow: 0 0 0 3px var(--ttt-accent) inset, 0 3px 0 rgba(0, 0, 0, .08); }
    100% { box-shadow: 0 0 0 5px var(--ttt-accent) inset, 0 3px 0 rgba(0, 0, 0, .08); }
}

@media (max-width: 380px) {
    .ttt-opponent-grid {
        grid-template-columns: 1fr;
    }

    .ttt-difficulty-grid {
        grid-template-columns: 1fr;
    }

    .ttt-theme-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
