@import url("https://fonts.googleapis.com/css2?family=Figtree:wght@400;500;600;700&family=Syne:wght@600;700;800&display=swap");

:root {
  --bg0: #e4edf6;
  --bg1: #f8fbfd;
  --ink: #101820;
  --muted: #5a6b7c;
  --line: rgba(16, 24, 32, 0.1);
  --accent: #0a7a6f;
  --accent-bright: #14b8a6;
  --accent-deep: #055c54;
  --warm: #e15a3c;
  --warm-soft: #f4a28e;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --shadow: 0 20px 50px rgba(16, 24, 32, 0.09);
  --shadow-hover: 0 28px 64px rgba(16, 24, 32, 0.14);
  --radius: 20px;
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-body);
  background: var(--bg1);
  line-height: 1.55;
  overflow-x: hidden;
}

/* atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(42% 36% at 12% 8%, rgba(20, 184, 166, 0.28), transparent 60%),
    radial-gradient(38% 32% at 88% 4%, rgba(225, 90, 60, 0.16), transparent 55%),
    radial-gradient(50% 40% at 70% 78%, rgba(100, 150, 200, 0.18), transparent 60%),
    linear-gradient(165deg, var(--bg1), var(--bg0));
  animation: drift 22s var(--ease) infinite alternate;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 5rem;
}

/* topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  animation: rise 0.7s var(--ease-out) both;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: -0.03em;
  font-size: 1.05rem;
  padding-left: 0.25rem;
}

.brand-mark {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  box-shadow: 0 0 0 4px rgba(10, 122, 111, 0.14);
  animation: pulse-mark 2.8s var(--ease) infinite;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-link {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.88rem;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  transition: color 0.25s var(--ease), background 0.25s var(--ease);
}

button.nav-link.btn-link {
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.nav-link:hover {
  color: var(--ink);
  background: rgba(10, 122, 111, 0.08);
}

/* hero */
.hero {
  position: relative;
  display: grid;
  gap: 1.1rem;
  padding: 2rem 0 2.75rem;
  animation: rise 0.85s var(--ease-out) both;
}

.hero::before,
.hero::after {
  content: "";
  position: absolute;
  border-radius: 40% 60% 55% 45%;
  filter: blur(2px);
  pointer-events: none;
  z-index: -1;
}

.hero::before {
  width: min(280px, 42vw);
  height: min(280px, 42vw);
  right: -2%;
  top: -8%;
  background: linear-gradient(145deg, rgba(20, 184, 166, 0.22), rgba(20, 184, 166, 0.02));
  animation: float-a 9s var(--ease) infinite alternate;
}

.hero::after {
  width: min(180px, 30vw);
  height: min(180px, 30vw);
  left: 8%;
  bottom: -12%;
  background: linear-gradient(145deg, rgba(225, 90, 60, 0.16), transparent);
  animation: float-b 11s var(--ease) infinite alternate;
}

.hero-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-deep);
  animation: rise 0.8s 0.05s var(--ease-out) both;
}

.hero-kicker i {
  width: 1.5rem;
  height: 2px;
  background: var(--accent);
  border-radius: 2px;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.8rem, 8vw, 5rem);
  letter-spacing: -0.05em;
  line-height: 0.94;
  animation: rise 0.85s 0.08s var(--ease-out) both;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
  position: relative;
  display: inline-block;
}

.hero h1 em::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0.08em;
  height: 0.18em;
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.45), rgba(225, 90, 60, 0.25));
  border-radius: 999px;
  transform-origin: left;
  animation: underline 1s 0.45s var(--ease-out) both;
}

.hero p {
  margin: 0;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.08rem;
  animation: rise 0.85s 0.14s var(--ease-out) both;
}

.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;
}

.is-hidden {
  display: none !important;
}

