/* ─── Шрифт Fixel (бренд УАЛ) ─── */
@font-face {
  font-family: 'Fixel Display';
  src: url('/fonts/FixelDisplay-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Fixel Display';
  src: url('/fonts/FixelDisplay-Bold.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Fixel Text';
  src: url('/fonts/FixelText-Regular.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Fixel Text';
  src: url('/fonts/FixelText-Medium.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Fixel Text';
  src: url('/fonts/FixelText-SemiBold.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  --blue: #3685ee;
  --blue-700: #2e71ca;
  --blue-900: #244f86;
  --yellow: #edef00;
  --yellow-600: #d4d600;
  --white: #ffffff;
  --ink: #1a1a22;
  --ink-500: #71717f;
  --ink-300: #bcbcc6;
  --green: #1fa971;
  --green-bg: #e7f9f1;
  --red: #e5484d;
  --red-bg: #ffeceb;

  --font-display: 'Fixel Display', 'Fixel Text', system-ui, sans-serif;
  --font-text: 'Fixel Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-text);
  color: var(--ink);
  background: linear-gradient(160deg, var(--blue) 0%, var(--blue-900) 100%);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

/* Зростаюча жовта лінія (мотив з hero) — фонова декорація */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='400' height='300' viewBox='0 0 400 300'%3E%3Cg fill='none' stroke='%23edef00' stroke-width='2' opacity='0.13'%3E%3Cpolyline points='30,250 130,235 220,180 300,120 370,50'/%3E%3C/g%3E%3Cg fill='%23edef00' opacity='0.13'%3E%3Ccircle cx='30' cy='250' r='6'/%3E%3Ccircle cx='130' cy='235' r='6'/%3E%3Ccircle cx='220' cy='180' r='6'/%3E%3Ccircle cx='300' cy='120' r='6'/%3E%3Ccircle cx='370' cy='50' r='7'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: min(90vw, 520px);
  pointer-events: none;
}

/* Каркас сторінки */
.app {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 16px
    max(16px, env(safe-area-inset-bottom));
}

/* Верхня панель: логотип + лічильник спроб */
.topbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.topbar .logo {
  height: 30px;
  width: auto;
  display: block;
}
.attempts {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.2px;
  white-space: nowrap;
  user-select: none;
  transition: opacity 0.2s;
}
.attempts b {
  color: rgba(255, 255, 255, 0.82);
  font-weight: 600;
}
.attempts.hidden {
  opacity: 0;
}

/* Центр — активний екран */
.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.screen {
  display: none;
  width: 100%;
  max-width: 440px;
  animation: pop 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
.screen.active {
  display: block;
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.card {
  background: var(--white);
  border-radius: 22px;
  padding: clamp(20px, 6vw, 30px) clamp(18px, 5vw, 26px);
  box-shadow: 0 18px 50px rgba(15, 30, 60, 0.32);
}

/* Знак-А на екрані вітання */
.mark {
  display: block;
  height: clamp(52px, 15vw, 66px);
  margin: 2px auto 14px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.08;
  text-align: center;
  font-size: clamp(22px, 6.4vw, 28px);
  margin-bottom: 10px;
}
h1.small {
  font-size: clamp(18px, 5vw, 22px);
}

.subtitle {
  text-align: center;
  color: var(--ink-500);
  font-size: clamp(14px, 3.7vw, 15px);
  line-height: 1.5;
  margin-bottom: 20px;
}
.subtitle.tight {
  margin-bottom: 14px;
}

/* Історія спроб (нова — зверху, зелена/червона) */
.history {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 26vh;
  overflow-y: auto;
  margin-bottom: 16px;
  padding-right: 2px;
  scrollbar-width: thin;
}
.history:empty {
  display: none;
}
.hist-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 12px;
  animation: histIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.25);
}
.hist-seq {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(17px, 5vw, 20px);
  letter-spacing: 1px;
  color: var(--ink);
}
.hist-tag {
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.hist-row.yes {
  background: var(--green-bg);
}
.hist-row.yes .hist-tag {
  color: var(--green);
}
.hist-row.no {
  background: var(--red-bg);
}
.hist-row.no .hist-tag {
  color: var(--red);
}
@keyframes histIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Поля вводу */
input[type='text'],
textarea {
  width: 100%;
  font-family: var(--font-text);
  border: 2px solid #e3e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 16px; /* ≥16px — щоб iOS не зумив при фокусі */
  color: var(--ink);
  background: #fff;
  transition: border-color 0.15s;
  outline: none;
}
input[type='text']:focus,
textarea:focus {
  border-color: var(--blue);
}
input::placeholder,
textarea::placeholder {
  color: var(--ink-300);
}

.name-input {
  text-align: center;
  font-weight: 500;
  margin-bottom: 16px;
}

/* Три віконечка для цифр */
.boxes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(8px, 3vw, 12px);
  margin-bottom: 16px;
}
.boxes input {
  width: 100%;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 9vw, 38px);
  color: var(--blue-700);
  border: 2px solid #e3e8f0;
  border-radius: 16px;
  background: #fff;
  padding: clamp(12px, 4vw, 18px) 4px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -moz-appearance: textfield;
  appearance: textfield;
}
.boxes input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(54, 133, 238, 0.14);
}
.boxes input::-webkit-outer-spin-button,
.boxes input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Помилка на екрані введення */
.game-error {
  color: var(--red);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  min-height: 18px;
  margin-bottom: 8px;
}

.error {
  color: var(--red);
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  min-height: 18px;
  margin-bottom: 8px;
}

/* Кнопки */
.btn {
  width: 100%;
  border: none;
  border-radius: 15px;
  padding: 16px;
  font-family: var(--font-display);
  font-size: clamp(15px, 4.4vw, 17px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: transform 0.07s, filter 0.15s, box-shadow 0.15s;
}
.btn:active {
  transform: translateY(2px);
}
.btn + .btn {
  margin-top: 10px;
}
.btn-primary {
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--yellow-600);
}
.btn-primary:active {
  box-shadow: 0 3px 0 var(--yellow-600);
}
.btn-primary:hover {
  filter: brightness(1.03);
}
.btn-secondary {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 5px 0 var(--blue-700);
}
.btn-secondary:active {
  box-shadow: 0 3px 0 var(--blue-700);
}
.btn-ghost {
  background: #f2f4f7;
  color: var(--ink-500);
}

/* Ввід правила */
.field-label {
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 15px;
}
textarea {
  min-height: 110px;
  resize: vertical;
  margin-bottom: 14px;
  line-height: 1.5;
}

/* Екран подяки */
.thanks {
  text-align: center;
}
.thanks .emoji {
  font-size: 56px;
  line-height: 1;
  margin-bottom: 10px;
}

/* Підпис під карткою */
.footnote {
  flex: 0 0 auto;
  text-align: center;
  color: rgba(255, 255, 255, 0.42);
  font-size: 11.5px;
  margin-top: 12px;
}

/* ─── Адмінка ─── */
.admin-body {
  background: #f4f6fa;
  color: var(--ink);
}
.admin-body::before {
  display: none;
}
.admin-wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 18px 60px;
}
.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.admin-head img {
  height: 34px;
}
.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.btn-rule,
.btn-clear {
  border: none;
  border-radius: 11px;
  padding: 9px 15px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition: filter 0.15s;
}
.btn-rule {
  background: var(--yellow);
  color: var(--ink);
}
.btn-clear {
  background: #fff;
  color: var(--red);
  border: 1.5px solid #f2c4c4;
}
.btn-rule:hover,
.btn-clear:hover {
  filter: brightness(0.97);
}
.admin-title {
  font-family: var(--font-display);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 22px;
  text-align: left;
  margin: 18px 0 4px;
}
.rule-banner {
  background: var(--yellow);
  border-radius: 12px;
  padding: 11px 15px;
  font-weight: 500;
  font-size: 14px;
  margin: 12px 0 18px;
}
.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.stat {
  background: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}
.stat .n {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--blue-700);
}
.stat .l {
  font-size: 12px;
  color: var(--ink-500);
}
.table-wrap {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
  min-width: 640px;
}
th,
td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid #eef1f6;
  vertical-align: top;
}
th {
  color: var(--ink-500);
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #fafbfd;
  position: sticky;
  top: 0;
}
tr:last-child td {
  border-bottom: none;
}
td.count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  color: var(--blue-700);
}
.pill {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}
.pill.done {
  background: var(--green-bg);
  color: var(--green);
}
.pill.progress {
  background: #eff6ff;
  color: var(--blue-700);
}
.guess-cell {
  max-width: 360px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.muted {
  color: var(--ink-300);
  font-style: italic;
}
