:root {
  --color-paper: #F8F9FC;
  --color-grid: #E5E7EF;
  --color-blue: #2563EB;
  --color-light-blue: #60A5FA;
  --color-purple: #8B5CF6;
  --color-pink: #EC4899;
  --color-orange: #F97316;
  --color-text: #111827;
  --color-text-muted: #6B7280;
  --color-text-light: #9CA3AF;
  --color-green: #22c55e;
  --color-yellow: #eab308;
  --color-red: #ef4444;

  --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  --grid-size: 40px;
  --navbar-height: 58px;
  --safe-area-top: env(safe-area-inset-top, 0px);
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);

  --r-panel: 24px;
  --r-card: 16px;
  --r-tile: 12px;
  --r-button: 10px;
  --r-chip: 999px;

  --glass-fill: rgba(255,255,255,0.5);
  --glass-blur: blur(22px) saturate(165%);
  --shadow-panel: 0 10px 32px rgba(84,66,170,0.12), inset 0 1px 0 rgba(255,255,255,0.9), inset 0 -1px 0 rgba(108,84,216,0.08);

  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;

  --plans-gap: 1.5rem;
}

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-paper);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  position: relative;
  overflow-x: hidden;
  padding-top: calc(var(--navbar-height) + var(--safe-area-top) + 24px);
  padding-bottom: calc(2rem + var(--safe-area-bottom));
  padding-left: 1rem;
  padding-right: 1rem;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image:
    linear-gradient(to right, var(--color-grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--color-grid) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  pointer-events: none;
  z-index: -2;
}

body::after {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 600px 400px at 20% 20%, rgba(37, 99, 235, 0.04) 0%, transparent 70%),
    radial-gradient(ellipse 500px 350px at 80% 30%, rgba(139, 92, 246, 0.03) 0%, transparent 70%),
    radial-gradient(ellipse 400px 300px at 70% 80%, rgba(236, 72, 153, 0.03) 0%, transparent 70%);
  pointer-events: none;
  z-index: -1;
}

a { color: inherit; text-decoration: none; transition: color var(--transition-fast); }
button { font-family: inherit; font-size: inherit; border: none; background: none; cursor: pointer; }
button, a, input { touch-action: manipulation; }
img { max-width: 100%; height: auto; display: block; }

a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--color-text);
  outline-offset: 3px;
  border-radius: 8px;
}

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

.navbar {
  position: fixed;
  top: calc(12px + var(--safe-area-top));
  left: 12px;
  right: 12px;
  height: var(--navbar-height);
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255,255,255,0.55);
  box-shadow: var(--shadow-panel);
  border-radius: var(--r-panel);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 1.2rem;
  z-index: 1000;
  max-width: 1040px;
  margin: 0 auto;
}

.nav-back-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--color-grid);
  color: var(--color-text);
  text-decoration: none;
  transition: all var(--transition-fast);
}

.nav-back-icon:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--color-text);
  color: var(--color-text);
}

.nav-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.shop-container {
  width: 100%;
  max-width: 1040px;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.shop-header {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.25rem 0.25rem 0.25rem 1rem;
}

.shop-header::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -2px;
  width: 4px;
  height: 56px;
  background: var(--color-yellow);
  border-radius: 3px;
  opacity: 0.55;
  pointer-events: none;
}

.shop-header::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -2px;
  width: 40px;
  height: 4px;
  background: var(--color-yellow);
  border-radius: 3px;
  opacity: 0.55;
  pointer-events: none;
}

.shop-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
}

.shop-eyebrow::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 2px;
  background: var(--color-text);
  border-radius: 1px;
}

.shop-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.shop-header p {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.plans-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--plans-gap);
  padding: 0.4rem;
}

.plan-card {
  --tier-color: var(--color-text-light);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  flex: 0 0 100%;
  min-width: 0;
  padding: 1.6rem 1.4rem 1.4rem;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--color-grid);
  border-radius: var(--r-card);
  transition: transform var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.plan-card::before {
  content: '';
  position: absolute;
  top: -7px;
  left: -7px;
  width: 28px;
  height: 28px;
  border-top: 3px solid var(--tier-color);
  border-left: 3px solid var(--tier-color);
  border-top-left-radius: 8px;
  opacity: 0.7;
  pointer-events: none;
}

.plan-card::after {
  content: '';
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 28px;
  height: 28px;
  border-right: 3px solid var(--tier-color);
  border-bottom: 3px solid var(--tier-color);
  border-bottom-right-radius: 8px;
  opacity: 0.7;
  pointer-events: none;
}

.plan-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.85);
  border-color: var(--tier-color);
}

.plan-card.tier-common { --tier-color: #9CA3AF; }
.plan-card.tier-starter { --tier-color: var(--color-orange); }
.plan-card.tier-silver { --tier-color: var(--color-light-blue); }
.plan-card.tier-gold { --tier-color: var(--color-yellow); }
.plan-card.tier-platinum { --tier-color: var(--color-green); }
.plan-card.tier-ultra { --tier-color: var(--color-pink); }
.plan-card.tier-ultimate { --tier-color: var(--color-purple); }

.plan-card.is-featured {
  border-color: rgba(234, 179, 8, 0.5);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 12px 30px rgba(234, 179, 8, 0.14);
}

.plan-card.is-featured:hover {
  border-color: var(--color-yellow);
}

.plan-index {
  position: absolute;
  top: 14px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--color-text-light);
}

