:root {
  --bg: #0f172a;
  --bg-alt: #1e293b;
  --card: #ffffff;
  --card-dark: #1e293b;
  --text: #f8fafc;
  --text-dark: #0f172a;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #818cf8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --radius: 16px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: linear-gradient(160deg, #0f172a 0%, #1e1b4b 50%, #312e81 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  padding-top: var(--safe-top);
  padding-bottom: calc(120px + var(--safe-bottom));
}

#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

/* ===== Hero ===== */
.hero {
  text-align: center;
  padding: 24px 8px 16px;
}

.hero h1 {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 800;
  letter-spacing: 0.02em;
}

.hero .emoji {
  font-size: 44px;
  filter: drop-shadow(0 4px 12px rgba(99, 102, 241, 0.4));
}

.tagline {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

/* ===== Card ===== */
.card {
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 20px;
  margin-top: 16px;
  box-shadow: var(--shadow);
  animation: cardIn 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.card.hidden { display: none; }

.card h2 {
  margin: 16px 0 4px;
  font-size: clamp(22px, 5.5vw, 28px);
  text-align: center;
  font-weight: 800;
}

.motto {
  text-align: center;
  color: var(--accent);
  font-style: italic;
  font-size: 14px;
  margin: 0 0 16px;
  opacity: 0.9;
}

/* ===== Flag ===== */
.flag {
  width: 100%;
  aspect-ratio: 3 / 2;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  position: relative;
  background: #222;
}

.flag svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 18px 0;
}

.stat {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 10px 12px;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat .label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.stat .value {
  font-size: 14px;
  font-weight: 600;
  word-break: break-word;
}

/* ===== Boxes ===== */
.culture-box, .facts-box {
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent-2);
  padding: 12px 14px;
  border-radius: 10px;
  margin-top: 12px;
}

.culture-box h3, .facts-box h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--accent);
  font-weight: 700;
}

.culture-box p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.facts-box ul {
  margin: 0;
  padding-left: 18px;
  font-size: 13px;
  line-height: 1.7;
}

.facts-box li {
  margin-bottom: 4px;
}

/* ===== Placeholder ===== */
.placeholder {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 14px;
}

/* ===== Actions ===== */
.actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  display: flex;
  gap: 10px;
  justify-content: center;
  background: linear-gradient(to top, rgba(15, 23, 42, 0.95) 60%, rgba(15, 23, 42, 0));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 50;
}

.btn {
  flex: 1;
  max-width: 280px;
  padding: 14px 18px;
  border: none;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.2s ease;
  font-family: inherit;
  color: white;
  user-select: none;
  -webkit-user-select: none;
}

.btn.primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent-2) 100%);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.45);
}

.btn.secondary {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  flex: 0 0 auto;
  max-width: 140px;
}

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

.btn:disabled {
  opacity: 0.6;
  pointer-events: none;
}

.btn-icon {
  font-size: 18px;
}

.btn.hidden { display: none; }

/* ===== Footer ===== */
footer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  padding: 24px 12px 8px;
  opacity: 0.7;
}

/* ===== Mobile tweaks ===== */
@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .btn { font-size: 15px; padding: 12px 14px; }
}

@media (min-width: 600px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ===== Loading state ===== */
.loading {
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
