/* Ühenda täpid */

/* ===== Disaini tokenid ===== */
:root {
    --tp-accent: #0f8a7e;
    --tp-accent-hover: #0c7369;
    --tp-accent-soft: rgba(15, 138, 126, 0.10);
    --tp-accent-ring: rgba(15, 138, 126, 0.32);
    --tp-on-accent: #ffffff;
    --tp-dot: #334155;
    --tp-dot-done: #0f8a7e;
    --tp-line: #0f8a7e;
    --tp-board: #ffffff;
    --tp-grid: rgba(15, 23, 42, 0.045);
    --tp-danger: #d64545;
    --tp-star: #f5b301;
    --tp-shadow-1: 0 1px 2px rgba(17, 17, 26, 0.06), 0 4px 12px rgba(17, 17, 26, 0.08);
    --tp-shadow-2: 0 2px 4px rgba(17, 17, 26, 0.08), 0 12px 24px rgba(17, 17, 26, 0.12);
    --tp-dur-fast: 150ms;
    --tp-dur-base: 250ms;
    --tp-dur-big: 450ms;
    --tp-ease: cubic-bezier(0.4, 0, 0.2, 1);
    --tp-ease-out: cubic-bezier(0, 0, 0.2, 1);
}
[data-theme="dark"] {
    --tp-accent: #4cbfae;
    --tp-accent-hover: #63cbbb;
    --tp-accent-soft: rgba(76, 191, 174, 0.12);
    --tp-accent-ring: rgba(76, 191, 174, 0.35);
    --tp-on-accent: #0b1f1c;
    --tp-dot: #cbd5e1;
    --tp-dot-done: #4cbfae;
    --tp-line: #4cbfae;
    --tp-board: #1d232c;
    --tp-grid: rgba(255, 255, 255, 0.04);
    --tp-danger: #ef7373;
    --tp-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.30);
    --tp-shadow-2: 0 2px 4px rgba(0, 0, 0, 0.40), 0 12px 24px rgba(0, 0, 0, 0.40);
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --tp-accent: #4cbfae;
        --tp-accent-hover: #63cbbb;
        --tp-accent-soft: rgba(76, 191, 174, 0.12);
        --tp-accent-ring: rgba(76, 191, 174, 0.35);
        --tp-on-accent: #0b1f1c;
        --tp-dot: #cbd5e1;
        --tp-dot-done: #4cbfae;
        --tp-line: #4cbfae;
        --tp-board: #1d232c;
        --tp-grid: rgba(255, 255, 255, 0.04);
        --tp-danger: #ef7373;
        --tp-shadow-1: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 12px rgba(0, 0, 0, 0.30);
        --tp-shadow-2: 0 2px 4px rgba(0, 0, 0, 0.40), 0 12px 24px rgba(0, 0, 0, 0.40);
    }
}

/* Omad display-reeglid võidaks muidu [hidden]-i */
.tp-app [hidden] { display: none !important; }

.tp-section { padding: 24px 16px 32px; }
.tp-app { max-width: 980px; font-family: 'Nunito', var(--bulma-family-primary, system-ui), sans-serif; }

/* ===== Päis ===== */
.tp-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.tp-badge {
    flex: 0 0 auto; width: 56px; height: 56px; border-radius: 14px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--tp-accent-soft); color: var(--tp-accent); font-size: 24px;
}
.tp-title {
    font-size: clamp(1.5rem, 3vw, 1.9rem); font-weight: 800; letter-spacing: -0.015em;
    color: var(--text-primary); line-height: 1.15; margin: 0;
}
.tp-sub { color: var(--text-secondary); font-size: 16px; margin-top: 4px; }

/* ===== Seadete paneel ===== */
.tp-panel {
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 16px;
    box-shadow: var(--tp-shadow-1); padding: 24px;
}
.tp-label { font-size: 14px; font-weight: 700; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 12px; }
.tp-row { margin-top: 24px; }

