:root {
  --bg: var(--tg-theme-bg-color, #0f0f10);
  --text: var(--tg-theme-text-color, #ffffff);
  --hint: var(--tg-theme-hint-color, #9ba2ad);
  --card: var(--tg-theme-secondary-bg-color, #1a1a1d);
  --button: var(--tg-theme-button-color, #2aabee);
  --button-text: var(--tg-theme-button-text-color, #fff);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

.wrap { max-width: 640px; margin: 0 auto; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

.hero { margin-bottom: 8px; }
.hero-title {
  font-size: 24px;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.hero-sub { margin: 0; font-size: 13px; }
.hint { color: var(--hint); }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
  border: 1px solid rgba(255,255,255,.05);
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}

.row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
label { color: var(--hint); font-size: 13px; }

input, select, button {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 15px;
}

input, select {
  background: rgba(255,255,255,.07);
  color: var(--text);
  transition: background 0.2s ease, transform 0.15s ease;
}

input:focus, select:focus {
  outline: none;
  background: rgba(255,255,255,.1);
}

button {
  background: var(--button);
  color: var(--button-text);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease;
}

.btn-press:active { transform: scale(0.98); filter: brightness(1.08); }

.accent { font-weight: 600; }

.title { font-size: 16px; margin-bottom: 8px; font-weight: 600; }
.text { font-size: 14px; line-height: 1.45; margin-bottom: 8px; word-break: break-word; }
.status { color: var(--hint); }

.hidden { display: none !important; }

.fade-up {
  opacity: 0;
  animation: fadeSlideUp 0.55s ease forwards;
}

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-rise {
  animation: cardPop 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes cardPop {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.app-shell.visible {
  animation: shellIn 0.45s ease forwards;
}

@keyframes shellIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.boot-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: var(--bg);
}

.boot-spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.12);
  border-top-color: var(--button);
  animation: spin 0.75s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.boot-text {
  margin: 0;
  font-size: 14px;
  color: var(--hint);
  animation: pulseText 1.4s ease-in-out infinite;
}

@keyframes pulseText {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
}

.gate-card {
  width: 100%;
  max-width: 360px;
  padding: 20px;
  border-radius: 18px;
  background: var(--card);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 16px 48px rgba(0,0,0,.45);
}

.float-y {
  animation: floatY 3.2s ease-in-out infinite;
}

@keyframes floatY {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.glow-ring {
  box-shadow:
    0 0 0 1px rgba(42,171,238,.25),
    0 16px 48px rgba(0,0,0,.45);
}

.gate-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
}

.gate-hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--hint);
  line-height: 1.4;
}

.gate-ch-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.gate-link {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.08);
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.2s ease, transform 0.15s ease;
}

.gate-link:active {
  transform: scale(0.98);
  background: rgba(255,255,255,.12);
}

.gate-link.bad {
  border: 1px solid rgba(255,80,80,.35);
}

.gate-link.ok {
  border: 1px solid rgba(80,220,120,.35);
}

.gate-btn {
  width: 100%;
  padding: 13px;
  border-radius: 12px;
  font-weight: 600;
}

.pulse-cta {
  animation: pulseCta 2s ease-in-out infinite;
}

@keyframes pulseCta {
  0%, 100% { box-shadow: 0 0 0 0 rgba(42,171,238,.35); }
  50% { box-shadow: 0 0 0 8px rgba(42,171,238,0); }
}

.req-hint {
  margin: 0 0 4px;
  font-size: 13px;
  line-height: 1.4;
  min-height: 2.8em;
  transition: color 0.35s ease, transform 0.35s ease;
}

.req-hint.hint-stars {
  color: #c9a227;
  animation: hintSwap 0.5s ease;
}

.req-hint.hint-ton {
  color: #5ac8fa;
  animation: hintSwap 0.5s ease;
}

@keyframes hintSwap {
  from { opacity: 0.35; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.pay-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 12px;
}

.timer-ring-wrap {
  position: relative;
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}

.pay-ring {
  width: 80px;
  height: 80px;
  display: block;
}

.pay-ring-bg {
  fill: none;
  stroke: rgba(255,255,255,.1);
  stroke-width: 5;
}

.pay-ring-arc {
  fill: none;
  stroke: var(--button);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 213.628;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.4s ease;
}

.timer-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.pay-window-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--hint);
}

.memo-line {
  font-family: ui-monospace, monospace;
  font-size: 13px;
}

.hint {
  color: var(--hint);
  font-size: 13px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(10px);
}

.modal-card {
  width: 100%;
  max-width: 380px;
  padding: 18px;
  border-radius: 16px;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.modal-title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.modal-body-tight {
  margin-bottom: 14px;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
}

.modal-btn-primary {
  background: var(--button);
  color: var(--button-text);
}

.modal-btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.modal-btn-full {
  width: 100%;
  flex: none;
}