.plan-index::before {
  content: '';
  width: 14px;
  height: 2px;
  background: var(--tier-color);
  border-radius: 1px;
  transform: rotate(-35deg);
}

.plan-badge {
  position: absolute;
  top: -12px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.3rem 1.2rem;
  background: var(--color-yellow);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  clip-path: polygon(10px 0, 100% 0, calc(100% - 10px) 100%, 0 100%);
  z-index: 2;
}

.plan-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tier-logo {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255, 255, 255, 0.95);
  outline: 2px solid var(--tier-color);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  display: block;
}

.plan-title {
  min-width: 0;
}

.plan-title h3 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.plan-price {
  font-family: var(--font-mono);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.plan-specs {
  list-style: none;
  padding: 0.25rem 0.9rem;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid var(--color-grid);
  border-radius: var(--r-tile);
}

.plan-specs li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed var(--color-grid);
  font-size: 0.85rem;
}

.plan-specs li:last-child {
  border-bottom: none;
}

.plan-specs span {
  color: var(--color-text-muted);
  white-space: nowrap;
}

.plan-specs strong {
  font-weight: 600;
  color: var(--color-text);
  text-align: right;
}

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.plan-features li {
  font-size: 0.8125rem;
  font-weight: 500;
}

.plan-features li.supported {
  color: #16a34a;
}

.plan-features li.supported::before {
  content: "✓ ";
}

.plan-features li.unsupported {
  color: var(--color-text-light);
  text-decoration: line-through;
}

.plan-features li.unsupported::before {
  content: "✗ ";
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.85rem 1.5rem;
  border-radius: var(--r-button);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.btn-buy {
  width: 100%;
  background: var(--color-text);
  color: #fff;
  border-color: var(--color-text);
  box-shadow: 4px 4px 0 var(--tier-color, var(--color-text-light));
}

.plan-card .btn-buy {
  margin-top: auto;
}

.btn-buy:hover {
  color: #fff;
  background: #1f2937;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--tier-color, var(--color-text-light));
}

.btn-buy:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--tier-color, var(--color-text-light));
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 2000;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: #FFFFFF;
  border: 1px solid var(--color-grid);
  border-radius: var(--r-card);
  padding: 2rem;
  max-width: 420px;
  width: 100%;
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.modal-overlay.show .modal-box {
  transform: translateY(0);
}

.modal-box h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 1rem;
  text-align: center;
}

.terms-content {
  background: rgba(17, 24, 39, 0.04);
  border: 1px solid var(--color-grid);
  border-radius: var(--r-tile);
  padding: 1rem;
  margin-bottom: 1rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  line-height: 1.6;
}

.terms-content p {
  margin-bottom: 0.75rem;
}

.terms-content p:last-child {
  margin-bottom: 0;
}

.timer-box {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--color-text-light);
  margin-bottom: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: 1.5rem;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-text);
  flex-shrink: 0;
  margin-top: 2px;
}

.checkbox-label input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.btn-cancel {
  flex: 1;
  background: rgba(255, 255, 255, 0.5);
  border-color: var(--color-grid);
  color: var(--color-text-muted);
}

.btn-cancel:hover {
  background: #ffffff;
  border-color: var(--color-text-muted);
  color: var(--color-text);
}

.btn-confirm {
  flex: 1;
  background: var(--color-text);
  color: #fff;
  border-color: var(--color-text);
  box-shadow: 4px 4px 0 var(--color-yellow);
}

.btn-confirm:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-confirm:not(:disabled):hover {
  background: #1f2937;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--color-yellow);
  color: #fff;
}

@media (min-width: 640px) {
  .plan-card {
    flex-basis: calc((100% - var(--plans-gap)) / 2);
  }
}

@media (min-width: 980px) {
  .plan-card {
    flex-basis: calc((100% - (var(--plans-gap) * 2)) / 3);
  }

  .shop-header h1 {
    font-size: 1.85rem;
  }
}

@media (min-width: 769px) {
  body {
    padding: calc(var(--navbar-height) + var(--safe-area-top) + 2rem) 1.5rem 2rem;
  }

  .navbar {
    left: 20px;
    right: 20px;
  }
}

@media (max-width: 600px) {
  body {
    padding: 80px 0.75rem 1.5rem;
  }

  .navbar {
    top: 10px;
    left: 10px;
    right: 10px;
    height: 52px;
  }

  .plans-grid {
    padding: 0.4rem 0.35rem;
  }

  .plan-card {
    padding: 1.5rem 1.15rem 1.2rem;
  }

  .modal-box {
    padding: 1.5rem;
  }
}

@media (prefers-reduced-transparency: reduce) {
  body::before,
  body::after {
    display: none;
  }

  .navbar {
    background: rgba(248, 249, 252, 0.98);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .plan-card,
  .modal-box {
    background: rgba(255, 255, 255, 0.95);
  }
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .navbar {
    background: rgba(248, 249, 252, 0.98);
  }

  .modal-overlay {
    background: rgba(17, 24, 39, 0.7);
  }
}