.tp-modes { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tp-mode {
    position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
    padding: 12px 16px; min-height: 76px; text-align: left; cursor: pointer;
    background: var(--bg-card); color: var(--text-primary);
    border: 1.5px solid var(--border-color); border-radius: 12px;
    font: inherit;
    transition: border-color var(--tp-dur-fast) var(--tp-ease), background var(--tp-dur-fast) var(--tp-ease), box-shadow var(--tp-dur-fast) var(--tp-ease);
}
.tp-mode-seq { font-size: 20px; font-weight: 800; letter-spacing: 0.02em; font-variant-numeric: tabular-nums; }
.tp-mode-name { font-size: 14px; color: var(--text-secondary); font-weight: 600; }
.tp-mode[aria-pressed="true"] { border-color: var(--tp-accent); background: var(--tp-accent-soft); }
.tp-mode[aria-pressed="true"] .tp-mode-seq { color: var(--tp-accent); }
.tp-mode[aria-pressed="true"]::after {
    content: "\f00c"; font-family: "Font Awesome 6 Free"; font-weight: 900;
    position: absolute; top: 8px; right: 10px; font-size: 12px; color: var(--tp-accent);
}
@media (hover: hover) {
    .tp-mode:hover { border-color: var(--tp-accent); box-shadow: var(--tp-shadow-1); }
}

.tp-seg { display: flex; flex-wrap: wrap; gap: 8px; }
.tp-seg button {
    min-width: 48px; height: 44px; padding: 0 16px; border-radius: 8px; cursor: pointer;
    border: 1.5px solid var(--border-color); background: var(--bg-card); color: var(--text-primary);
    font: inherit; font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums;
    transition: border-color var(--tp-dur-fast) var(--tp-ease), background var(--tp-dur-fast) var(--tp-ease);
}
.tp-seg button[aria-pressed="true"] { border-color: var(--tp-accent); background: var(--tp-accent); color: var(--tp-on-accent); }
.tp-seg button:disabled { opacity: 0.4; cursor: not-allowed; }
@media (hover: hover) {
    .tp-seg button:not(:disabled):not([aria-pressed="true"]):hover { border-color: var(--tp-accent); }
}

.tp-toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tp-check {
    display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; cursor: pointer;
    border: 1px solid var(--border-light); border-radius: 12px; background: var(--bg-secondary);
    color: var(--text-primary);
}
.tp-check input { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--tp-accent); flex: 0 0 auto; }
.tp-check strong { display: block; font-size: 16px; color: var(--text-primary); }
.tp-check small { display: block; font-size: 14px; color: var(--text-secondary); line-height: 1.35; }
.tp-check.is-disabled { opacity: 0.5; cursor: not-allowed; }

.tp-cta { margin-top: 24px; margin-bottom: 0 !important; }
.button.tp-primary {
    background: var(--tp-accent); border-color: transparent; color: var(--tp-on-accent);
    font-weight: 700; border-radius: 8px;
}
.button.tp-primary:hover, .button.tp-primary:focus-visible { background: var(--tp-accent-hover); color: var(--tp-on-accent); }
.tp-cta .button { height: 48px; padding-left: 24px; padding-right: 24px; font-size: 16px; }

/* ===== Riba (galerii + mäng) ===== */
.tp-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.tp-bar-gap { flex: 1 1 auto; }
.tp-bar .button { margin: 0; }
.tp-back { border-radius: 8px; }
.tp-icon { width: 44px; height: 44px; padding: 0; border-radius: 8px; }
.tp-pill {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px;
    border-radius: 999px; background: var(--bg-card); border: 1px solid var(--border-light);
    color: var(--text-primary); font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums;
}
.tp-pill i { color: var(--text-muted); font-size: 13px; }
.tp-pill-next { background: var(--tp-accent-soft); border-color: var(--tp-accent-ring); color: var(--tp-accent); font-size: 18px; }
.tp-pill-next b { font-size: 22px; font-weight: 900; }
.tp-pill-miss.has-miss { color: var(--tp-danger); }
.tp-pill-miss.has-miss i { color: var(--tp-danger); }

