/* Светлая тема в духе shadcn: белые карточки, светло-серый фон,
   тонкие границы, крупные радиусы, один акцентный цвет. */
:root {
  --bg: #f4f4f5;
  --card: #ffffff;
  --border: #e4e4e7;
  --fg: #18181b;
  --muted: #71717a;
  --accent: #a21b0d;
  --accent-soft: #fdf0ee;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .06), 0 8px 24px rgba(24, 24, 27, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.muted { color: var(--muted); }
.accent { color: var(--accent); }
.hidden { display: none !important; }

button {
  font-family: inherit;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  cursor: pointer;
  transition: background .15s ease, transform .05s ease;
}
button:active { transform: scale(.98); }
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* ========================= ЭКРАН ТЕЛЕВИЗОРА ========================= */
/* Всё в vmin/vw: читается с пяти метров на любой диагонали. */
body.screen { overflow: hidden; }

.tv {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 3vmin 4vmin;
  gap: 2.4vmin;
}

.tv-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 2vmin;
  flex: 0 0 auto;
}
.tv-brand {
  font-size: 2.6vmin;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--accent);
}
.tv-status { font-size: 2.4vmin; color: var(--muted); font-weight: 600; }

.tv-body { flex: 1 1 auto; min-height: 0; position: relative; }

