/* ========================================
   Terraria Web Launcher — style.css
   ======================================== */

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

:root {
  --bg:        #050a0f;
  --bg2:       #0a1520;
  --card:      #0d1f2d;
  --card2:     #112233;
  --border:    rgba(0,200,255,0.12);
  --accent:    #00c8ff;
  --accent2:   #7b4fff;
  --gold:      #f0c040;
  --green:     #28e896;
  --red:       #ff4b4b;
  --text:      #e8f4ff;
  --muted:     #5b7a9a;
  --radius:    16px;
  --shadow:    0 8px 40px rgba(0,0,0,0.6);
}

html, body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  overflow-x: hidden;
}

/* ── Stars Background ── */
.stars {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  overflow: hidden;
}
.star {
  position: absolute;
  border-radius: 50%;
  background: white;
  animation: twinkle var(--dur, 3s) ease-in-out infinite;
  opacity: 0;
}
@keyframes twinkle {
  0%,100% { opacity: 0; transform: scale(0.5); }
  50% { opacity: var(--op, 0.8); transform: scale(1); }
}

.bg-glow {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 60% 40% at 20% 50%, rgba(0,200,255,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 50% 60% at 80% 30%, rgba(123,79,255,0.06) 0%, transparent 70%),
    radial-gradient(ellipse 40% 50% at 50% 90%, rgba(240,192,64,0.04) 0%, transparent 70%);
}

/* ── Layout ── */
.container {
  position: relative; z-index: 1;
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex; flex-direction: column; gap: 24px;
}

/* ── Header ── */
.header {
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 12px;
  padding: 20px 28px;
  background: linear-gradient(135deg, rgba(0,200,255,0.08), rgba(123,79,255,0.08));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
}
.logo-wrap { display: flex; align-items: center; gap: 16px; }
.logo-icon { font-size: 2.5rem; filter: drop-shadow(0 0 12px rgba(240,192,64,0.6)); }
.logo-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(1rem, 4vw, 1.6rem);
  background: linear-gradient(135deg, var(--gold), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  line-height: 1.3;
  text-shadow: none;
}
.logo-sub { font-size: 0.75rem; color: var(--muted); margin-top: 4px; }

