/* ============================================================
   Mini Games Collection
   Visual language inspired by Apple HIG + Microsoft Fluent:
   neutral surfaces, one purposeful accent, hairline separators,
   system typography, restrained motion.
   ============================================================ */

:root {
  --r-control: 8px;
  --r-card: 14px;
  --r-pill: 980px;

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --dur: 0.18s;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text",
    "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Cascadia Mono", "Consolas",
    "Liberation Mono", Menlo, monospace;
}

/* ---------- Light (default) ---------- */
[data-theme="light"] {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #f0f0f2;
  --surface-hover: #f4f4f6;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8a8a8e;
  --separator: rgba(0, 0, 0, 0.09);
  --border: rgba(0, 0, 0, 0.11);
  --accent: #0071e3;
  --accent-hover: #0077ed;
  --accent-soft: rgba(0, 113, 227, 0.1);
  --on-accent: #ffffff;
  --good: #1a8f5a;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-2: 0 1px 1px rgba(0, 0, 0, 0.04), 0 10px 28px -12px rgba(0, 0, 0, 0.18);
  --console-bg: #1d1d1f;
  --console-text: #e8e8ed;
}

/* ---------- Dark ---------- */
[data-theme="dark"] {
  --bg: #161618;
  --surface: #1f1f22;
  --surface-2: #2a2a2e;
  --surface-hover: #2e2e33;
  --text: #f5f5f7;
  --text-2: rgba(235, 235, 245, 0.62);
  --text-3: rgba(235, 235, 245, 0.42);
  --separator: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.14);
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --accent-soft: rgba(10, 132, 255, 0.18);
  --on-accent: #ffffff;
  --good: #30d158;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2: 0 1px 1px rgba(0, 0, 0, 0.3), 0 14px 34px -14px rgba(0, 0, 0, 0.6);
  --console-bg: #101012;
  --console-text: #e4e4ea;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; }

.page { max-width: 1040px; margin: 0 auto; padding: 48px 24px 56px; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
  flex-wrap: wrap;
}

.eyebrow {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 6px;
}

.brand h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.022em;
  line-height: 1.05;
}

.sub {
  margin-top: 10px;
  max-width: 440px;
  color: var(--text-2);
  font-size: 15px;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.date-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  white-space: nowrap;
}
.date-pill svg { width: 16px; height: 16px; color: var(--text-3); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--r-control);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-hover); }
.icon-btn svg { width: 18px; height: 18px; }
[data-theme="light"] .i-moon { display: none; }
[data-theme="dark"]  .i-sun  { display: none; }

/* ============================================================
   Layout
   ============================================================ */
.layout {
  display: grid;
  grid-template-columns: 256px 1fr;
  gap: 24px;
  align-items: start;
}

/* ---------- Sidebar ---------- */
.sidebar { position: sticky; top: 24px; }

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 10px;
}
.sidebar-head h2 { font-size: 13px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.04em; }

.badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  background: var(--surface-2);
}

.game-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-2);
  margin-bottom: 14px;
}

.game-btn {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 11px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--dur) var(--ease);
}
.game-btn:hover { background: var(--surface-hover); }

.game-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  color: var(--text-2);
  background: var(--surface-2);
}
.game-icon svg { width: 16px; height: 16px; }

.game-meta { min-width: 0; }
.game-name {
  display: block;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.game-desc {
  display: block;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game-btn.active { background: var(--accent); }
.game-btn.active .game-name,
.game-btn.active .game-desc { color: var(--on-accent); }
.game-btn.active .game-desc { opacity: 0.78; }
.game-btn.active .game-icon {
  background: rgba(255, 255, 255, 0.22);
  color: var(--on-accent);
}

/* ---------- Buttons (shared) ---------- */
button { font-family: inherit; cursor: pointer; border: none; }

.text-btn {
  width: 100%;
  height: 36px;
  border-radius: var(--r-control);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--dur) var(--ease);
}
.text-btn:hover { background: var(--surface-hover); }
.text-btn.subtle {
  width: auto;
  padding: 0 14px;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-2);
}
.text-btn.subtle:hover { background: var(--surface-2); color: var(--text); }

/* ============================================================
   Console
   ============================================================ */
.console {
  display: flex;
  flex-direction: column;
  min-height: 520px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-2);
}

.console-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--separator);
}
.console-head h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  padding: 4px 11px 4px 9px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
}
.status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  transition: background var(--dur) var(--ease);
}
.status.is-live { color: var(--good); background: var(--accent-soft); }
.status.is-live .status-dot { background: var(--good); }

.output {
  flex: 1;
  background: var(--console-bg);
  border-radius: 10px;
  padding: 18px 20px;
  min-height: 280px;
  max-height: 46vh;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--console-text);
}
.output::-webkit-scrollbar { width: 10px; }
.output::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  border: 3px solid transparent;
  background-clip: padding-box;
}
.output p { margin-bottom: 7px; animation: lineIn 0.2s var(--ease) both; }
.output p:last-child { margin-bottom: 0; }
@keyframes lineIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Input ---------- */
.input-row { display: flex; gap: 10px; margin-top: 16px; }

.input-row input[type="text"] {
  flex: 1;
  height: 42px;
  padding: 0 14px;
  border-radius: var(--r-control);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.input-row input[type="text"]::placeholder { color: var(--text-3); }
.input-row input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

#submitBtn {
  height: 42px;
  padding: 0 22px;
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--dur) var(--ease);
}
#submitBtn:hover { background: var(--accent-hover); }
#submitBtn:active { transform: scale(0.985); }

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.hint { font-size: 12.5px; color: var(--text-3); }
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ============================================================
   Origin note
   ============================================================ */
.origin {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 28px;
  padding: 22px 24px;
  border-radius: var(--r-card);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 32%, transparent);
  box-shadow: var(--shadow-2);
}

.origin-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 12px;
  color: var(--on-accent);
  background: var(--accent);
  box-shadow: 0 6px 16px -6px var(--accent);
}
.origin-icon svg { width: 24px; height: 24px; }

.origin-text { flex: 1; min-width: 220px; }
.origin-chip {
  display: inline-block;
  margin-bottom: 7px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.origin-title { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.origin-sub { margin-top: 4px; font-size: 13.5px; color: var(--text-2); max-width: 560px; }

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 42px;
  padding: 0 20px;
  border-radius: var(--r-control);
  background: var(--accent);
  border: 1px solid transparent;
  color: var(--on-accent);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: 0 6px 16px -8px var(--accent);
  transition: background var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.download-btn:hover { background: var(--accent-hover); }
.download-btn:active { transform: scale(0.985); }
.download-btn svg { width: 16px; height: 16px; color: currentColor; }

/* ============================================================
   Accessibility
   ============================================================ */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 880px) {
  .page { padding: 32px 18px 40px; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .brand h1 { font-size: 32px; }
}
@media (max-width: 520px) {
  .topbar { align-items: flex-start; }
  .footer-row .hint { display: none; }
  .date-value { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .origin { flex-direction: column; align-items: flex-start; }
  .download-btn { width: 100%; justify-content: center; }
}

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