/* ===== TikTok Battle Arena - Design System ===== */

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

/* Typography & Variables */
:root {
  --font-display: 'Orbitron', monospace, sans-serif;
  --font-body: 'Rajdhani', sans-serif;

  /* Color Palette */
  --bg-primary: #06060e;
  --bg-secondary: #0b0b1a;
  --bg-panel: rgba(10, 12, 24, 0.95);
  --bg-card: rgba(15, 20, 38, 0.85);
  
  --text-primary: #ffffff;
  --text-secondary: #8d98b5;
  --text-muted: #4e5775;
  
  --accent-blue: #1a73e8;
  --accent-cyan: #00d4ff;
  --accent-gold: #ffd700;
  --accent-red: #ff2244;
  --accent-green: #00cc66;
  --accent-orange: #ff8800;
  
  --border-subtle: rgba(0, 212, 255, 0.15);
  --border-glow: rgba(0, 212, 255, 0.4);
  
  /* Fixed Logical Dimensions for TikTok LIVE (9:16 Portrait) - 2 Zone Layout */
  --screen-width: 1080px;
  --screen-height: 1920px;
  --arena-width: 1080px;
  --arena-height: 1200px;
  --guide-height: 0px;
  --reserved-height: 720px;
}

html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #030308;
  font-family: var(--font-body);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* App Container - 1080x1920 Logical Canvas with dynamic auto-fit transform scale */
#app {
  width: var(--screen-width);
  height: var(--screen-height);
  max-width: 1080px;
  max-height: 1920px;
  transform-origin: center center;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary);
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.95);
}

/* ===== 1. Battle Arena Container (1080 x 1140) ===== */
#battle-arena {
  width: var(--arena-width);
  height: var(--arena-height);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

#arena-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ===== 2. High-Visibility Gift Guide Section (1080 x 240) ===== */
#gift-guide-area {
  width: var(--screen-width);
  height: var(--guide-height);
  flex-shrink: 0;
  background: linear-gradient(180deg, #090b16 0%, #060710 100%);
  border-top: 1.5px solid rgba(0, 212, 255, 0.2);
  border-bottom: 1.5px solid rgba(0, 212, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  position: relative;
  overflow: hidden;
}

/* 8 Prominent Horizontal Gift Pills (4 columns x 2 rows) */
.gift-guide-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 8px 8px;
  width: 100%;
  height: 100%;
}

.guide-pill {
  background: rgba(14, 18, 34, 0.94);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 6px 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.guide-pill::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 3.5px;
  background: var(--country-color, #00d4ff);
  box-shadow: 0 0 8px var(--country-color, #00d4ff);
}

.guide-pill:hover {
  transform: translateY(-2px);
  border-color: var(--country-color, var(--border-glow));
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7), 0 0 14px rgba(var(--country-rgb), 0.4);
}

/* Gift Left Group: PNG Image + Gift Name */
.pill-gift-group {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.pill-gift-img {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
  image-rendering: auto;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.6));
}

.pill-gift-name {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

/* Arrow Divider */
.pill-arrow {
  color: rgba(255, 255, 255, 0.4);
  font-size: 12px;
  font-weight: 700;
  margin: 0 2px;
  flex-shrink: 0;
}

/* Country Right Group: Vector Flag + Country Name */
.pill-country-group {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.pill-flag-canvas {
  width: 30px;
  height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.7);
}

.pill-country-name {
  font-family: var(--font-display);
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
  color: var(--country-color, #ffffff);
  text-shadow: 0 0 10px rgba(var(--country-rgb), 0.5);
  white-space: nowrap;
}

/* ===== 3. Video / Content Reserved Section (1080 x 540) ===== */
#reserved-content-area {
  width: var(--screen-width);
  height: var(--reserved-height);
  flex-shrink: 0;
  background: radial-gradient(circle at 50% 30%, #060714 0%, #020206 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.reserved-content-box {
  width: 100%;
  height: 100%;
  border: 1.5px dashed rgba(0, 212, 255, 0.12);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(10, 14, 28, 0.4);
}

.reserved-badge {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  color: rgba(0, 212, 255, 0.6);
  letter-spacing: 1.5px;
  background: rgba(0, 212, 255, 0.06);
  padding: 4px 12px;
  border-radius: 12px;
  border: 1px solid rgba(0, 212, 255, 0.15);
}

.reserved-hint {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* ===== Developer Panel ===== */
.dev-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: var(--bg-panel);
  backdrop-filter: blur(24px);
  border-left: 1px solid var(--border-subtle);
  z-index: 10000;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-body);
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.dev-panel.hidden {
  transform: translateX(100%);
  pointer-events: none;
}

.dev-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.dev-panel-header h3 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent-cyan);
}

.dev-close-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-secondary);
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.dev-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.dev-section {
  margin-bottom: 18px;
}

.dev-section h4 {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.dev-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.dev-section-header h4 {
  margin-bottom: 0;
}

/* Status Indicator */
.dev-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
  flex-shrink: 0;
}

.status-dot.connected {
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

.status-dot.disconnected {
  background: var(--accent-red);
  box-shadow: 0 0 8px var(--accent-red);
}

.status-dot.connecting {
  background: var(--accent-orange);
  box-shadow: 0 0 8px var(--accent-orange);
  animation: blink 1s infinite;
}

.status-dot.test {
  background: var(--accent-gold);
  box-shadow: 0 0 8px var(--accent-gold);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-text {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
}

/* Input Group */
.dev-input-group {
  display: flex;
  gap: 8px;
}

.dev-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
}

.dev-input:focus {
  border-color: var(--accent-cyan);
}

/* Last Gift Diagnostic Inspector */
.dev-last-gift-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.gift-diag-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.diag-label {
  color: var(--text-muted);
  font-weight: 600;
}

.diag-val {
  color: var(--accent-cyan);
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 12px;
}

/* Buttons */
.dev-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  padding: 8px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.dev-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.dev-btn:active {
  transform: translateY(0);
}

.dev-btn-accent {
  background: rgba(0, 212, 255, 0.15);
  border-color: rgba(0, 212, 255, 0.35);
  color: var(--accent-cyan);
}

.dev-btn-accent:hover {
  background: rgba(0, 212, 255, 0.25);
  border-color: var(--accent-cyan);
}

.dev-btn-warning {
  background: rgba(255, 136, 0, 0.15);
  border-color: rgba(255, 136, 0, 0.35);
  color: var(--accent-orange);
}

.dev-btn-warning:hover {
  background: rgba(255, 136, 0, 0.25);
  border-color: var(--accent-orange);
}

.dev-btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
}

.dev-btn-text:hover {
  color: var(--text-secondary);
}

/* Button Grids */
.dev-gift-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.dev-country-btn {
  border-left: 3px solid var(--country-color, #666);
  text-align: left;
}

.dev-action-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.dev-action-row .dev-btn {
  flex: 1;
  text-align: center;
}

/* Event Log */
.dev-event-log {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  height: 160px;
  overflow-y: auto;
  padding: 8px;
  font-size: 12px;
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: var(--text-muted) transparent;
}

.dev-log-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dev-log-entry:last-child {
  border-bottom: none;
}

.log-time {
  color: var(--text-muted);
  font-size: 11px;
}

.log-gift {
  color: var(--accent-gold);
  font-weight: 600;
}

.log-user {
  color: var(--accent-cyan);
}

.log-country {
  color: var(--text-primary);
  font-weight: 600;
}

.log-score {
  color: var(--accent-green);
  font-weight: 700;
}

.log-unknown {
  color: var(--accent-red);
  font-weight: 700;
}
