/* ============================================================
   ТАЙМЕР ДЛЯ НАСТОЛЬНЫХ ИГР — /timer
   Использует общий стиль .poker-page / .pk-* из styles.css и poker-timer.css
   ============================================================ */
.pk-stage-wrap.tm-top { padding-bottom: var(--space-2xl); }
.tm-head { text-align: center; max-width: 760px; margin: 0 auto var(--space-xl); }
.tm-head .pk-sub2 { margin-left: auto; margin-right: auto; }

.tm-card { max-width: 860px; margin: 0 auto; padding: clamp(var(--space-lg), 4vw, var(--space-2xl)); text-align: center; color: #fff; }

/* Экран времени */
.tm-display { padding: var(--space-md) 0 var(--space-lg); }
.tm-clock, .tm-unit input {
  font-family: var(--font); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
  font-size: clamp(3rem, 13vw, 7.5rem); color: #fff; letter-spacing: 0.01em;
}
.tm-clock { transition: color .3s; }
.tm-set { display: flex; justify-content: center; align-items: flex-start; gap: clamp(2px, 1.2vw, 12px); }
.tm-unit { display: flex; flex-direction: column; align-items: center; gap: 8px; cursor: text; }
.tm-unit input {
  width: 2.1ch; padding: 0; text-align: center; background: transparent; border: 0; border-bottom: 2px solid rgba(255,255,255,0.22);
  border-radius: 0; outline: none; -moz-appearance: textfield; appearance: textfield; transition: border-color .2s;
}
.tm-unit input::-webkit-outer-spin-button, .tm-unit input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tm-unit input:focus { border-bottom-color: var(--gold); }
.tm-unit span { color: rgba(255,255,255,0.55); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.12em; }
.tm-colon { font-style: normal; font-family: var(--font); font-weight: 800; font-size: clamp(3rem, 13vw, 7.5rem); line-height: 1; color: rgba(255,255,255,0.35); }

.tm-progress { height: 6px; background: rgba(255,255,255,0.12); border-radius: 999px; overflow: hidden; margin: var(--space-lg) auto 0; max-width: 620px; opacity: 0; transition: opacity .3s; }
.tm-progress i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .25s linear; }
.tm-card:not([data-status="idle"]) .tm-progress { opacity: 1; }

