/*
 * Çinko TV — yansıtma ekranı. Palet CinkoTheme.xaml'daki adların CSS karşılığıdır;
 * ekranlarda renk doğrudan yazılmaz, bu değişkenler kullanılır.
 * Eski/yavaş TV tarayıcıları hedeflendiği için animasyonlar transform/opacity ile sınırlı.
 */

:root {
    --background-start: #B92E34;
    --background-end: #3D0C02;
    --surface: #F7ECD2;
    --surface-muted: #E4D2A8;
    --surface-border: #D8C4A0;
    --accent: #8C1C13;
    --accent-deep: #2B1B17;
    --mark-red: #C1121F;
    --gold: #F0C05A;
    --text-on-surface: #2B1B17;
    --text-on-surface-muted: #6B5A50;
    --text-on-dark: #F7ECD2;
    --text-on-dark-muted: #E4D2A8;
    --outline-on-dark: #C87F76;
}

html, body {
    margin: 0;
    height: 100%;
    font-family: "Open Sans", "Segoe UI", sans-serif;
    background: var(--background-end);
    overflow: hidden;
}

.tv-root {
    position: relative;
    height: 100vh;
    background: linear-gradient(326deg, var(--background-start) 0%, var(--background-end) 74%);
    color: var(--text-on-dark);
}

/* --- Bekleme ve eşleştirme ------------------------------------------------ */

.tv-waiting, .tv-pairing {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.1rem;
    text-align: center;
}

/* Marka kilidi: satır imzası + ÇİNKO + alt yazı (logo-dark.svg, vektör). */
.tv-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
}

.tv-brand-logo {
    width: min(24rem, 60vw);
    height: auto;
}

.tv-brand-badge {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.35em;
    padding-left: 0.35em;
    color: var(--gold);
}

.tv-subtitle {
    font-size: 1.4rem;
    color: var(--text-on-dark-muted);
}

.tv-status {
    font-size: 1.1rem;
    color: var(--text-on-dark);
}

.tv-qr {
    width: min(38vh, 40vw);
    height: min(38vh, 40vw);
    border-radius: 1.2rem;
    background: var(--surface);
    padding: 0.8rem;
}

/* Kod elle de girilebilsin: iri, harf aralıklı. */
.tv-code {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 0.45em;
    padding-left: 0.45em; /* harf aralığı son harfin sağına da boşluk koyar; dengele */
    color: var(--gold);
}

/* --- Yansıtma düzeni ------------------------------------------------------ */

.tv-mirror {
    height: 100%;
    box-sizing: border-box;
    padding: 1.2rem;
    display: flex;
    gap: 1.4rem;
}

.tv-left {
    width: 17rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
}

.tv-number-card {
    background: var(--surface);
    border-radius: 1.3rem;
    padding: 1rem 0.5rem 1.1rem;
    text-align: center;
}

.tv-rolling {
    font-size: 5rem;
    line-height: 1.1;
    font-weight: 700;
    color: var(--accent);
}

/* Tarama sürerken kartın zemini soluk, rakamlar tam renk; sayı inince zemin yanar ve sayı bir an
   büyür (1.0.10, telefondaki numara topuyla aynı kural). */
.tv-number-card {
    transition: background-color 0.12s;
}

.tv-number-card.rolling {
    background: rgba(247, 236, 210, 0.6);
}

.tv-rolling.landed {
    animation: tv-number-land 0.2s ease-out;
}

@keyframes tv-number-land {
    50% { transform: scale(1.12); }
}

.tv-phase {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-on-surface);
}

.tv-remaining {
    font-size: 0.95rem;
    color: var(--text-on-surface-muted);
}

.tv-awards {
    border: 1px solid var(--outline-on-dark);
    border-radius: 1.1rem;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.tv-award-title {
    font-size: 0.9rem;
    color: var(--text-on-dark-muted);
}

.tv-award-state {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-on-dark-muted);
}

.tv-award-state.expected { color: var(--text-on-dark); }
.tv-award-state.won { color: var(--gold); }

.tv-recent-title {
    font-size: 0.95rem;
    color: var(--text-on-dark-muted);
    margin-bottom: 0.4rem;
}

/* Kısayol ipucu: ekranın altında kısa süreli şerit. */
.tv-hint {
    position: fixed;
    left: 50%;
    bottom: 2.5rem;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.75);
    color: var(--text-on-dark);
    border: 1px solid var(--text-on-dark-muted);
    border-radius: 0.75rem;
    padding: 0.6rem 1.2rem;
    font-size: 1.1rem;
    z-index: 50;
}