.hub-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin: 0 0 1.25rem;
  padding: 0.65rem 0.75rem;
  position: sticky;
  top: 0.5rem;
  z-index: 25;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface-strong) 92%, transparent);
  background: rgba(248, 251, 252, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 28px rgba(16, 24, 32, 0.06);
  animation: rise 0.8s 0.16s var(--ease-out) both;
}

.hub-search {
  flex: 1 1 280px;
}

.hub-search input {
  width: 100%;
  padding: 0.75rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.hub-search input:focus {
  border-color: rgba(10, 122, 111, 0.45);
  box-shadow: 0 0 0 4px rgba(10, 122, 111, 0.12);
}

.hub-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.hub-filter {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.hub-filter.is-on,
.hub-filter:hover {
  color: var(--ink);
  border-color: rgba(10, 122, 111, 0.35);
  background: #fff;
}

.hub-filter.is-on {
  background: rgba(10, 122, 111, 0.12);
  color: var(--accent-deep);
}

.hub-sort select {
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.84rem;
  cursor: pointer;
}

.continue-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid rgba(10, 122, 111, 0.28);
  border-radius: var(--radius);
  background: linear-gradient(120deg, rgba(20, 184, 166, 0.14), rgba(255, 255, 255, 0.85));
  animation: rise 0.75s 0.12s var(--ease-out) both;
}

.continue-copy {
  font-weight: 600;
  color: var(--ink);
}

.continue-copy span {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.continue-banner .btn {
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
}

.daily-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin: 0 0 1.25rem;
  padding: 0.85rem 1.1rem;
  border: 1px dashed rgba(10, 122, 111, 0.35);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  animation: rise 0.75s 0.14s var(--ease-out) both;
}

.daily-copy {
  font-weight: 600;
  color: var(--ink);
}

.daily-copy span {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.9rem;
}

.daily-pick .btn {
  padding: 0.55rem 1rem;
  font-size: 0.88rem;
}

.back-top {
  position: fixed;
  right: 1.1rem;
  bottom: 1.1rem;
  z-index: 40;
  width: 2.6rem;
  height: 2.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(16, 24, 32, 0.12);
}

.back-top:hover {
  border-color: rgba(10, 122, 111, 0.45);
  color: #0a7a6f;
}

.mg-related {
  margin: 1.75rem 0 0.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

.mg-related h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--ink);
}

.hub-stats {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-strong);
  animation: rise 0.7s 0.1s var(--ease-out) both;
}

.hub-stats-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.08);
  overflow: hidden;
  margin-bottom: 0.45rem;
}

.hub-stats-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #0a7a6f, #1fb8a8);
  border-radius: inherit;
}

.hub-stats p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.hub-stats strong {
  color: var(--ink);
}

.hub-help-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-best {
  background: rgba(224, 177, 90, 0.22) !important;
  color: #8a5a12 !important;
}

.chip-new {
  background: rgba(11, 127, 116, 0.12) !important;
  color: #0b7f74 !important;
}

.chip-multi {
  background: rgba(59, 110, 180, 0.16) !important;
  color: #2a4f8a !important;
}

body.hub-compact .game-grid {
  gap: 0.65rem;
}

body.hub-compact .game-card {
  padding: 0.65rem;
}

body.hub-compact .game-card .preview {
  height: 72px;
}

body.hub-compact .game-card h2 {
  font-size: 1rem;
}

body.hub-compact .game-card p {
  display: none;
}

.save-dot {
  margin-left: 0.35rem;
  color: var(--accent);
  font-size: 0.65rem;
  vertical-align: middle;
}

.hub-empty {
  margin: 0 0 2rem;
  color: var(--muted);
  font-weight: 600;
}

.recent-strip {
  margin: 0 0 1.75rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(10px);
  animation: rise 0.8s 0.17s var(--ease-out) both;
}

.recent-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.recent-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.recent-clear {
  padding: 0.35rem 0.7rem !important;
  font-size: 0.78rem !important;
}