.badges { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  padding: 4px 10px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em;
}
.badge-green { background: rgba(40,232,150,0.15); color: var(--green); border: 1px solid rgba(40,232,150,0.3); }
.badge-blue  { background: rgba(0,200,255,0.12);  color: var(--accent); border: 1px solid rgba(0,200,255,0.25); }
.badge-purple{ background: rgba(123,79,255,0.12); color: #b090ff; border: 1px solid rgba(123,79,255,0.3); }

/* ── Card ── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 36px;
  box-shadow: var(--shadow);
  min-height: 380px;
  display: flex; align-items: center; justify-content: center;
}

/* ── Steps ── */
.step {
  display: none;
  flex-direction: column; align-items: center;
  text-align: center; gap: 18px;
  width: 100%;
  animation: fadeIn 0.4s ease;
}
.step.active { display: flex; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-icon {
  font-size: 3.5rem;
  filter: drop-shadow(0 0 20px rgba(0,200,255,0.4));
  line-height: 1;
}
.step-icon.spin { animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.step h2 {
  font-size: 1.6rem; font-weight: 700;
  background: linear-gradient(135deg, #fff, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.step-desc { color: var(--muted); font-size: 0.95rem; line-height: 1.7; max-width: 500px; }

/* ── Info Grid ── */
.info-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 12px;
  width: 100%; max-width: 500px;
}
.info-item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 14px 8px;
  background: var(--bg2); border: 1px solid var(--border); border-radius: 12px;
}
.info-icon { font-size: 1.4rem; }
.info-label { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.info-val   { font-size: 0.78rem; font-weight: 600; color: var(--accent); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 32px; border-radius: 12px;
  font-size: 1rem; font-weight: 600; cursor: pointer;
  border: none; transition: all 0.25s;
  letter-spacing: 0.02em;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  box-shadow: 0 4px 20px rgba(0,200,255,0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0,200,255,0.5);
}
.btn-primary:active { transform: translateY(0); }
.btn-outline {
  background: transparent;
  color: var(--accent); border: 1.5px solid var(--accent);
}
.btn-outline:hover { background: rgba(0,200,255,0.08); }
.btn-launch { font-size: 1.15rem; padding: 18px 44px; }
.link-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: inherit; text-decoration: underline;
}

/* ── Progress ── */
.progress-wrap { width: 100%; max-width: 560px; }
.progress-bar-bg {
  height: 10px; border-radius: 10px;
  background: rgba(255,255,255,0.06); overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.progress-bar {
  height: 100%; border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(0,200,255,0.5);
  position: relative;
}
.progress-bar::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 1.5s infinite;
}
@keyframes shimmer {
  from { transform: translateX(-100%); }
  to   { transform: translateX(100%); }
}
.progress-labels {
  display: flex; justify-content: space-between;
  font-size: 0.75rem; color: var(--muted); margin-top: 6px;
}

/* ── Chunk Grid ── */
.chunk-grid {
  display: flex; flex-wrap: wrap; gap: 5px;
  max-width: 560px; justify-content: center;
}
.chunk-dot {
  width: 12px; height: 12px; border-radius: 3px;
  background: rgba(255,255,255,0.06);
  transition: all 0.3s;
}
.chunk-dot.done    { background: var(--green);  box-shadow: 0 0 6px rgba(40,232,150,0.5); }
.chunk-dot.active  { background: var(--accent); box-shadow: 0 0 6px rgba(0,200,255,0.6); animation: pulse 0.8s ease infinite; }
.chunk-dot.error   { background: var(--red); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── DL Stats ── */
.dl-stats {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 10px;
  width: 100%; max-width: 560px;
}
.stat-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px; background: var(--bg2); border-radius: 10px;
  border: 1px solid var(--border);
}
.stat-label { font-size: 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }
.stat-val   { font-size: 0.85rem; font-weight: 700; color: var(--text); }

/* ── Log Box ── */
.log-box {
  width: 100%; max-width: 560px; max-height: 180px;
  overflow-y: auto; background: var(--bg);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 16px; font-family: monospace; font-size: 0.78rem;
  color: var(--green); line-height: 1.7;
  text-align: left;
}
.log-box::-webkit-scrollbar { width: 5px; }
.log-box::-webkit-scrollbar-track { background: transparent; }
.log-box::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.log-line { animation: fadeIn 0.2s ease; }
.log-line.warn  { color: var(--gold); }
.log-line.error { color: var(--red); }

/* ── Hint ── */
.hint { font-size: 0.8rem; color: var(--muted); margin-top: -6px; }

/* ── Game Wrap ── */
.game-wrap {
  position: fixed; inset: 0; z-index: 100;
  background: #000;
  display: flex; flex-direction: column;
}
.game-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 16px; background: var(--bg2);
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.game-title { font-weight: 700; font-size: 0.95rem; color: var(--accent); }
.game-controls { display: flex; gap: 8px; }
.ctrl-btn {
  padding: 6px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); cursor: pointer;
  font-size: 1rem; transition: all 0.2s;
}
.ctrl-btn:hover { background: var(--card2); border-color: var(--accent); }
.ctrl-btn.danger:hover { border-color: var(--red); color: var(--red); }

#screen-container {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #000;
}
#game-canvas { max-width: 100%; max-height: 100%; display: block; }

.game-status-bar {
  display: flex; gap: 20px; align-items: center;
  padding: 6px 16px; background: var(--bg);
  border-top: 1px solid var(--border); flex-shrink: 0;
  font-size: 0.72rem; color: var(--muted); font-family: monospace;
}

/* ── Footer ── */
.footer { text-align: center; font-size: 0.72rem; color: var(--muted); padding-top: 8px; }

/* ── Responsive ── */
@media (max-width: 540px) {
  .card { padding: 28px 18px; }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .dl-stats  { grid-template-columns: 1fr 1fr; }
  .header { flex-direction: column; }
}
