*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: var(--tg-theme-bg-color, #12141a);
  --card: var(--tg-theme-secondary-bg-color, #1c2028);
  --text: var(--tg-theme-text-color, #eef1f6);
  --muted: var(--tg-theme-hint-color, #8b93a7);
  --accent: var(--tg-theme-button-color, #c9a227);
  --btn-text: var(--tg-theme-button-text-color, #1a1408);
  --danger: #e05c4e;
}

html.in-browser {
  background: #111;
}
html.in-browser body {
  background: #111;
  margin: 0;
  padding: 0;
  min-height: 100%;
}
html.in-browser #miniapp { display: none !important; }
html.in-tg #web-gate { display: none !important; }
#web-gate { min-height: 100vh; }
html, body { margin: 0; min-height: 100%; overflow-x: hidden; }
body {
  font-family: "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 400px at 20% -10%, #2a2418 0%, var(--bg) 55%);
  color: var(--text);
  padding: 16px 16px 32px;
  max-width: 100%;
}
#miniapp {
  max-width: 100%;
  overflow-x: hidden;
}

.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eyebrow { margin: 0; letter-spacing: 0.14em; text-transform: uppercase; font-size: 11px; color: var(--muted); }
h1 { margin: 4px 0 0; font-size: 22px; font-weight: 650; }
h2 { font-size: 15px; margin: 20px 0 8px; }

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 34px;
  font-weight: 700;
  min-width: 4.2ch;
  text-align: right;
}
.timer.warn { color: #f0c14a; }
.timer.crit { color: var(--danger); animation: pulse 0.6s ease infinite; }
.timer.idle { color: var(--muted); font-size: 22px; }
@keyframes pulse { 50% { opacity: 0.55; } }

.status { min-height: 1.3em; color: var(--muted); font-size: 13px; }
.actions button, .hero, .back, #btn-create, .row button {
  border: 0; border-radius: 12px; padding: 12px;
  background: var(--card); color: var(--text); font-size: 14px;
}
.actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0;
}
#screen-olymp .back { margin-bottom: 0; }
#screen-olymp .list { gap: 12px; }
#btn-join, .row .btns button.primary, .rb-foot button.primary {
  background: var(--accent);
  color: var(--btn-text);
  font-weight: 650;
  border: 1px solid var(--accent);
}
#btn-join { grid-column: 1 / -1; }
.actions .ghost { min-width: 0; padding: 12px 8px; font-size: 13px; }
button.ghost { background: var(--card); }
#btn-skip.ready,
#btn-extra.ready {
  background: #1c3d32;
  color: #8fdbb4;
  border: 1px solid #2d6b54;
}
#btn-skip.used,
#btn-extra.used {
  background: #3d1c1c;
  color: #e08f8f;
  border: 1px solid #6b2d2d;
}
.list { display: flex; flex-direction: column; gap: 8px; }
.row, .card {
  background: var(--card);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  border: 1px solid transparent;
}
.row.current { border-color: var(--accent); }
.row.me {
  background: #1c3d32;
  color: #8fdbb4;
}
.row.me .pos,
.row.me strong,
.row.me small { color: #8fdbb4; }
.row .pos {
  flex: 0 0 1.6em;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--muted);
}
.row .who {
  flex: 1;
  min-width: 0;
  text-align: left;
}
.row small, .hint, .field { color: var(--muted); font-size: 13px; }
.field {
  display: block;
  width: 100%;
  margin: 0 0 12px;
}
.field .opt { font-weight: 400; color: var(--muted); font-size: 12px; }
.field input,
.field textarea,
.field select {
  display: block;
  margin-top: 6px;
}
.err { color: var(--danger); }
.field[hidden], .check[hidden] { display: none !important; }
.screen { display: none; }
.screen.is-on { display: block; }
.hero {
  display: block;
  width: 100%;
  margin: 10px 0;
  padding: 22px 16px;
  font-size: 20px;
  font-weight: 700;
  background: var(--accent);
  color: var(--btn-text);
  border-radius: 16px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(201, 162, 39, 0.35);
  text-decoration: none;
  text-align: center;
}
#go-notify.hero, #go-notify-list.hero, #go-maint.hero {
  background: var(--card);
  color: var(--text);
  border: 1px solid #3a3f4c;
}
#btn-create { background: var(--accent); color: var(--btn-text); font-weight: 650; width: 100%; margin-top: 6px; }
.back { margin-bottom: 8px; padding: 6px 10px; }
textarea, select, input {
  background: #0e1014; color: var(--text); border: 1px solid #333; border-radius: 10px; padding: 10px 12px; font-size: 16px;
  width: 100%;
  max-width: 100%;
}
.row { flex-wrap: wrap; }
.row .btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 14px;
  color: var(--text);
  font-size: 14px;
}
.check input { width: auto; margin-top: 3px; accent-color: var(--accent); }
.rb-head .check {
  margin: 8px 0 0;
  width: 100%;
}
.check small { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.row .btns input[type="time"] { width: 7.5rem; padding: 8px; }
.row.rb-card {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 12px;
}
#maint-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.rb-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
}
.rb-head input[type="time"],
.row.rb-card input[type="time"] {
  width: 7.5rem;
  margin: 0;
  padding: 12px;
}
.rb-text {
  margin: 0;
  min-height: 7.2em;
  resize: vertical;
  padding: 12px;
}
.rb-text-view {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  white-space: pre-wrap;
  background: #0e1014;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 12px;
}
.rb-foot {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  margin: 0;
}
.rb-foot-row {
  flex-direction: row;
}
.rb-foot-row button {
  flex: 1;
  min-width: 0;
}
.rb-foot button.primary,
.rb-foot button.danger {
  width: 100%;
  padding: 12px;
  font-weight: 650;
}
.rb-foot button.danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}

#screen-notify .back { margin-bottom: 12px; }
#screen-notify h1 { margin: 0 0 12px; }
#screen-notify .hint { margin: 0 0 12px; }
#screen-notify .list { gap: 12px; margin: 0; }
#screen-notify .hero { margin: 12px 0 0; }