.recent-empty {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.recent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.recent-chip {
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.84rem;
  background: var(--chip-bg, rgba(10, 122, 111, 0.12));
  border: 1px solid rgba(16, 24, 32, 0.06);
  transition: transform 0.2s var(--ease);
}

.recent-chip:hover {
  transform: translateY(-2px);
}

.fav-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  z-index: 3;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: #c5cdd6;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(16, 24, 32, 0.08);
  transition: color 0.2s var(--ease), transform 0.2s var(--ease);
}

.fav-btn:hover {
  transform: scale(1.08);
}

.fav-btn.is-on {
  color: #e15a3c;
}

/* category nav */
.cat-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 2.25rem;
  animation: rise 0.8s 0.18s var(--ease-out) both;
}

.cat-nav a,
.cat-nav-btn {
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(10px);
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--muted);
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease),
    background 0.25s var(--ease);
}

.cat-nav a:hover,
.cat-nav-btn:hover {
  color: var(--ink);
  border-color: rgba(10, 122, 111, 0.35);
  background: #fff;
  transform: translateY(-2px);
}

.cat-nav-btn.is-on {
  color: var(--accent-deep);
  border-color: rgba(10, 122, 111, 0.4);
  background: rgba(10, 122, 111, 0.12);
}

.cat-nav-count {
  margin-left: 0.35rem;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--accent);
  opacity: 0.85;
}

/* categories + cards */
.cat-block {
  margin-bottom: 3rem;
}

.cat-head {
  margin-bottom: 1.15rem;
  display: grid;
  gap: 0.35rem;
}

.cat-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 3vw, 2rem);
  letter-spacing: -0.035em;
}

.cat-head p {
  margin: 0;
  color: var(--muted);
  max-width: 42rem;
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
}

.game-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 0.8rem;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  transition: transform 0.4s var(--ease-out), box-shadow 0.4s var(--ease-out), border-color 0.3s var(--ease);
  opacity: 0;
  transform: translateY(18px);
}

.game-card.is-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.55s var(--ease-out), transform 0.55s var(--ease-out), box-shadow 0.4s var(--ease-out),
    border-color 0.3s var(--ease);
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, 0.45) 48%, transparent 62%);
  transform: translateX(-120%);
  transition: transform 0.7s var(--ease-out);
  pointer-events: none;
  z-index: 2;
}

.game-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: rgba(10, 122, 111, 0.28);
}

.game-card:hover::before {
  transform: translateX(120%);
}

.game-card .preview {
  height: 124px;
  border-radius: 14px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.game-card .preview .thumb-svg,
.scores-thumb .thumb-svg {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card .preview::after {
  content: none;
}

.lang-select {
  display: inline-flex;
  align-items: center;
}

.lang-select select {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.15rem;
}

.howto-chip {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}

.howto-chip:hover {
  color: var(--accent-deep);
  border-color: rgba(10, 122, 111, 0.35);
}

.scores-panel {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.scores-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.scores-head h2 {
  margin: 0;
  font-size: 1.05rem;
}

.scores-actions {
  display: flex;
  gap: 0.4rem;
}

.scores-list {
  display: grid;
  gap: 0.55rem;
}

.scores-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 0.75rem;
  align-items: center;
  padding: 0.45rem;
  border-radius: 12px;
  border: 1px solid transparent;
  color: inherit;
  text-decoration: none;
}

.scores-row:hover {
  border-color: rgba(10, 122, 111, 0.25);
  background: rgba(10, 122, 111, 0.05);
}

.scores-thumb {
  width: 72px;
  height: 48px;
  border-radius: 10px;
  overflow: hidden;
}

.scores-meta {
  display: grid;
  gap: 0.15rem;
}

.scores-meta strong {
  font-size: 0.98rem;
}

.scores-meta em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 600;
}

.scores-empty {
  margin: 0;
  color: var(--muted);
}

.howto-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(16, 24, 32, 0.45);
}

.howto-modal.is-open {
  display: flex;
}