/* Odadan çıkış: göz almasın, ama kumanda ve fare bulabilsin. */
.tv-detach {
    margin-top: auto;
    align-self: flex-start;
    background: transparent;
    border: 1px solid var(--text-on-dark-muted);
    border-radius: 0.5rem;
    color: var(--text-on-dark-muted);
    font: inherit;
    font-size: 0.85rem;
    padding: 0.35rem 0.7rem;
    opacity: 0.7;
    cursor: pointer;
}

.tv-detach:hover,
.tv-detach:focus {
    opacity: 1;
    outline: 2px solid var(--text-on-dark);
}

/* İlk basış yapıldı: tuş dikkat çeksin, ikinci basış kapatır. */
.tv-detach.armed {
    opacity: 1;
    color: var(--text-on-dark);
    border-color: var(--text-on-dark);
    background: rgba(255, 255, 255, 0.12);
}

.tv-recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.tv-recent-cell {
    width: 2.6rem;
    height: 2.6rem;
    border-radius: 0.55rem;
    background: var(--surface-muted);
    color: var(--accent);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tv-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    min-width: 0;
}

/* Üst satır: logo ya da komşu balonu. Boyu sabit; balon gelince tablo kıpırdamaz. */
.tv-title-slot {
    height: 5.8rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Yansıtma başlığı: düz yazı yerine marka kilidi. */
.tv-title-logo {
    height: 3.4rem;
    width: auto;
}

/* Komşu balonu (19 Kasım 2026): telefondakiyle aynı krem; kuyruğu soldaki büyük sayıyı
   gösterir. Uzaktan okunsun diye yazı iri. Eski TV tarayıcıları için kuyruk kenarlıkla. */
.tv-neighbour {
    position: relative;
    flex: 1;
    align-self: stretch;
    margin-left: 0.7rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    /* Alt boşluk süre çizgisinin yeri: çizgi yazının üstüne binip harflerin kuyruğunu
       kesiyordu (19 Kasım 2026, web TV). */
    padding: 0 1.2rem 0.8rem;
    background: #FFF8E7;
    border: 2px solid var(--gold);
    border-radius: 1rem;
    animation: tv-neighbour-in 0.25s ease-out;
}

.tv-neighbour::before {
    content: "";
    position: absolute;
    left: -0.8rem;
    top: 50%;
    margin-top: -0.75rem;
    border-top: 0.75rem solid transparent;
    border-bottom: 0.75rem solid transparent;
    border-right: 0.8rem solid var(--gold);
}

.tv-neighbour::after {
    content: "";
    position: absolute;
    left: -0.62rem;
    top: 50%;
    margin-top: -0.65rem;
    border-top: 0.65rem solid transparent;
    border-bottom: 0.65rem solid transparent;
    border-right: 0.7rem solid #FFF8E7;
}

.tv-neighbour-emoji {
    font-size: 2.8rem;
    line-height: 1;
}

/* Karikatür yüz: emojinin yerinde, salondan seçilsin diye ondan büyük. Numara örtülmez. */
.tv-neighbour-face {
    width: 4.6rem;
    height: 4.6rem;
    flex: none;
    margin-top: 0.4rem;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.tv-neighbour-words {
    min-width: 0;
}

.tv-neighbour-name {
    font-size: 1.05rem;
    line-height: 1.25;
    font-weight: 700;
    color: var(--accent);
}

/* Satır yüksekliği kuyruklu harflere (y, g, ç, ş) yer bırakır: taşma gizli olduğu için
   1.15'te harflerin altı kesiliyordu (19 Kasım 2026, web TV). */
.tv-neighbour-text {
    font-size: 1.9rem;
    /* Küçük çözünürlüklü TV'de uzun cümle sığsın; min() tanımayan eski tarayıcı üsttekini kullanır. */
    font-size: min(1.9rem, 2.3vw);
    font-weight: 700;
    line-height: 1.35;
    padding-bottom: 0.08em;
    color: var(--text-on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Süre çizgisi: 5 saniyede kısalır (MirrorScreen.NeighbourTime ile aynı). */
.tv-neighbour-timer {
    position: absolute;
    left: 1.2rem;
    right: 1.2rem;
    bottom: 0.35rem;
    height: 0.25rem;
    border-radius: 0.2rem;
    background: var(--surface-muted);
    overflow: hidden;
}

.tv-neighbour-timer-bar {
    height: 100%;
    background: #B8A06A;
    transform-origin: left center;
    animation: tv-neighbour-timer 5s linear forwards;
}

@keyframes tv-neighbour-in {
    0% { opacity: 0; transform: scale(0.96); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes tv-neighbour-timer {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

.tv-pending {
    text-align: center;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--gold);
}

/* 1..90 tablosu: 10 sütun × 9 satır. */
.tv-board {
    flex: 1;
    border: 1px solid var(--outline-on-dark);
    border-radius: 1.1rem;
    padding: 0.8rem;
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    grid-auto-rows: 1fr;
    gap: 0.35rem;
}

.tv-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    font-size: 1.35rem;
    font-weight: 700;
    background: rgba(43, 27, 23, 0.55);
    color: var(--outline-on-dark);
}

.tv-cell.drawn {
    background: var(--surface);
    color: var(--accent);
}

.tv-cell.newest {
    animation: tv-pop 0.6s ease-out;
    box-shadow: 0 0 0 3px var(--gold);
}

@keyframes tv-pop {
    0% { transform: scale(1.45); }
    100% { transform: scale(1); }
}

/* --- Kutlama -------------------------------------------------------------- */

.tv-celebration {
    position: absolute;
    inset: 0;
    background: rgba(61, 12, 2, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tv-celebration-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.8rem;
    z-index: 1;
}

.tv-celebration-title {
    font-size: 3.2rem;
    font-weight: 700;
    color: var(--gold);
}

.tv-celebration-subtitle {
    font-size: 1.3rem;
    color: var(--text-on-dark-muted);
}

.tv-card {
    background: var(--surface);
    border: 0.55rem solid var(--accent);
    border-radius: 1.4rem;
    padding: 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    box-shadow: 0 0.9rem 2.5rem rgba(61, 12, 2, 0.45);
}

.tv-card-row {
    display: flex;
    gap: 0.4rem;
}

.tv-card-cell {
    width: 4.2rem;
    height: 4.2rem;
    border-radius: 0.6rem;
    background: var(--surface-muted);
    color: var(--text-on-surface);
    font-size: 1.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.tv-card-cell.empty {
    background: transparent;
    border: 1px solid var(--surface-border);
}

/* Kademeyle ilgisi olmayan sayılar gizli: kartın kalan satırları hâlâ oyunda. */
.tv-card-cell.masked {
    color: var(--text-on-surface-muted);
}

.tv-card-cell.marked {
    background: var(--mark-red);
    color: var(--surface);
    animation: tv-pop 0.35s ease-out;
}

.tv-confetti {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Oyundaki ConfettiView ile aynı dil: alttan yukarı süzülen baloncuklar.
   Boy/renk/sürüklenme parça başına satır içi değişkenlerle verilir. */
.tv-confetti-piece {
    position: absolute;
    bottom: -5vh;
    border-radius: 50%;
    opacity: 0;
    animation-name: tv-rise;
    animation-timing-function: ease-out;
    animation-iteration-count: infinite;
}

@keyframes tv-rise {
    0% { transform: translate(0, 0); opacity: 0.9; }
    70% { opacity: 0.7; }
    100% { transform: translate(var(--drift, 0px), -115vh); opacity: 0; }
}

/* --- Dönem sahnesi (yılbaşı, 1 Aralık 2026) --------------------------------
   Eşleştirme ekranının sol yarısı: ışıklar, ortada büyük yazı, altta yarım boy komşular (Fikriye'de püsküllü sim,
   Necati Amca düdük üfler, Elif şapkalı), konfeti. Taslak: docs/taslaklar/yilbasi-sahne.html. */

.tv-pairing.with-scene { flex-direction: row; gap: 0; }
.tv-pairing.with-scene .tv-pairing-side {
    flex: 1; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.1rem;
}
.tv-scene {
    position: relative; width: 58%; height: 100%; overflow: hidden;
    background: radial-gradient(ellipse 85% 80% at 50% 75%, #9b2418 0%, #6e160e 45%, #2f0b05 100%);
}
.tv-scene .lights { position: absolute; left: 0; right: 0; top: 0; height: 10vh; }
.tv-scene .lights svg { width: 100%; height: 100%; }
.tv-scene .bulb { animation: tvs-twinkle 1.6s ease-in-out infinite; filter: drop-shadow(0 0 4px currentColor); }
@keyframes tvs-twinkle { 0%,100% { opacity: 1 } 50% { opacity: .35 } }
.tv-scene .headline { position: absolute; left: 0; right: 0; top: 22%; text-align: center; z-index: 1; pointer-events: none; }
.tv-scene .headline .h1 { font-size: min(8vh, 4.4vw); font-weight: 900; color: var(--gold); text-shadow: 0 .5vh 2vh rgba(0,0,0,.45); }
.tv-scene .headline .h2 { font-size: min(4.7vh, 2.6vw); font-weight: 700; color: var(--surface); margin-top: .8vh; text-shadow: 0 .4vh 1.4vh rgba(0,0,0,.4); }
.tv-scene .ball { position: absolute; bottom: -3%; width: 31%; aspect-ratio: 1; filter: drop-shadow(0 .8vh 1.1vh rgba(0,0,0,.45)); }
.tv-scene .ball img { position: absolute; inset: 0; width: 100%; height: 100%; }
.tv-scene .ball.f { left: 3%; animation: tvs-bob 2.4s ease-in-out infinite; }
.tv-scene .ball.n { left: 35%; bottom: -4%; animation: tvs-bob 2.8s ease-in-out .4s infinite; }
.tv-scene .ball.e { left: 67%; animation: tvs-bob 2.2s ease-in-out .9s infinite; }
@keyframes tvs-bob { 0%,100% { transform: translateY(0) rotate(-3deg) } 50% { transform: translateY(-7%) rotate(3deg) } }
.tv-scene .ball.hop img { animation: tvs-hop .5s ease-out 2; }
@keyframes tvs-hop { 0%,100% { transform: translateY(0) } 40% { transform: translateY(-9%) } }
/* Elif'in şapkası */
.tv-scene .hat { position: absolute; left: 30%; top: -12%; width: 34%; height: 40%; transform-origin: 50% 100%; z-index: 2; animation: tvs-wobble 1.8s ease-in-out 1s infinite; }
@keyframes tvs-wobble { 0%,100% { transform: rotate(-14deg) } 50% { transform: rotate(-4deg) } }
.tv-scene .hat .cone { width: 100%; height: 100%; clip-path: polygon(50% 0,100% 100%,0 100%); background: repeating-linear-gradient(135deg, #B92E34 0 1.6vh, var(--gold) 1.6vh 2.6vh); }
.tv-scene .hat .band { position: absolute; left: -8%; right: -8%; bottom: -8%; height: 16%; border-radius: .8vh; background: var(--surface); }
.tv-scene .hat .pom { position: absolute; left: 50%; top: -16%; width: 36%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0%, var(--surface) 55%, #e6d3a8 100%); }
/* Fikriye'nin simi */
.tv-scene .tinsel { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; z-index: 2; filter: drop-shadow(0 0 .4vh rgba(255,214,90,.9)); }
.tv-scene .tinsel .s1 { animation: tvs-shimmer 1.1s ease-in-out infinite alternate; }
.tv-scene .tinsel .s2 { animation: tvs-shimmer 1.1s ease-in-out .55s infinite alternate; }
.tv-scene .tinsel .sway { transform-box: view-box; transform-origin: 100px 160px; animation: tvs-sway 3s ease-in-out infinite; }
@keyframes tvs-shimmer { 0% { opacity: .8 } 100% { opacity: 1 } }
@keyframes tvs-sway { 0%,100% { transform: rotate(-2deg) } 50% { transform: rotate(2deg) } }
/* Necati Amca'nın düdüğü: 14 sn'de bir Elif'e, yarısında Fikriye'ye */
.tv-scene .horn { position: absolute; left: 46%; top: 65%; width: 70%; height: 20%; transform-origin: 0 50%; z-index: 3; overflow: visible; opacity: 0; }
.tv-scene .horn.r { transform: rotate(-14deg); animation: tvs-showR 14s linear infinite; }
.tv-scene .horn.l { left: 54%; transform: scaleX(-1) rotate(-14deg); animation: tvs-showL 14s linear infinite; }
.tv-scene .horn svg { width: 100%; height: 100%; overflow: visible; }
.tv-scene .horn .paper { transform-box: fill-box; transform-origin: 0% 50%; transform: scaleX(.08); }
.tv-scene .horn .curl { transform-box: fill-box; transform-origin: 50% 50%; }
.tv-scene .horn .toot { opacity: 0; }
.tv-scene .horn.r .paper { animation: tvs-blowR 14s ease-in-out infinite; } .tv-scene .horn.l .paper { animation: tvs-blowL 14s ease-in-out infinite; }
.tv-scene .horn.r .curl { animation: tvs-curlR 14s ease-in-out infinite; } .tv-scene .horn.l .curl { animation: tvs-curlL 14s ease-in-out infinite; }
.tv-scene .horn.r .toot { animation: tvs-tootR 14s ease-in-out infinite; } .tv-scene .horn.l .toot { animation: tvs-tootL 14s ease-in-out infinite; }
@keyframes tvs-showR { 0%,4.3% { opacity: 0 } 4.4%,24.3% { opacity: 1 } 25.7%,100% { opacity: 0 } }
@keyframes tvs-showL { 0%,54.3% { opacity: 0 } 54.4%,74.3% { opacity: 1 } 75.7%,100% { opacity: 0 } }
@keyframes tvs-blowR { 0%,11.4% { transform: scaleX(.08) } 14.3%,19.3% { transform: scaleX(1) } 22.9%,100% { transform: scaleX(.08) } }
@keyframes tvs-blowL { 0%,61.4% { transform: scaleX(.08) } 64.3%,69.3% { transform: scaleX(1) } 72.9%,100% { transform: scaleX(.08) } }
@keyframes tvs-curlR { 0%,11.4% { opacity: 1; transform: scale(1) } 13.6%,20.7% { opacity: 0; transform: scale(.4) } 23.6%,100% { opacity: 1; transform: scale(1) } }
@keyframes tvs-curlL { 0%,61.4% { opacity: 1; transform: scale(1) } 63.6%,70.7% { opacity: 0; transform: scale(.4) } 73.6%,100% { opacity: 1; transform: scale(1) } }
@keyframes tvs-tootR { 0%,15.4% { opacity: 0 } 16.4%,18.6% { opacity: 1 } 20%,100% { opacity: 0 } }
@keyframes tvs-tootL { 0%,65.4% { opacity: 0 } 66.4%,68.6% { opacity: 1 } 70%,100% { opacity: 0 } }
/* konfeti, parıltı */
.tv-scene .conf { position: absolute; top: -3%; width: .9vh; height: 1.5vh; border-radius: .3vh; animation: tvs-fall linear infinite; }
@keyframes tvs-fall { 0% { transform: translateY(0) rotate(0) } 100% { transform: translateY(108vh) rotate(600deg) } }
.tv-scene .spark { position: absolute; width: 1.6vh; height: 1.6vh; color: var(--gold); animation: tvs-spark 2s ease-in-out infinite; }
.tv-scene .spark::before, .tv-scene .spark::after { content: ""; position: absolute; left: 50%; top: 50%; background: currentColor; border-radius: 2px; transform: translate(-50%,-50%); }
.tv-scene .spark::before { width: 100%; height: 16%; } .tv-scene .spark::after { width: 16%; height: 100%; }
@keyframes tvs-spark { 0%,100% { transform: scale(.3) rotate(0); opacity: .2 } 50% { transform: scale(1) rotate(45deg); opacity: 1 } }
/* konuşma balonu */
.tv-scene .say { position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -.6vh); white-space: nowrap; background: #FFF8E8; color: #2B1B17;
    border: .4vh solid var(--gold); border-radius: 1.4vh; padding: .8vh 1.8vh; font-size: 3vh; z-index: 5; animation: tvs-sayin .25s ease-out; }
.tv-scene .say::after { content: ""; position: absolute; left: 50%; top: 100%; transform: translateX(-50%); border: 1vh solid transparent; border-top-color: var(--gold); }
@keyframes tvs-sayin { from { opacity: 0; transform: translate(-50%, 1vh) } to { opacity: 1; transform: translate(-50%, -.6vh) } }
@media (prefers-reduced-motion: reduce) { .tv-scene * { animation: none !important; } }
.tv-scene-art { position: absolute; inset: 0; }
/* Elif sağ kenarda: balonu sağa yaslı, taşmasın. */
.tv-scene .ball.e .say { left: auto; right: 0; transform: translate(0, -.6vh); animation: none; }
.tv-scene .ball.e .say::after { left: auto; right: 22%; transform: none; }
/* Sahnede dinle düğmesi: sağ üst, ışıkların altında. Kendiliğinden sesli çalarken görünmez; bitince ▶, çalarken ⏹. */
.tv-scene .replay { position: absolute; top: 12vh; right: 2.2vw; width: 7vh; height: 7vh; border-radius: 50%; z-index: 3;
    border: .35vh solid var(--gold); background: rgba(43,10,5,.55); display: grid; place-items: center; padding: 0; cursor: pointer; }
.tv-scene .replay svg { width: 46%; height: 46%; display: block; }
.tv-scene .replay:focus-visible { outline: .5vh solid #F7ECD2; outline-offset: .4vh; }
.tv-scene .replay:active { transform: scale(.92); }

/* Yılbaşı geri sayımı (1.0.15): hangi ekran açıksa onun üstünde tam ekran (tv.js countdownOpen). */
.tv-countdown {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    z-index: 10000;
    background: #080302;
}