/* --- Заставка с QR --- */
.idle {
  height: 100%;
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 3vmin;
}
.idle-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2.2vmin;
  padding: 5vmin;
}
.idle h1 { font-size: 7.4vmin; line-height: 1.05; margin: 0; font-weight: 800; letter-spacing: -.02em; }
.idle .lead { font-size: 3.4vmin; margin: 0; color: var(--fg); font-weight: 500; }
.idle .note { font-size: 2.4vmin; margin: 0; color: var(--muted); }
.idle-langs { display: flex; gap: 1.4vmin; margin-top: 1vmin; }
.idle-langs span {
  font-size: 2vmin; padding: .8vmin 1.8vmin; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted);
}
.idle-langs span.on { background: var(--accent-soft); color: var(--accent); border-color: #f3d5d0; }

.idle-qr {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2vmin; padding: 4vmin;
}
.idle-qr img { width: 42vmin; height: 42vmin; image-rendering: pixelated; }
.idle-qr .url { font-size: 2vmin; color: var(--muted); font-variant-numeric: tabular-nums; }

/* --- Занято: обратный отсчёт вместо QR --- */
.busy {
  height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.6vmin; padding: 6vmin;
}
.busy .label { font-size: 3.2vmin; color: var(--muted); font-weight: 600; }
.busy .clock {
  font-size: 18vmin; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -.03em;
}

/* --- Игровое поле --- */
.stage { position: absolute; inset: 0; }
#field { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud {
  position: absolute; inset: auto 0 0 0;
  display: flex; gap: 2vmin; justify-content: center; padding: 2vmin;
  pointer-events: none; z-index: 6;
}
.hud .tile {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.2vmin 3vmin; min-width: 22vmin; text-align: center; box-shadow: var(--shadow);
}
.hud .tile .k { font-size: 1.9vmin; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.hud .tile .v { font-size: 5vmin; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hud .tile.hot .v { color: var(--accent); }

.center-msg {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  z-index: 4; pointer-events: none;
}
.center-msg .box {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 4vmin 6vmin; text-align: center; max-width: 70%;
}
.center-msg h2 { font-size: 5.6vmin; margin: 0 0 1.4vmin; font-weight: 800; }
.center-msg p { font-size: 3vmin; margin: 0; color: var(--muted); }

/* --- Результаты --- */
.results { height: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 3vmin; }
.results .panel { padding: 4vmin; display: flex; flex-direction: column; gap: 2vmin; min-height: 0; }
.results .panel.score { justify-content: center; }
.results h2 { font-size: 4vmin; margin: 0; font-weight: 800; }
.results .big { font-size: 20vmin; font-weight: 800; line-height: .95; color: var(--accent); font-variant-numeric: tabular-nums; }
.results .sub { font-size: 3.2vmin; color: var(--muted); }
.results .sub b { color: var(--fg); font-size: 4vmin; }
.results ol {
  list-style: none; margin: 0; padding: 0; flex: 1 1 auto; min-height: 0;
  display: flex; flex-direction: column; justify-content: space-evenly; overflow: hidden;
}
.results li {
  display: grid; grid-template-columns: 4vmin 1fr auto; gap: 1.6vmin; align-items: baseline;
  font-size: 3.1vmin; padding: .6vmin 1.4vmin; border-radius: 10px;
}
.results li.blank { color: #d4d4d8; }
.results li .rank { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }
.results li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.results li .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
.results li.me { background: var(--accent-soft); }
.results li.me .sc { color: var(--accent); }

/* Полоса предупреждения за 30 секунд до конца сессии. */
.warnbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20;
  background: var(--accent); color: #fff; text-align: center;
  font-size: 2.6vmin; font-weight: 700; padding: 1.2vmin;
}

/* ============================ ТЕЛЕФОН ============================ */
body.ctl {
  height: 100dvh; overscroll-behavior: none; touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.phone { height: 100dvh; display: flex; flex-direction: column; padding: 16px; gap: 12px; }
.phone-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 0 0 auto; }
.phone-brand { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.langs { display: flex; gap: 4px; }
.langs button { font-size: 12px; padding: 6px 10px; border-radius: 999px; color: var(--muted); }
.langs button.on { background: var(--accent-soft); border-color: #f3d5d0; color: var(--accent); }

.panel { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.pane { flex: 1 1 auto; display: flex; flex-direction: column; gap: 14px; padding: 20px; justify-content: center; align-items: center; text-align: center; }
.pane h1 { font-size: 24px; margin: 0; font-weight: 800; }
.pane p { font-size: 15px; margin: 0; color: var(--muted); line-height: 1.5; }
.pane .big-num { font-size: 64px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.pane button.wide { width: 100%; padding: 18px; font-size: 18px; }

/* Управляющая поверхность: весь экран — одна кнопка. */
.surface {
  flex: 1 1 auto; position: relative; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.surface.flash { background: var(--accent-soft); }
/* Индикатор руля: точка ходит в основном вбок, поэтому и форма широкая.
   Прозрачность задаём цветом, а не opacity — иначе бледнеет и сама точка. */
.surface .crosshair {
  position: relative; width: 200px; height: 100px; max-width: 62vw;
  border: 3px solid #f0cdc8; border-radius: 999px;
}
.surface .crosshair::after {
  content: ""; position: absolute; left: 50%; top: 12%; bottom: 12%; width: 2px;
  margin-left: -1px; background: #f0cdc8;
}
/* Точка показывает, куда сейчас смотрит указка: обратная связь без задержки сети. */
.surface .dot {
  position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%; background: var(--accent); will-change: transform;
}
.surface .aim { font-size: 17px; font-weight: 700; }
.surface .tip { font-size: 13px; color: var(--muted); padding: 0 24px; }
.surface .left { position: absolute; top: 12px; right: 14px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.surface .rotate {
  position: absolute; inset: auto 12px 12px 12px; background: var(--accent); color: #fff;
  border-radius: 12px; padding: 10px; font-size: 14px; font-weight: 700;
}
.surface.warn { border-color: var(--accent); }


/* Телефон в ландшафте: экран низкий, всё лишнее ужимаем. */
@media (orientation: landscape) and (max-height: 520px) {
  .phone { padding: 8px 12px; gap: 6px; }
  /* Шапку не прячем: играют теперь всегда горизонтально, и переключатель
     языков должен оставаться доступным. Просто ужимаем её. */
  .phone-head { gap: 6px; }
  .phone-brand { font-size: 11px; }
  .langs button { font-size: 11px; padding: 4px 8px; }
  .pane { padding: 10px 16px; gap: 8px; }
  .pane h1 { font-size: 19px; }
  .pane p { font-size: 13px; }
  .pane .big-num { font-size: 40px; }
  .pane button.wide { padding: 12px; font-size: 16px; }
  .surface .crosshair { width: 160px; height: 74px; }
  .surface .aim { font-size: 15px; }
  .surface .tip { font-size: 12px; }
  .row button { padding: 10px; font-size: 14px; }
}

.row { display: flex; gap: 10px; flex: 0 0 auto; }
.row button { flex: 1; padding: 14px; font-size: 15px; }

input[type="text"] {
  width: 100%; padding: 14px; font-size: 17px; font-family: inherit;
  border: 1px solid var(--border); border-radius: 12px; background: var(--card); color: var(--fg);
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