.howto-modal-card {
  width: min(520px, 100%);
  max-height: min(80vh, 640px);
  overflow: auto;
  background: #fff;
  border-radius: 18px;
  padding: 1.1rem 1.2rem 1.25rem;
  box-shadow: 0 24px 60px rgba(16, 24, 32, 0.28);
}

.howto-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.howto-modal-head h2 {
  margin: 0;
  font-size: 1.2rem;
}

.howto-modal-body p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  line-height: 1.55;
  white-space: pre-wrap;
}

.howto-modal-play {
  display: inline-flex;
  margin-top: 0.35rem;
}

.preview-orb {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  animation: orb 5s var(--ease) infinite alternate;
}

.preview-orb.a {
  width: 70px;
  height: 70px;
  left: 12%;
  top: 18%;
}

.preview-orb.b {
  width: 110px;
  height: 110px;
  right: -8%;
  bottom: -20%;
  animation-delay: -1.5s;
}

.preview-grid {
  position: absolute;
  inset: 18% 14%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  opacity: 0.55;
}

.preview-grid span {
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
  animation: tile-pop 2.4s var(--ease) infinite;
}

.preview-grid span:nth-child(2) { animation-delay: 0.15s; }
.preview-grid span:nth-child(3) { animation-delay: 0.3s; }
.preview-grid span:nth-child(5) { animation-delay: 0.2s; }
.preview-grid span:nth-child(8) { animation-delay: 0.4s; }

.game-card h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: -0.03em;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.93rem;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.26rem 0.58rem;
  border-radius: 999px;
  background: rgba(10, 122, 111, 0.1);
  color: var(--accent-deep);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.chip.cat-memory { background: rgba(100, 140, 200, 0.16); color: #335a8a; }
.chip.cat-puzzle { background: rgba(10, 122, 111, 0.12); color: var(--accent-deep); }
.chip.cat-arcade { background: rgba(225, 90, 60, 0.12); color: #a33a26; }
.chip.cat-reflex { background: rgba(224, 177, 90, 0.2); color: #8a5a12; }

.play {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.1rem;
  font-weight: 800;
  color: var(--accent-deep);
}

.play::after {
  content: "→";
  transition: transform 0.25s var(--ease);
}

.game-card:hover .play::after {
  transform: translateX(5px);
}

/* game pages */
.game-shell {
  width: min(780px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3.5rem;
  position: relative;
  z-index: 1;
}

.game-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1.35rem;
  animation: rise 0.55s var(--ease-out) both;
}

.game-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
  flex: 1 1 auto;
}

.game-nav-link {
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--muted);
}

.game-nav-link:hover {
  color: var(--ink);
  border-color: rgba(10, 122, 111, 0.35);
}

.game-nav-mute {
  padding: 0.4rem 0.75rem !important;
  font-size: 0.8rem !important;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: 700;
  color: var(--muted);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(10px);
  transition: color 0.2s var(--ease), transform 0.2s var(--ease), border-color 0.2s var(--ease);
}

.back:hover {
  color: var(--ink);
  border-color: rgba(10, 122, 111, 0.3);
  transform: translateX(-2px);
}

.game-title {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.5vw, 2.55rem);
  letter-spacing: -0.04em;
  animation: rise 0.6s 0.05s var(--ease-out) both;
}

.game-sub {
  margin: 0 0 1.2rem;
  color: var(--muted);
  animation: rise 0.6s 0.1s var(--ease-out) both;
}

.panel {
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 2px);
  background: var(--surface);
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  padding: 1.15rem;
  animation: rise 0.65s 0.14s var(--ease-out) both;
}

.panel:fullscreen,
#stage:fullscreen,
.game-shell:fullscreen {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  max-width: none;
  border-radius: 0;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: clamp(0.75rem, 3vh, 1.75rem);
  background: #0e161c;
  overflow: auto;
}

