:root {
  --bg: var(--tg-theme-bg-color, #0a0a1a);
  --text: var(--tg-theme-text-color, #e0e0ff);
  --hint: var(--tg-theme-hint-color, #7a7a9a);
  --btn: var(--tg-theme-button-color, #6c5ce7);
  --btn-text: var(--tg-theme-button-text-color, #ffffff);
  --secondary-bg: var(--tg-theme-secondary-bg-color, #12122a);

  --vip: #f0c040;
  --vip-glow: rgba(240, 192, 64, 0.4);
  --standard: #4a9eff;
  --standard-glow: rgba(74, 158, 255, 0.3);
  --balcony: #a855f7;
  --balcony-glow: rgba(168, 85, 247, 0.3);
  --selected: #22c55e;
  --selected-glow: rgba(34, 197, 94, 0.5);
  --taken: #2a2a3a;
  --taken-text: #444;
}

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

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

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-bottom: 140px;
}

header {
  text-align: center;
  padding: 16px 16px 8px;
}

header h1 {
  font-size: 22px;
  background: linear-gradient(135deg, var(--vip), #ff6b9d, var(--balcony));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--hint);
  font-size: 13px;
  margin-top: 4px;
}

/* Legend */
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--hint);
}

.seat-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.seat-dot.vip { background: var(--vip); box-shadow: 0 0 6px var(--vip-glow); }
.seat-dot.standard { background: var(--standard); box-shadow: 0 0 6px var(--standard-glow); }
.seat-dot.balcony { background: var(--balcony); box-shadow: 0 0 6px var(--balcony-glow); }
.seat-dot.selected { background: var(--selected); box-shadow: 0 0 6px var(--selected-glow); }
.seat-dot.taken { background: var(--taken); }

/* Hall */
.hall-wrapper {
  flex: 1;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 4px;
  touch-action: pan-x pan-y pinch-zoom;
}

.hall {
  min-width: 600px;
  padding: 10px 20px 20px;
  transform-origin: top center;
  transition: transform 0.1s;
}

/* Stage */
.stage {
  margin: 0 auto 16px;
  width: 70%;
  perspective: 200px;
}

.stage-inner {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.3), rgba(74, 158, 255, 0.1));
  border: 1px solid rgba(168, 85, 247, 0.4);
  border-radius: 50% 50% 0 0 / 30% 30% 0 0;
  padding: 18px 0 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--balcony);
  text-transform: uppercase;
  transform: rotateX(10deg);
  box-shadow: 0 4px 30px rgba(168, 85, 247, 0.15), inset 0 -2px 20px rgba(168, 85, 247, 0.1);
}

/* Section labels */
.section-label {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--hint);
  margin: 12px 0 6px;
  position: relative;
}

.section-label::before,
.section-label::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 25%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
}
.section-label::before { left: 5%; }
.section-label::after { right: 5%; }

/* Rows */
.row {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 3px 0;
  gap: 2px;
}

.row-label {
  width: 22px;
  font-size: 10px;
  font-weight: 600;
  color: var(--hint);
  text-align: center;
  flex-shrink: 0;
}

.seats {
  display: flex;
  gap: 2px;
  justify-content: center;
}

/* Seats */
.seat {
  width: 18px;
  height: 18px;
  border-radius: 4px 4px 2px 2px;
  font-size: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
  border: none;
  outline: none;
  -webkit-appearance: none;
}

.seat.vip {
  background: linear-gradient(135deg, var(--vip), #d4a020);
  box-shadow: 0 0 4px var(--vip-glow);
}
.seat.standard {
  background: linear-gradient(135deg, var(--standard), #2a7adf);
  box-shadow: 0 0 4px var(--standard-glow);
}
.seat.balcony-seat {
  background: linear-gradient(135deg, var(--balcony), #8030d7);
  box-shadow: 0 0 4px var(--balcony-glow);
}

.seat.selected {
  background: var(--selected) !important;
  box-shadow: 0 0 8px var(--selected-glow), 0 0 16px rgba(34, 197, 94, 0.2) !important;
  transform: scale(1.15);
}

.seat.taken {
  background: var(--taken) !important;
  box-shadow: none !important;
  cursor: not-allowed;
  opacity: 0.5;
}

.seat:not(.taken):not(.selected):hover {
  transform: scale(1.2);
  filter: brightness(1.3);
}

.seat:not(.taken):not(.selected):active {
  transform: scale(0.95);
}

/* Tooltip */
.tooltip {
  position: fixed;
  background: rgba(15, 15, 35, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 100;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  white-space: nowrap;
}

.tooltip.visible { opacity: 1; }

.tooltip .tip-row { color: var(--hint); font-size: 11px; }
.tooltip .tip-seat { font-weight: 700; font-size: 15px; margin: 2px 0; }
.tooltip .tip-price { color: var(--selected); font-weight: 600; }

/* Cart */
.cart {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(12, 12, 30, 0.95);
  backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255,255,255,0.08);
  z-index: 50;
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 30px rgba(0,0,0,0.4);
  transition: transform 0.3s ease;
}

.cart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
}

.cart-total {
  background: linear-gradient(135deg, var(--selected), #16a34a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 18px;
  font-weight: 800;
}

.cart-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  padding: 0 20px;
}

.cart-body.open {
  max-height: 300px;
  padding: 0 20px 16px;
}

.cart-items {
  max-height: 150px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.cart-empty {
  color: var(--hint);
  text-align: center;
  font-size: 13px;
  padding: 8px 0;
}

.cart-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.cart-item-name { font-weight: 500; }

.cart-item-price { color: var(--hint); }

.cart-item-remove {
  background: none;
  border: none;
  color: #ef4444;
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}
.cart-item-remove:hover { background: rgba(239,68,68,0.15); }

.pay-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  background: linear-gradient(135deg, var(--btn), #8b5cf6);
  color: var(--btn-text);
  transition: all 0.2s;
  box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

.pay-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.pay-btn:not(:disabled):active {
  transform: scale(0.98);
}

/* Balcony divider */
.balcony-divider {
  margin: 16px auto 8px;
  width: 80%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--balcony), transparent);
  border-radius: 2px;
  opacity: 0.5;
}

/* Scrollbar */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

@media (min-width: 500px) {
  .seat { width: 22px; height: 22px; }
  .seats { gap: 3px; }
  .row { gap: 4px; margin: 4px 0; }
  .row-label { width: 28px; font-size: 11px; }
}