/* ===== Mänguväli ===== */
.tp-board-wrap {
    position: relative; background: var(--tp-board); border: 1px solid var(--border-light);
    border-radius: 16px; box-shadow: var(--tp-shadow-1); overflow: hidden;
    background-image: radial-gradient(var(--tp-grid) 1.2px, transparent 1.2px);
    background-size: 22px 22px;
}
.tp-board { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
.tp-dot-c { fill: var(--tp-dot); transition: fill var(--tp-dur-fast) var(--tp-ease); }
.tp-dot-l {
    fill: var(--text-primary); font-family: 'Nunito', system-ui, sans-serif; font-weight: 800;
    paint-order: stroke; stroke: var(--tp-board); stroke-linejoin: round;
    text-anchor: middle; dominant-baseline: central; pointer-events: none;
}
.tp-dot.is-done .tp-dot-c { fill: var(--tp-dot-done); }
.tp-dot.is-done .tp-dot-l { fill: var(--text-muted); }
.tp-dot.is-wrong .tp-dot-c { fill: var(--tp-danger); }
.tp-dot.is-wrong { animation: tp-shake 300ms var(--tp-ease); }
.tp-hint-ring { fill: none; stroke: var(--tp-accent); opacity: 0; pointer-events: none; }
.tp-dot.is-hint .tp-hint-ring { animation: tp-pulse 1.1s var(--tp-ease) infinite; }
.tp-line { stroke: var(--tp-line); stroke-linecap: round; fill: none; }
.tp-rubber { stroke: var(--tp-line); stroke-linecap: round; stroke-dasharray: 2 3; opacity: 0.55; pointer-events: none; }
.tp-fill { opacity: 0; transform-box: fill-box; transform-origin: center; pointer-events: none; transition: opacity var(--tp-dur-big) var(--tp-ease-out); }
.tp-board.is-won .tp-fill { opacity: 0.92; animation: tp-pop 420ms var(--tp-ease-out); }
.tp-board.is-won .tp-line { transition: stroke-width var(--tp-dur-base) var(--tp-ease); }
.tp-board.is-won .tp-dot { opacity: 0.2; transition: opacity var(--tp-dur-big) var(--tp-ease); }
.tp-board.is-won .tp-decoy { opacity: 0; }
/* Keskne :focus-visible annab +2px — väli on overflow:hidden mähise sees, seega rõngas sissepoole */
.tp-board:focus-visible { outline-offset: -4px !important; }

@keyframes tp-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-3px); }
}
@keyframes tp-pulse {
    0% { opacity: 0.9; stroke-width: var(--tp-ring-w, 2px); transform: scale(0.6); }
    100% { opacity: 0; transform: scale(1.6); }
}
.tp-hint-ring { transform-box: fill-box; transform-origin: center; }
@keyframes tp-pop {
    0% { transform: scale(0.96); }
    60% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

.tp-progress { position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--tp-accent-soft); pointer-events: none; z-index: 1; }
.tp-progress span { display: block; height: 100%; width: 0; background: var(--tp-accent); transition: width var(--tp-dur-base) var(--tp-ease-out); }

/* Võiduaken mänguvälja allservas — pilt jääb nähtavaks (mobiilis välja all, vt allpool) */
.tp-stage { position: relative; }
.tp-win { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: center; padding: 16px; pointer-events: none; }
.tp-win-card {
    pointer-events: auto; text-align: center; padding: 16px 24px; max-width: 560px; width: 100%;
    background: var(--bg-card); border: 1px solid var(--border-light); border-radius: 16px; box-shadow: var(--tp-shadow-2);
    animation: tp-rise var(--tp-dur-base) var(--tp-ease-out) backwards;
}
.tp-win-title { font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 900; color: var(--text-primary); letter-spacing: -0.01em; }
.tp-stars { margin: 4px 0 12px; font-size: 26px; color: var(--border-color); display: flex; justify-content: center; gap: 6px; }
.tp-stars .is-on { color: var(--tp-star); animation: tp-pop 280ms var(--tp-ease-out) backwards; animation-delay: calc(var(--i) * 110ms + 200ms); }
.tp-win-card .buttons { margin-bottom: 0; }
.tp-win-card .button { margin-bottom: 0; }
@keyframes tp-rise { from { transform: translateY(16px); opacity: 0; } }