.panel:fullscreen .hud,
.game-shell:fullscreen .hud,
#stage:fullscreen .hud {
  width: min(100%, 52rem);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e8f0f4;
}

.panel:fullscreen #stage,
.panel:fullscreen canvas,
#stage:fullscreen canvas,
.game-shell:fullscreen #stage,
.game-shell:fullscreen canvas {
  max-width: min(100vw - 2rem, 96vh);
  max-height: 82vh;
  width: auto;
  height: auto;
}

.panel:fullscreen .hint,
.game-shell:fullscreen .hint {
  color: rgba(232, 240, 244, 0.72);
}

.panel:fullscreen .stat b,
.game-shell:fullscreen .stat b,
#stage:fullscreen .stat b {
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  color: #f0f8fc;
}

.panel:fullscreen .stat span,
.game-shell:fullscreen .stat span,
#stage:fullscreen .stat span {
  color: rgba(232, 240, 244, 0.72);
}

.panel:fullscreen .hud .btn.ghost,
.game-shell:fullscreen .hud .btn.ghost {
  color: #e8f0f4;
  border-color: rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.06);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(16, 24, 32, 0.06);
}

.stat {
  display: grid;
  gap: 0.08rem;
  min-width: 4rem;
}

.stat b {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--ink), var(--accent-deep));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 12px;
  padding: 0.7rem 1.05rem;
  background: var(--ink);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.btn:hover {
  transform: translateY(-2px);
  background: #0a1218;
  box-shadow: 0 10px 24px rgba(16, 24, 32, 0.18);
}

.btn:active {
  transform: translateY(0);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

.btn.ghost:hover {
  background: #fff;
  border-color: rgba(10, 122, 111, 0.3);
  box-shadow: none;
}

.btn.accent {
  background: linear-gradient(135deg, var(--accent), #0f9b8d);
}

.btn.accent:hover {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.hint {
  margin-top: 0.9rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.game-controls {
  margin-bottom: 1rem;
  animation: rise 0.6s 0.12s var(--ease-out) both;
}

.ctrl-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.ctrl-bar .btn {
  padding: 0.55rem 0.85rem;
  font-size: 0.88rem;
}

.ctrl-more {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 0.55rem;
  padding: 0.55rem 0.65rem;
  border: 1px dashed var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.45);
}

.ctrl-more.is-hidden {
  display: none;
}

.mg-toast {
  position: fixed;
  left: 50%;
  bottom: 1.4rem;
  z-index: 80;
  transform: translateX(-50%) translateY(120%);
  max-width: min(92vw, 28rem);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  background: rgba(16, 24, 32, 0.92);
  color: #f4f8fb;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: 0 16px 40px rgba(16, 24, 32, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.35s var(--ease-out), opacity 0.35s var(--ease-out);
}

.mg-toast.is-on {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.mg-pause {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  background: rgba(10, 18, 24, 0.52);
  backdrop-filter: blur(6px);
}

.mg-pause.is-hidden {
  display: none;
}

.mg-pause-card {
  width: min(90vw, 22rem);
  padding: 1.5rem 1.35rem;
  border-radius: 20px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  text-align: center;
  box-shadow: var(--shadow-hover);
  animation: panel-in 0.3s var(--ease-out);
}

.mg-pause-card h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

.mg-pause-card p {
  margin: 0 0 1rem;
  color: var(--muted);
}

.hub-help {
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-strong);
  animation: rise 0.6s var(--ease-out) both;
}

.hub-help h2 {
  margin: 0 0 0.55rem;
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.hub-help ul {
  margin: 0 0 0.85rem;
  padding-left: 1.15rem;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

.hub-help li {
  margin: 0.25rem 0;
}

.hub-help kbd {
  display: inline-block;
  min-width: 1.4rem;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 0.8rem;
  text-align: center;
}

.chip-plays {
  background: rgba(16, 24, 32, 0.06) !important;
  color: var(--muted) !important;
}

.game-nav-mute.is-fav {
  color: #e15a3c;
}

.settings-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-strong);
  padding: 1rem 1.05rem;
  margin-bottom: 0.4rem;
  animation: panel-in 0.35s var(--ease-out);
}

.settings-panel.is-hidden {
  display: none;
}

.settings-panel h3 {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.settings-fields {
  display: grid;
  gap: 0.75rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0 0.55rem;
}

.settings-actions [data-act="apply"].is-dirty {
  box-shadow: 0 0 0 3px rgba(10, 122, 111, 0.28);
}

.set-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 180px);
  gap: 0.65rem;
  align-items: center;
  font-weight: 600;
  font-size: 0.9rem;
}

.set-row.check {
  grid-template-columns: 1fr auto;
}

.set-row span b {
  font-family: var(--font-display);
  color: var(--accent-deep);
  margin-left: 0.25rem;
}

.set-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.set-row select,
.set-row input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: #fff;
}

.ctrl-msg {
  min-height: 1.2em;
  margin-top: 0.35rem;
}

.howto-panel p,
.howto-body p {
  margin: 0 0 0.65rem;
  color: var(--muted);
  line-height: 1.6;
  font-weight: 500;
}

.howto-body p:last-child {
  margin-bottom: 0;
}

.howto-keys {
  margin-top: 0.85rem;
}

.howto-keys h4 {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  font-family: var(--font-display);
}

.howto-key-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}

