:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #101619;
  color: #f1f5f4;
  --muted: #aab8b1;
  --border: #34413d;
  --accent: #adf5b5;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100svh;
  background: radial-gradient(ellipse at 50% 24%, #19302a80, transparent 70%), #101619;
}
button { font: inherit; -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
[hidden] { display: none !important; }

.app {
  max-width: 448px;
  margin-inline: auto;
  padding: clamp(18px, 5svh, 48px) 20px max(16px, env(safe-area-inset-bottom));
}

.dashboard {
  display: flex;
  flex-direction: column;
  min-height: var(--tg-viewport-stable-height, 100svh);
}

.brand {
  margin-bottom: 8px;
  text-align: center;
}

.dashboard .brand {
  display: grid;
  align-self: center;
  row-gap: 8px;
  max-width: 100%;
  margin-bottom: 0;
}

.dashboard .brand-name {
  width: auto;
  margin: 0;
}

.brand-name {
  position: relative;
  width: clamp(128px, 42vw, 174px);
  aspect-ratio: 4 / 1;
  margin: 0 auto;
  background: center / 100% 100% no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 302 102' preserveAspectRatio='none'%3E%3Cpath fill='%23f1f5f4' fill-rule='evenodd' d='\
    M0 62h11v29q0 2 2 2t2-2V68q0-6-4-12L4 45q-4-7-4-14V14Q0 0 13 0q14 0 14 14v21H16V12q0-2-2-2t-2 2v17q0 6 4 12l7 11q4 7 4 14v22q0 14-14 14Q0 102 0 88Z \
    M34 1h12v90h9v10H34Z \
    M62 14Q62 0 75.5 0T89 14v74q0 14-13.5 14T62 88Zm12-2v78q0 2 1.5 2t1.5-2V12q0-2-1.5-2T74 12Z \
    M94 1h12l3 64 3-64h9l3 64 3-64h12l-8 100h-11l-3.5-60-3.5 60h-11Z \
    M144 1h22v10h-10v30h8v10h-8v40h10v10h-22Z \
    M172 1h14q13 0 13 14v72q0 14-13 14h-14Zm12 10v80h1q2 0 2-2V13q0-2-2-2Z \
    M204 1h12l4 71 4-71h12l-10 100h-12Z \
    M242 1h14q13 0 13 14v29q0 14-13 14h-2v43h-12Zm12 10v37h1q2 0 2-2V13q0-2-2-2Z \
    M274 1h10l9 54V1h9v100h-10l-9-54v54h-9Z'/%3E%3C/svg%3E");
}

.brand-name span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.tagline {
  margin: 0 0 clamp(14px, 4svh, 30px);
  color: var(--muted);
  font-size: clamp(.85rem, 4vw, 1rem);
  font-weight: 500;
  line-height: 1.25;
  text-align: center;
}
.tagline span { color: var(--accent); font-style: italic; }

.access-actions {
  display: grid;
  gap: 9px;
  margin-top: clamp(12px, 3svh, 22px);
}

.action-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .8125rem;
  line-height: 1.35;
  text-align: center;
}
.price-star { color: #ffd879; }

.access-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: min-content;
  max-height: clamp(168px, 40svh, 355px);
  padding: clamp(12px, 3svh, 22px) 16px 16px;
  background: linear-gradient(145deg, #273931, #1b2425 72%);
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: inset 0 1px #ffffff0f, 0 16px 36px #0003;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-size: clamp(.72rem, 3.5vw, .86rem);
  line-height: 1.4;
}

.service-status {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
  color: #d3ded7;
}

.service-status::after {
  width: 7px;
  height: 7px;
  flex: none;
  align-self: center;
  content: "";
  background: #9caaa2;
  border-radius: 50%;
}

.service-status[data-state="online"]::after {
  background: #8cef9e;
  box-shadow: 0 0 0 3px #8cef9e1f;
}

.service-ping {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  margin: 0 0 0 -6px;
  padding: 2px 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-variant-numeric: tabular-nums;
}
.service-ping svg { flex: none; width: 14px; height: 14px; }
.service-ping:active:not(:disabled) { background: #ffffff14; }
.service-ping:disabled svg { opacity: .45; }
.server-location { text-align: right; }
.server-location span { display: block; color: var(--muted); }
.server-location span:last-child { white-space: nowrap; }

.shield-stage {
  position: relative;
  display: grid;
  place-items: center;
  flex: 1 0 auto;
  min-height: 55px;
  margin: 4px 0;
  color: var(--accent);
}

.shield-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: min(100%, clamp(98px, 31svh, 220px));
  height: clamp(55px, 22svh, 180px);
}

.shield-emblem::before {
  position: absolute;
  inset: -12% -24%;
  background: radial-gradient(ellipse at center, #a5ffb945, #8ee6a018 40%, transparent 70%);
  content: "";
  animation: shield-breathe 5s ease-in-out infinite alternate;
}

@keyframes shield-breathe {
  from { opacity: .46; transform: scale(.88); }
  to { opacity: 1; transform: scale(1.1); }
}

.shield-emblem svg { position: relative; width: clamp(70px, 18svh, 128px); height: auto; }
.shield-emblem path[fill="url(#shield-fill)"] {
  filter: drop-shadow(0 0 3px #a5ffb94d);
  animation: shield-outline-glow 5s ease-in-out infinite alternate;
}
@keyframes shield-outline-glow {
  from { filter: drop-shadow(0 0 2px #a5ffb940); }
  to { filter: drop-shadow(0 0 7px #a5ffb999); }
}
.shield-wordmark, .shield-wordmark-secondary { fill: currentColor; }
.shield-wordmark { font-size: 24px; font-weight: 850; }
.shield-wordmark-secondary { font-size: 20px; font-weight: 770; }

.service-icons {
  position: absolute;
  inset: 0;
  display: block;
  color: #b4bab6;
  opacity: .42;
  pointer-events: none;
  mask-image:
    radial-gradient(ellipse 72px 64px at center, transparent 30%, #000 100%),
    linear-gradient(transparent, #000 12px, #000 calc(100% - 12px), transparent);
  mask-composite: intersect;
}
.service-pattern-lines {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.service-pattern-wordmark {
  fill: currentColor;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: -.08em;
}

@media (prefers-reduced-motion: reduce) {
  .shield-emblem::before { animation: none; opacity: .65; }
  .shield-emblem path[fill="url(#shield-fill)"] { animation: none; }
}

.access-card[data-state="expired"] .shield-stage { color: #f2cb8c; }
.access-card[data-state="error"] .shield-stage { color: #f2adad; }

.access-status { padding: 5px 0 2px; text-align: center; }
.access-status h2 {
  margin: 0;
  font-size: clamp(1.05rem, 5vw, 1.3rem);
  font-weight: 640;
  letter-spacing: -.04em;
  line-height: 1.2;
}
.access-status h2:empty { display: none; }

.access-card[data-state="active"] .access-status h2 {
  font-size: .9375rem;
  font-weight: 450;
  letter-spacing: normal;
}

.card-description, .feedback, .entry-message {
  color: var(--muted);
  font-size: .875rem;
  line-height: 1.45;
}

.card-description { margin: 6px 0 0; }
.card-description:empty { display: none; }

.primary-button, .secondary-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid #adf5b5;
  border-radius: 12px;
  background: linear-gradient(115deg, #c8ffc9, #83e6a2);
  color: #15291c;
  font-weight: 680;
  font-size: .95rem;
  touch-action: manipulation;
  transition: transform 110ms ease-out, background-color 140ms ease-out, box-shadow 110ms ease-out;
}

.primary-button svg, .secondary-button svg { width: 17px; height: 17px; flex: none; }
.permanent-access-copy { display: grid; }
.permanent-access-copy > span { grid-area: 1 / 1; }
#permanent-access-status { align-self: center; }
#permanent-access[data-unavailable] .permanent-access-copy > span:first-child { visibility: hidden; }

.secondary-button {
  font-size: .88rem;
  border: 1px solid #51725a;
  border-radius: 12px;
  background: #24352e;
  color: #c5dace;
  font-weight: 650;
}
@media (hover: hover) {
  .primary-button:hover:not(:disabled) { background: #d6ffda; }
  .secondary-button:hover:not(:disabled) { background: #2c4238; }
}
.primary-button:active:not(:disabled), .secondary-button:active:not(:disabled) {
  transform: translateY(2px) scale(.985);
  box-shadow: inset 0 2px 6px #10161943;
}
.primary-button:active:not(:disabled) { background: #94e5a5; }
.secondary-button:active:not(:disabled) { background: #1d2b24; }
@media (prefers-reduced-motion: reduce) {
  .primary-button, .secondary-button { transition: none; }
}
.secondary-button:disabled { color: #a0ada5; background: #222d27; border-color: #43534b; }
.feedback {
  min-block-size: 2.9em;
  margin: 0;
  text-align: center;
}

.key-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 6px;
}
.key-panel input {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #51725a;
  border-radius: 12px;
  background: #18251f;
  color: #e6f4ea;
  font: .82rem ui-monospace, monospace;
}
.key-panel input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.key-panel button { width: auto; }

.text-button {
  min-height: 44px;
  margin-top: 8px;
  padding: 0 10px;
  border: 1px solid #5e8068;
  border-radius: 8px;
  color: var(--accent);
  background: transparent;
  font-size: .875rem;
}

.setup-note {
  margin: clamp(10px, 2svh, 16px) auto 0;
  max-width: 32ch;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
  text-align: center;
}
.setup-note p { margin: 0; }
.support-note { padding-top: 10px; }
:is(.setup-note, .action-note) a { color: var(--accent); text-underline-offset: .15em; }
:is(.setup-note, .action-note) a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.entry-message { margin: 0; text-align: center; }

@media (max-height: 500px) {
  .app { padding-top: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .brand { margin-bottom: 4px; }
  .dashboard .brand { row-gap: 4px; }
  .brand-name { width: 111px; }
  .tagline { margin-bottom: 8px; }
  .access-actions { gap: 4px; margin-top: 8px; }
  .action-note { margin-top: 2px; }
  .access-card { padding-top: 6px; padding-bottom: 5px; }
  .service-ping { min-height: 24px; }
  .shield-emblem { height: 58px; }
  .shield-stage { margin-block: 2px; }
  .shield-emblem svg { width: 66px; }
  .feedback { font-size: .79rem; }
  .setup-note { margin-top: 5px; max-width: 42ch; }
  .support-note { padding-top: 6px; }
}