/* ===== Galerii ===== */
.tp-help { color: var(--text-secondary); margin-bottom: 12px; }
.tp-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 12px; }
.tp-card {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    aspect-ratio: 1 / 1.08; padding: 12px 8px 8px; cursor: pointer; font: inherit;
    background: var(--bg-card); color: var(--text-primary);
    border: 1.5px solid var(--border-light); border-radius: 12px;
    transition: border-color var(--tp-dur-fast) var(--tp-ease), box-shadow var(--tp-dur-fast) var(--tp-ease), transform var(--tp-dur-fast) var(--tp-ease);
}
.tp-card svg { width: 64%; height: auto; flex: 1 1 auto; }
.tp-card-q {
    flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
    font-size: 40px; font-weight: 900; color: var(--text-muted);
}
.tp-card-name { font-size: 14px; font-weight: 700; color: var(--text-primary); line-height: 1.2; text-align: center; }
.tp-card-meta { font-size: 12px; color: var(--text-muted); }
.tp-card-stars { position: absolute; top: 6px; right: 8px; font-size: 11px; color: var(--tp-star); letter-spacing: 1px; }
.tp-card:disabled { opacity: 0.45; cursor: not-allowed; }
@media (hover: hover) {
    .tp-card:not(:disabled):hover { border-color: var(--tp-accent); box-shadow: var(--tp-shadow-2); transform: translateY(-2px); }
}

/* ===== Täisekraan ===== */
.tp-app:fullscreen { max-width: none; width: 100%; height: 100%; padding: 16px; background: var(--bg-primary); overflow: auto; }
.tp-app:-webkit-full-screen { max-width: none; width: 100%; height: 100%; padding: 16px; background: var(--bg-primary); }

/* ===== Mobiil ===== */
@media (max-width: 768px) {
    .tp-modes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
    .tp-section { padding: 16px 12px 24px; }
    .tp-panel { padding: 16px; }
    .tp-head { gap: 12px; margin-bottom: 16px; }
    .tp-badge { width: 48px; height: 48px; font-size: 20px; border-radius: 12px; }
    .tp-modes { gap: 8px; }
    .tp-mode { padding: 10px 12px; min-height: 68px; }
    .tp-mode-seq { font-size: 18px; }
    .tp-toggles { grid-template-columns: 1fr; }
    .tp-bar { gap: 6px; flex-wrap: nowrap; }
    .tp-pill { height: 32px; padding: 0 10px; font-size: 14px; flex: 0 0 auto; }
    .tp-pill-next { font-size: 15px; }
    .tp-pill-next b { font-size: 18px; }
    /* Edenemist näitab välja ülaserva riba — pill ei mahu 360 px reale */
    #tpProgress { display: none; }
    .tp-back span:not(.icon) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .tp-back, .tp-icon { width: 40px; height: 40px; padding: 0; flex: 0 0 auto; }
    .tp-gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
    .tp-card { padding: 8px 4px 6px; }
    .tp-card-q { font-size: 26px; }
    .tp-card-name { font-size: 12px; }
    .tp-win-card { padding: 12px 16px; }
}
@media (max-width: 600px) {
    .tp-win { position: static; padding: 12px 0 0; }
    .tp-win-card { max-width: none; }
}

/* Lasteaia sait: suuremad valikud */
.tp-app[data-site="digiaed"] .tp-mode-seq { font-size: 26px; }
.tp-app[data-site="digiaed"] .tp-mode { min-height: 92px; }
