/* ===== CSS Variables ===== */
:root {
  --bg: #f5f5f7;
  --bg-card: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-active: #006edb;
  --border: #d2d2d7;
  --error: #ff3b30;
  --success: #34c759;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --max-width: 640px;
  --android-color: #3ddc84;
  --windows-color: #0078d4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1c1e;
    --bg-card: #2c2c2e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #8e8e93;
    --accent: #0a84ff;
    --accent-hover: #409cff;
    --accent-active: #0071e3;
    --border: #3a3a3c;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.4);
  }
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
}

/* ===== Screen ===== */
.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* ===== Auth Screen ===== */
#auth-screen {
  min-height: 100vh;
  display: none;
  align-items: center;
  justify-content: center;
}

#auth-screen.active {
  display: flex;
}

.auth-container {
  text-align: center;
  padding: 40px 24px;
  max-width: 360px;
  width: 100%;
}

.auth-icon {
  width: 96px;
  height: 96px;
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  margin-bottom: 20px;
}

.auth-title {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.input-wrapper input {
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s;
}

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

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== Spinner ===== */
.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-large {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== Error ===== */
.error-msg {
  color: var(--error);
  font-size: 14px;
  margin-top: 4px;
}

.hidden {
  display: none !important;
}

/* ===== Shake Animation ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

/* ===== Store Header ===== */
.store-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 16px 20px;
}

.header-title {
  font-size: 20px;
  font-weight: 700;
}

/* ===== Store Main ===== */
.store-main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 24px 20px;
  min-height: calc(100vh - 120px);
}

/* ===== Loading & Error ===== */
.loading-container,
.error-container {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.error-icon {
  width: 56px;
  height: 56px;
  line-height: 56px;
  border-radius: 50%;
  background: var(--error);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  margin: 0 auto 16px;
}

#store-error-msg {
  margin-bottom: 20px;
}

/* ===== App Card ===== */
.app-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.app-info {
  display: flex;
  gap: 16px;
  padding: 24px;
  align-items: center;
}

.app-icon {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.app-meta {
  min-width: 0;
}

.app-name {
  font-size: 22px;
  font-weight: 700;
}

.app-desc {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.app-version {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot-sep::before {
  content: '\00B7';
  font-weight: 700;
}

/* ===== Download Buttons ===== */
.download-buttons {
  display: flex;
  gap: 12px;
  padding: 0 24px 24px;
}

.dl-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 16px 12px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: inherit;
  position: relative;
}

.dl-btn:active {
  transform: scale(0.97);
}

.dl-btn.android {
  background: #e8f9ee;
  color: #1b7a3a;
}

.dl-btn.android:hover {
  background: #d4f4df;
}

.dl-btn.windows {
  background: #e5f1fb;
  color: #0057a3;
}

.dl-btn.windows:hover {
  background: #cce4f7;
}

@media (prefers-color-scheme: dark) {
  .dl-btn.android {
    background: #1a3d28;
    color: #6ee79a;
  }
  .dl-btn.android:hover {
    background: #224d33;
  }
  .dl-btn.windows {
    background: #1a2f45;
    color: #6db8f2;
  }
  .dl-btn.windows:hover {
    background: #223b55;
  }
}

.dl-btn.recommended {
  box-shadow: 0 0 0 2px var(--accent);
}

.dl-btn-platform {
  font-size: 14px;
  font-weight: 700;
}

.dl-btn-action {
  font-size: 15px;
  font-weight: 600;
}

.dl-btn-size {
  font-size: 12px;
  opacity: 0.7;
}

.dl-btn .btn-spinner {
  border-color: rgba(0, 0, 0, 0.15);
  border-top-color: currentColor;
  width: 20px;
  height: 20px;
}

.dl-btn-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

/* ===== Release Notes ===== */
.release-notes {
  padding: 24px;
  border-top: 1px solid var(--border);
}

.release-notes h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.notes-content {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ===== Install Guide ===== */
.install-guide {
  padding: 24px;
  border-top: 1px solid var(--border);
}

.install-guide h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

.guide-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.guide-item {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 16px;
}

.guide-platform {
  font-size: 13px;
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.guide-item ol {
  padding-left: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.guide-item li {
  margin-bottom: 4px;
}

/* ===== Footer ===== */
.store-footer {
  text-align: center;
  padding: 20px;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .app-info {
    padding: 20px 16px;
  }

  .download-buttons {
    flex-direction: column;
    padding: 0 16px 20px;
  }

  .guide-grid {
    grid-template-columns: 1fr;
  }

  .release-notes,
  .install-guide {
    padding: 20px 16px;
  }
}