/* Режимы: idle — поля ввода, остальное — цифры */
.tm-card:not([data-status="idle"]) .tm-set { display: none; }
.tm-card[data-status="paused"] .tm-clock { color: rgba(255,255,255,0.55); animation: tm-blink 1.4s ease-in-out infinite; }
.tm-card[data-status="done"] .tm-clock { color: #ff6b5c; }
.tm-card.tm-warn .tm-clock { color: #ffb3a8; }
@keyframes tm-blink { 50% { opacity: 0.45; } }

.tm-done { margin: 0 auto var(--space-lg); padding: var(--space-md) var(--space-lg); border-radius: var(--radius-md, 16px); background: rgba(255,107,92,0.16); border: 1px solid rgba(255,107,92,0.5); animation: tm-pulse 1s ease-in-out infinite; }
.tm-done[hidden] { display: none; }
.tm-done b { display: block; font-size: clamp(1.4rem, 4vw, 2rem); font-family: var(--font); }
.tm-done span { color: rgba(255,255,255,0.8); }
@keyframes tm-pulse { 50% { background: rgba(255,107,92,0.3); } }

.tm-presets { display: flex; flex-wrap: wrap; gap: var(--space-sm); justify-content: center; margin-bottom: var(--space-lg); }
.tm-card:not([data-status="idle"]) .tm-presets { display: none; }
.tm-chip { background: rgba(255,255,255,0.07); color: #fff; border: 1px solid rgba(255,255,255,0.18); border-radius: 999px; padding: 9px 18px; font: inherit; font-weight: 600; font-size: 0.92rem; cursor: pointer; transition: background .15s, border-color .15s, color .15s; }
.tm-chip:hover { background: rgba(201,162,90,0.16); border-color: var(--gold); color: var(--gold); }
.tm-chip.is-active { background: var(--gold); border-color: var(--gold); color: #240606; }

.tm-controls { display: flex; flex-wrap: wrap; gap: var(--space-smd); justify-content: center; }
.tm-controls [hidden] { display: none; }
.tm-plus { display: flex; gap: var(--space-smd); justify-content: center; }
.tm-plus[hidden] { display: none; }
.tm-card:not([data-status="idle"]) .tm-controls { flex-direction: column; align-items: center; }
.tm-card:not([data-status="idle"]) .tm-controls > .btn { min-width: 260px; justify-content: center; }
.tm-card:not([data-status="idle"]) .tm-plus .btn { min-width: 0; flex: 1 1 0; }
.tm-card:not([data-status="idle"]) .tm-plus { width: 260px; }
.tm-main { min-width: 190px; justify-content: center; }

/* Факт */
.tm-fact { margin: var(--space-xl) auto 0; max-width: 680px; text-align: left; padding: var(--space-md) var(--space-lg) var(--space-lg); border-radius: 18px; background: rgba(201,162,90,0.12); border: 1px solid rgba(201,162,90,0.45); animation: tm-fact-in .5s cubic-bezier(.22,.9,.25,1); position: relative; overflow: hidden; }
.tm-fact[hidden] { display: none; }
@keyframes tm-fact-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.tm-fact__top { display: flex; justify-content: space-between; align-items: center; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.tm-fact__tag { display: inline-flex; align-items: center; gap: 8px; color: var(--gold); font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.tm-fact__tag b { color: #fff; font-weight: 700; }
.tm-fact__close { background: none; border: 0; color: rgba(255,255,255,0.6); font-size: 1.6rem; line-height: 1; cursor: pointer; padding: 0 4px; }
.tm-fact__close:hover { color: #fff; }
.tm-fact__text { margin: 0; font-size: clamp(1rem, 2.2vw, 1.18rem); line-height: 1.55; color: #fff; }
.tm-fact__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(255,255,255,0.08); }
.tm-fact__bar i { display: block; height: 100%; width: 100%; background: var(--gold); transition: width .5s linear; }

/* Настройки */
.tm-settings { display: flex; flex-wrap: wrap; gap: var(--space-md) var(--space-xl); justify-content: center; align-items: center; margin-top: var(--space-xl); padding-top: var(--space-lg); border-top: 1px solid rgba(255,255,255,0.12); }
.tm-check { color: rgba(255,255,255,0.9); }
.tm-check--fun { display: inline-flex; align-items: center; gap: var(--space-sm); }

/* Переключатели-слайдеры */
.tm-switch { display: inline-flex; align-items: center; gap: 12px; cursor: pointer; font-weight: 600; }
.tm-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.tm-switch__track { position: relative; flex: none; width: 46px; height: 26px; border-radius: 999px; background: rgba(255,255,255,0.18); border: 1px solid rgba(255,255,255,0.25); transition: background .2s, border-color .2s; }
.tm-switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4); transition: transform .2s; }
.tm-switch input:checked + .tm-switch__track { background: var(--gold); border-color: var(--gold); }
.tm-switch input:checked + .tm-switch__track::after { transform: translateX(20px); background: #240606; }
.tm-switch input:focus-visible + .tm-switch__track { outline: 2px solid #fff; outline-offset: 2px; }

/* Подсказка «?» */
.tm-tip { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.4); color: rgba(255,255,255,0.85); font-size: 0.8rem; font-weight: 700; cursor: help; outline: none; }
.tm-tip:hover, .tm-tip:focus { border-color: var(--gold); color: var(--gold); }
.tm-tip__box { position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(4px); width: min(320px, 80vw); padding: 12px 14px; border-radius: 12px; background: #1c0505; border: 1px solid rgba(201,162,90,0.5); box-shadow: 0 16px 40px rgba(0,0,0,0.5); color: #fff; font-size: 0.86rem; font-weight: 400; line-height: 1.45; text-align: left; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s, transform .15s; z-index: 5; }
.tm-tip:hover .tm-tip__box, .tm-tip:focus .tm-tip__box { opacity: 1; visibility: visible; transform: translateX(-50%); }
.tm-interval { display: inline-flex; align-items: center; gap: var(--space-sm); }
.tm-interval[hidden] { display: none; }
.tm-interval__label { color: rgba(255,255,255,0.65); font-size: 0.9rem; }
.tm-seg { display: inline-flex; border: 1px solid rgba(255,255,255,0.2); border-radius: 999px; overflow: hidden; }
.tm-seg__item { cursor: pointer; }
.tm-seg__item input { position: absolute; opacity: 0; pointer-events: none; }
.tm-seg__item span { display: block; padding: 8px 16px; font-size: 0.9rem; font-weight: 600; color: rgba(255,255,255,0.8); transition: background .15s, color .15s; }
.tm-seg__item input:checked + span { background: var(--gold); color: #240606; }
.tm-seg__item input:focus-visible + span { outline: 2px solid #fff; outline-offset: -3px; }
.tm-hint { margin: var(--space-md) auto 0; max-width: 560px; color: rgba(255,255,255,0.6); font-size: 0.86rem; }
.tm-hint[hidden] { display: none; }

/* Контент */
.tm-why { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap-cards); }
.tm-lead { margin-bottom: var(--space-lg); }
.tm-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-md); }
.tm-steps li { display: flex; gap: var(--space-md); align-items: flex-start; }
.tm-steps__num { flex: none; width: 38px; height: 38px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(201,162,90,0.16); color: var(--gold); font-weight: 800; }
.tm-steps b { color: #fff; display: block; margin-bottom: 2px; }
.tm-steps p { margin: 0; color: rgba(255,255,255,0.72); font-size: 0.94rem; }

@media (max-width: 860px) { .tm-why { grid-template-columns: 1fr; } }
@media (max-width: 560px) {
  .tm-controls .btn { flex: 1 1 100%; justify-content: center; }
  .tm-settings { flex-direction: column; align-items: flex-start; }
  .tm-fact { padding: var(--space-md); }
}
@media (prefers-reduced-motion: reduce) { .tm-card *, .tm-fact, .tm-done { animation: none !important; } }

/* Во время отсчёта на кнопке «Пауза» иконка «play» не нужна */
.tm-card[data-status="running"] .tm-main svg { display: none; }


/* ── Компактная раскладка: таймер целиком помещается на экран ── */
.pk-stage-wrap.tm-top { padding-top: clamp(var(--space-md), 2.4vw, var(--space-xl)); padding-bottom: var(--space-xl); }
.tm-head { margin-bottom: var(--space-lg); }
.tm-head .pk-title2 { font-size: clamp(1.4rem, 6.2vw, 3rem); white-space: nowrap; margin: var(--space-smd) 0 var(--space-sm); }
.tm-head .pk-sub2 { font-size: 1rem; max-width: 62ch; }
.tm-card { padding: clamp(var(--space-md), 2.4vw, var(--space-xl)); }
.tm-display { padding: 0 0 var(--space-md); }
.tm-clock, .tm-unit input, .tm-colon { font-size: clamp(3rem, min(11vw, 15vh), 6.5rem); }
.tm-progress { margin-top: var(--space-md); }
.tm-presets { margin-bottom: var(--space-md); }
.tm-card .btn--lg { padding: 12px 26px; font-size: 1rem; }
.tm-settings { margin-top: var(--space-lg); padding-top: var(--space-md); gap: var(--space-sm) var(--space-xl); }
.tm-fact { margin-top: var(--space-lg); }

/* Настройки: 1-я строка — звук, 2-я — факты */
.tm-settings { flex-direction: column; gap: var(--space-sm); }
.tm-row { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: var(--space-sm) var(--space-xl); }
@media (max-width: 560px) { .tm-settings { align-items: stretch; } .tm-row { flex-direction: column; align-items: flex-start; } }

/* ── Полноэкранный режим (настоящий fullscreen и запасной вариант для iPhone) ── */
.tm-card.tm-fake { position: fixed; inset: 0; z-index: 2000; width: 100%; height: 100vh; height: 100dvh; max-width: none; margin: 0; }
html.tm-noscroll, html.tm-noscroll body { overflow: hidden; }
.tm-card.is-fs {
  display: flex; flex-direction: column; justify-content: center; max-width: none; padding: 0; border: 0; border-radius: 0; overflow: auto;
  background:
    radial-gradient(60rem 48rem at 50% -12%, #6c0a0a, transparent 60%),
    radial-gradient(48rem 48rem at 100% 100%, #3a0000, transparent 60%),
    linear-gradient(180deg, #380000, #220000 60%, #190000);
}
.tm-card.is-fs .tm-inner { width: 100%; padding: 2vh 3vw; }
.tm-card.is-fs .tm-settings, .tm-card.is-fs .tm-hint, .tm-card.is-fs .tm-presets { display: none; }
.tm-card.is-fs .tm-clock, .tm-card.is-fs .tm-unit input, .tm-card.is-fs .tm-colon { font-size: clamp(3rem, min(22vw, 34vh), 22rem); }
.tm-card.is-fs .tm-display { padding-bottom: 1.5vh; }
.tm-card.is-fs[data-status] .tm-controls { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 10px; }
.tm-card.is-fs[data-status] .tm-controls > .btn { min-width: 0; padding: 10px 20px; font-size: 0.95rem; }
.tm-card.is-fs[data-status] .tm-plus { width: auto; gap: 10px; }
.tm-card.is-fs[data-status] .tm-plus .btn { flex: none; padding: 10px 20px; font-size: 0.95rem; }
.tm-card.is-fs .tm-fact { max-width: 900px; margin-top: 2vh; padding: 12px 18px 16px; }
.tm-card.is-fs .tm-fact__text { font-size: clamp(0.9rem, 2.6vh, 1.25rem); }

/* Телефон/планшет в портретной ориентации: если браузер не даёт заблокировать ландшафт — поворачиваем картинку сами */
@media (orientation: portrait) and (pointer: coarse) {
  .tm-card.is-fs .tm-inner {
    position: absolute; top: 0; left: 0; overflow: auto; display: flex; flex-direction: column; justify-content: center;
    width: 100vh; height: 100vw; transform-origin: 0 0; transform: translateX(100vw) rotate(90deg);
    width: 100dvh; height: 100dvw; transform: translateX(100dvw) rotate(90deg);
  }
}
/* секция с карточкой должна перекрывать шапку и соседние блоки, пока включён запасной fullscreen */
html.tm-noscroll .pk-stage-wrap { z-index: 3000; }
.tm-card.is-fs .tm-controls .btn { flex: 0 0 auto; }
@media (orientation: portrait) and (pointer: coarse) {
  .tm-card.is-fs .tm-clock, .tm-card.is-fs .tm-unit input, .tm-card.is-fs .tm-colon { font-size: clamp(3rem, min(22vh, 32vw), 22rem); }
  .tm-card.is-fs .tm-inner { padding: 2vw 3vh; }
  .tm-card.is-fs .tm-fact__text { font-size: clamp(0.9rem, 2.4vw, 1.25rem); }
}