.howto-key-list li {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.howto-key-list kbd,
.keybind-btn {
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-size: 0.82rem;
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  min-width: 4.5rem;
  text-align: center;
}

.keybind-list {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.keybind-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.keybind-row.is-listening .keybind-btn {
  border-color: var(--accent);
  color: var(--accent-deep);
  box-shadow: 0 0 0 2px rgba(10, 122, 111, 0.15);
}

.keybind-actions {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

/* shared play surfaces */
#stage,
.panel #board,
.panel canvas,
#canvas,
canvas#c {
  border-radius: 16px;
}

.panel canvas,
#canvas,
canvas#c {
  display: block;
  margin-left: auto;
  margin-right: auto;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 16px 40px rgba(16, 24, 32, 0.18);
  transition: transform 0.35s var(--ease);
}

.panel:hover canvas,
.panel:hover #canvas,
.panel:hover canvas#c {
  transform: translateY(-1px);
}

#stage .cell,
#board .cell,
.board .card .face,
.hole,
.block,
.chip,
.item,
.pad[data-i],
.tile {
  transition: transform 0.18s var(--ease), filter 0.18s var(--ease), background 0.18s var(--ease);
}

#stage .cell:hover:not(:disabled),
#board .cell:hover:not(:disabled),
.item:hover,
.block:hover,
.tile:hover,
.hole:hover {
  transform: translateY(-1px) scale(1.02);
  filter: brightness(1.03);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-2%, 1.5%, 0) scale(1.04);
  }
}

@keyframes float-a {
  from {
    transform: translate(0, 0) rotate(0deg);
  }
  to {
    transform: translate(-12px, 18px) rotate(8deg);
  }
}

@keyframes float-b {
  from {
    transform: translate(0, 0) rotate(0deg);
  }
  to {
    transform: translate(14px, -10px) rotate(-6deg);
  }
}

@keyframes pulse-mark {
  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(10, 122, 111, 0.14);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(10, 122, 111, 0.08);
  }
}

@keyframes underline {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes orb {
  from {
    transform: translate(0, 0) scale(1);
  }
  to {
    transform: translate(10px, -8px) scale(1.08);
  }
}

@keyframes tile-pop {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.92);
  }
  50% {
    opacity: 0.8;
    transform: scale(1);
  }
}

@media (max-width: 560px) {
  .set-row {
    grid-template-columns: 1fr;
  }

  .topbar {
    border-radius: 18px;
  }
}

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

  .game-card {
    opacity: 1;
    transform: none;
  }
}
