:root {
  color-scheme: light;
  --bg: #fcfaf2;
  --bg-accent: #f3eee0;
  --surface: #ffffff;
  --ink: #1f2533;
  --ink-muted: #596275;
  --border: #e4decb;
  --primary: #ff4f9a;
  --primary-edge: #c92c73;
  --secondary: #ffffff;
  --secondary-edge: #d8d0ba;
  --sun: #ffd23f;
  --sky: #8fdcff;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-card: 0 10px 28px rgba(31, 37, 51, 0.07), 0 2px 6px rgba(31, 37, 51, 0.04);
}

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

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100dvh;
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 12% 10%, rgba(255, 210, 63, 0.22), transparent 34%),
    radial-gradient(circle at 88% 14%, rgba(143, 220, 255, 0.28), transparent 36%);
  color: var(--ink);
  font-family: "Nunito", ui-rounded, system-ui, -apple-system, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-shell {
  max-width: 1040px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: clamp(20px, 4vw, 40px) clamp(18px, 4vw, 32px) 28px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand-mark {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  transition: transform 180ms ease;
}

.brand:hover .brand-mark {
  transform: rotate(-4deg) scale(1.04);
}

.site-header h1 {
  margin: 0;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.75rem, 3.6vw, 2.5rem);
  line-height: 1.08;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--ink-muted);
  font-size: 0.98rem;
  font-weight: 700;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1;
  text-decoration: none;
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 12px 22px;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
  user-select: none;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  border-bottom: 5px solid var(--primary-edge);
}

.btn-primary:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(3px);
  border-bottom-width: 2px;
}

.btn-secondary {
  background: var(--secondary);
  color: var(--ink);
  border: 2px solid var(--secondary-edge);
  border-bottom-width: 4px;
}

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

.btn-secondary:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

.shelf-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.search-wrap input {
  width: min(320px, 100%);
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 999px;
  outline: none;
  transition: border-color 140ms ease;
}

.search-wrap input:focus {
  border-color: var(--ink);
}

.game-count {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--ink-muted);
}

main {
  flex: 1;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr));
  gap: 22px;
}

.game-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 32px rgba(31, 37, 51, 0.1), 0 4px 10px rgba(31, 37, 51, 0.05);
}

.card-top {
  display: flex;
  align-items: center;
  gap: 16px;
}

.game-icon {
  width: 78px;
  height: 78px;
  border-radius: 20px;
  object-fit: cover;
  flex-shrink: 0;
  border: 2px solid rgba(31, 37, 51, 0.08);
  background: var(--bg-accent);
}

.card-heading {
  min-width: 0;
}

.game-title {
  margin: 0;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.45rem;
  line-height: 1.12;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-accent);
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 800;
}

.game-desc {
  margin: 0;
  color: var(--ink-muted);
  font-size: 0.97rem;
  font-weight: 600;
  flex: 1;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
}

.card-actions .btn-primary {
  flex: 1;
  padding: 13px 20px;
  font-size: 1.15rem;
}

.empty-state {
  text-align: center;
  color: var(--ink-muted);
  font-weight: 700;
  padding: 40px 16px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
}

.site-footer {
  padding-top: 12px;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.site-footer p {
  margin: 0;
}

.install-dialog {
  width: min(560px, calc(100vw - 28px));
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(31, 37, 51, 0.22);
}

.install-dialog::backdrop {
  background: rgba(31, 37, 51, 0.45);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-head h2 {
  margin: 0;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
}

.icon-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 2px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.dialog-intro {
  margin: 10px 0 16px;
  color: var(--ink-muted);
  font-weight: 600;
}

.guide-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.guide-box {
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}

.guide-box h3 {
  margin: 0 0 8px;
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
}

.guide-box ol {
  margin: 0;
  padding-left: 18px;
  font-size: 0.92rem;
  color: var(--ink-muted);
  font-weight: 600;
}

.guide-box li + li {
  margin-top: 6px;
}

.dialog-foot {
  margin-top: 18px;
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 600px) {
  .site-header {
    align-items: flex-start;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions .btn {
    width: 100%;
  }
}
