:root {
  --bg: #f7fbff;
  --ink: #193149;
  --muted: #5c7285;
  --panel: #ffffff;
  --line: #d7e5ee;
  --sky: #89d7f3;
  --leaf: #66bd7a;
  --sun: #ffd35c;
  --berry: #e86288;
  --violet: #8b79e6;
  --shadow: 0 18px 48px rgba(39, 76, 111, 0.16);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at 12% 18%, rgba(137, 215, 243, 0.25), transparent 24rem),
    linear-gradient(140deg, #f8fcff 0%, #f1fbf5 48%, #fff8e6 100%);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px;
}

.brand,
.nav button,
.icon-button,
.primary-button,
.secondary-button,
.game-card,
.choice,
.segmented button {
  border: 0;
  cursor: pointer;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 12px;
  background: transparent;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 800;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #ffffff 0 16%, transparent 18%),
    conic-gradient(from 0deg, var(--sun), var(--berry), var(--violet), var(--sky), var(--leaf), var(--sun));
  box-shadow: 0 8px 22px rgba(232, 98, 136, 0.25);
}

.nav {
  display: flex;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 28px rgba(42, 75, 101, 0.09);
}

.nav button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 92px;
  min-height: 46px;
  padding: 8px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.nav button.active,
.nav button:focus-visible,
.brand:focus-visible,
.game-card:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.icon-button:focus-visible,
.choice:focus-visible,
.segmented button:focus-visible {
  outline: 4px solid rgba(255, 211, 92, 0.85);
  outline-offset: 2px;
}

.nav button.active {
  background: var(--ink);
  color: #fff;
}

.view {
  padding: 14px 8px 26px;
}

.screen-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 16px;
  margin: 12px 0 20px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 8px;
  font-size: clamp(2rem, 6vw, 4.4rem);
  line-height: 0.95;
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  line-height: 1;
}

h3 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.lead {
  max-width: 720px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  line-height: 1.4;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.game-card {
  min-height: 270px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.game-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 24px 58px rgba(39, 76, 111, 0.2);
}

.game-art {
  position: relative;
  height: 132px;
  margin: -2px -2px 16px;
  overflow: hidden;
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--sky), #e5f8ff);
}

.game-art::before,
.game-art::after {
  content: "";
  position: absolute;
  border-radius: 50%;
}

.art-firefly::before {
  width: 34px;
  height: 34px;
  left: 24%;
  top: 36%;
  background: #fffbd7;
  box-shadow: 0 0 30px 12px rgba(255, 251, 215, 0.9), 70px 24px 0 -8px #fff6b0;
}

.art-firefly::after {
  width: 130px;
  height: 70px;
  left: 36%;
  top: 38%;
  border: 6px dotted rgba(25, 49, 73, 0.28);
  background: transparent;
}

.art-star::before {
  width: 46px;
  height: 46px;
  left: 18%;
  top: 20%;
  background: var(--sun);
  clip-path: polygon(50% 0, 62% 34%, 98% 34%, 68% 55%, 80% 92%, 50% 70%, 20% 92%, 32% 55%, 2% 34%, 38% 34%);
  box-shadow: 110px 48px 0 -4px var(--berry), 190px 12px 0 -10px var(--violet);
}

.art-star::after {
  inset: 18px;
  border: 6px solid rgba(255, 255, 255, 0.55);
  background: transparent;
}

.art-sparkle::before {
  width: 36px;
  height: 36px;
  left: 52%;
  top: 44%;
  background: #ffffff;
  box-shadow: -96px -10px 0 -7px rgba(255, 255, 255, 0.45), 86px 26px 0 -12px rgba(255, 255, 255, 0.35);
}

.art-sparkle::after {
  inset: 24px;
  border: 2px dashed rgba(25, 49, 73, 0.2);
  background: rgba(255, 255, 255, 0.28);
}

.art-memory::before {
  width: 44px;
  height: 44px;
  left: 24%;
  top: 28%;
  background: var(--leaf);
  border-radius: 16px 16px 50% 50%;
  box-shadow: 70px 30px 0 #ffd35c, 140px -6px 0 #e86288;
}

.art-memory::after {
  width: 260px;
  height: 90px;
  left: 8%;
  top: 72%;
  background: rgba(102, 189, 122, 0.35);
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #edf7fb;
  color: #254b66;
  font-size: 0.85rem;
  font-weight: 800;
}

.panel {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 290px;
  gap: 14px;
  align-items: start;
}

.game-stage {
  position: relative;
  overflow: hidden;
  border: 2px solid #cce3ee;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

canvas {
  display: block;
  width: 100%;
  height: min(68vh, 620px);
  min-height: 440px;
  touch-action: none;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 22px;
  background: rgba(255, 255, 255, 0.74);
  text-align: center;
}

.stage-overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(480px, 100%);
  padding: 22px;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.hud {
  display: grid;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat {
  min-height: 86px;
  padding: 12px;
  border-radius: var(--radius);
  background: #eef8fb;
}

.stat strong {
  display: block;
  margin-top: 5px;
  font-size: 1.55rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.primary-button,
.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-weight: 900;
}

.primary-button {
  background: var(--ink);
  color: #ffffff;
}

.secondary-button {
  border: 2px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.icon-button {
  width: 54px;
  padding: 0;
  border: 2px solid var(--line);
  background: #ffffff;
  color: var(--ink);
}

.result-list,
.settings-list {
  display: grid;
  gap: 12px;
}

.result-row,
.setting-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.result-row small,
.setting-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eef7fb;
}

.segmented button {
  min-width: 80px;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
}

.segmented button.active {
  background: #ffffff;
  box-shadow: 0 5px 16px rgba(25, 49, 73, 0.12);
}

.empty-state {
  padding: 28px;
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.progress-track {
  overflow: hidden;
  height: 14px;
  border-radius: 999px;
  background: #dfeef5;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--leaf), var(--sun), var(--berry));
  transition: width 180ms ease;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .game-grid,
  .play-layout {
    grid-template-columns: 1fr 1fr;
  }

  .play-layout {
    align-items: stretch;
  }

  .game-stage {
    grid-column: 1 / -1;
  }

  canvas {
    height: 58vh;
  }
}

@media (max-width: 700px) {
  .shell {
    padding: 10px;
  }

  .topbar,
  .screen-head,
  .result-row,
  .setting-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
  }

  .nav {
    width: 100%;
    border-radius: var(--radius);
  }

  .nav button {
    flex: 1;
    min-width: 0;
    padding-inline: 6px;
  }

  .game-grid,
  .play-layout,
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .game-card {
    min-height: 245px;
  }

  canvas {
    min-height: 360px;
    height: 56vh;
  }

  .segmented {
    grid-auto-flow: row;
    border-radius: var(--radius);
  }

  .segmented button {
    border-radius: var(--radius);
  }
}
