:root {
  --bg: #1a1410;
  --card: #261d16;
  --accent: #c8a15a;
  --text: #ece3d4;
  --muted: #9a8b76;
  --error: #d8674f;
}

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

body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}

/* Экраны: показываем только активный.
   100dvh — «динамическая» высота: учитывает адресную строку браузера на
   смартфоне, поэтому нижняя кнопка не уезжает под край экрана. */
.screen { display: none; padding: 16px; min-height: 100vh; min-height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }
/* Экран входа — карточку центрируем по вертикали */
#screen-login.active { justify-content: center; }

.card {
  background: var(--card);
  border: 1px solid #3a2d22;
  border-radius: 14px;
  padding: 20px;
  margin: 0 auto 14px;
  width: 100%;
  max-width: 420px;
  align-self: center;
}

h1 { font-size: 28px; color: var(--accent); margin-bottom: 4px; text-align: center; }

.muted { color: var(--muted); text-align: center; margin-bottom: 18px; }
.hint  { color: var(--muted); font-size: 13px; margin-top: 12px; }
.hint.center { text-align: center; }
.error { color: var(--error); font-size: 14px; min-height: 18px; margin-top: 8px; text-align: center; }

input {
  width: 100%;
  padding: 14px;
  margin-bottom: 12px;
  background: #1f1812;
  border: 1px solid #3a2d22;
  border-radius: 10px;
  color: var(--text);
  font-size: 16px;
}
input:focus { outline: none; border-color: var(--accent); }

button {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #1a1410;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}
button:active { opacity: 0.85; }

button.big { margin-top: auto; padding: 18px; font-size: 18px; }
button.link {
  width: auto; background: none; color: var(--accent);
  font-weight: 400; padding: 4px;
}

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; font-size: 18px;
}
#char-name { font-size: 24px; font-weight: 700; color: var(--accent); }

.stat { margin-bottom: 14px; }
.stat-row { display: flex; justify-content: space-between; margin-bottom: 6px; font-size: 15px; }
.bar { height: 14px; background: #1f1812; border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; transition: width 0.4s ease; }
.bar-fill.food   { background: linear-gradient(90deg, #7a9a3a, #b6d86a); }
.bar-fill.psyche { background: linear-gradient(90deg, #5a7ac8, #6ab6d8); }

/* Активные состояния персонажа */
#statuses { width: 100%; max-width: 420px; align-self: center; }
.status {
  border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
  border-left: 4px solid var(--muted); background: var(--card);
}
.status-title { font-weight: 600; font-size: 15px; }
.status-desc { font-size: 13px; color: var(--muted); margin-top: 2px; }
.status-info   { border-left-color: #6ab6d8; }
.status-warn   { border-left-color: #d8a85a; }
.status-danger { border-left-color: #d8674f; }
.status-warn   .status-title { color: #e7c074; }
.status-danger .status-title { color: #e89078; }

/* Таймеры убывания на экране игрока */
#timers { width: 100%; max-width: 420px; align-self: center; }
.timer {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid #3a2d22; border-radius: 10px;
  padding: 8px 14px; margin-bottom: 8px; font-size: 14px;
}
.timer-left { font-family: monospace; color: var(--accent); font-weight: 600; }

#qr-reader { width: 100%; max-width: 420px; margin: 0 auto; border-radius: 12px; overflow: hidden; }

/* Модалка результата */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal.hidden { display: none; }
.modal-box {
  background: var(--card); border-radius: 14px; padding: 26px;
  max-width: 360px; width: 100%; text-align: center;
}
#modal-text { margin-bottom: 20px; font-size: 17px; line-height: 1.4; }

/* ====== Админ-панель ====== */
.admin-wrap { max-width: 760px; margin: 0 auto; width: 100%; }

/* Вкладки прокручиваются по горизонтали отдельным контейнером,
   чтобы свайп листал именно панель, а не основное содержимое. */
.tabs {
  display: flex; gap: 8px; margin-bottom: 18px;
  overflow-x: auto; flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  overscroll-behavior-x: contain;
  padding-bottom: 6px;
}
.tabs::-webkit-scrollbar { height: 5px; }
.tabs::-webkit-scrollbar-thumb { background: #3a2d22; border-radius: 3px; }
.tabs button {
  flex: 0 0 auto; width: auto; white-space: nowrap;
  background: var(--card); color: var(--text);
  border: 1px solid #3a2d22; font-weight: 500; padding: 12px 16px;
}
.tabs button.active { background: var(--accent); color: #1a1410; }

.list { display: flex; flex-direction: column; gap: 12px; }

.row-card {
  background: var(--card); border: 1px solid #3a2d22; border-radius: 12px;
  padding: 14px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start;
}
.row-card .info { flex: 1; min-width: 0; }
.row-card .info .name { font-weight: 600; font-size: 16px; }
.row-card .info .sub { color: var(--muted); font-size: 13px; margin-top: 4px; word-break: break-word; }
.row-card .actions { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.row-card .actions button { padding: 8px 12px; font-size: 13px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; margin-right: 6px; }
.tag.up { background: #2f3a1a; color: #b6d86a; }
.tag.down { background: #3a221a; color: #d8674f; }
.tag.audio { background: #1a2f3a; color: #6ab6d8; }
.tag.used { background: #3a1a1a; color: #d8674f; }
.tag.ok { background: #1a3a25; color: #6ad89a; }

button.secondary { background: #3a2d22; color: var(--text); }
button.danger { background: #5a2a22; color: #f0c8c0; }
button.small { width: auto; padding: 8px 14px; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 10px; }
.toolbar h2 { font-size: 18px; color: var(--accent); }

label.field { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.checkbox-row input { width: auto; margin: 0; }
select, textarea {
  width: 100%; padding: 14px; background: #1f1812; border: 1px solid #3a2d22;
  border-radius: 10px; color: var(--text); font-size: 16px;
}
textarea { resize: vertical; font-family: inherit; }
textarea:focus, select:focus { outline: none; border-color: var(--accent); }

.modal-box.wide { max-width: 440px; text-align: left; max-height: 90vh; overflow-y: auto; }
.modal-box.wide h3 { margin-bottom: 6px; color: var(--accent); }
.btn-row { display: flex; gap: 10px; margin-top: 20px; }

.qr-box { text-align: center; }
.qr-box .code { font-family: monospace; margin-top: 10px; }
#qr-render { display: inline-block; background: #fff; padding: 14px; border-radius: 10px; }

.audio-item { display: flex; align-items: center; gap: 12px; }
.audio-item audio { flex: 1; height: 36px; }
@media print {
  body * { visibility: hidden; }
  #qr-modal, #qr-modal * { visibility: visible; }
  #qr-modal { position: absolute; inset: 0; background: #fff; }
  #qr-modal button { display: none; }
}
