/* ============================================================
   MEIWORD GAMES HUB — index of all Meiword games
   Cream + indigo identity, mobile-first, tactile cards.
   ============================================================ */

:root {
  --ink: #1e1b4b;
  --indigo: #6366f1;
  --indigo-dark: #4338ca;
  --indigo-soft: #eef2ff;
  --gold: #f59e0b;
  --gold-soft: #fef3c7;
  --mint: #10b981;
  --mint-soft: #d1fae5;
  --rose: #f43f5e;
  --bg: #fdfbf7;
  --card: #ffffff;
  --muted: #6b7280;
  --line: #e9e7f5;
  --nav-height: 60px;
}

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

html, body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  background-image: radial-gradient(#e7e4f7 1.1px, transparent 1.1px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 { font-family: 'Bricolage Grotesque', 'Inter', sans-serif; }

a { color: inherit; }

/* ---------- top nav ---------- */
.games-top-nav {
  position: sticky; top: 0; z-index: 40;
  height: var(--nav-height);
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 0 16px;
  background: rgba(253, 251, 247, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.12rem; flex-shrink: 0; }
.brand-badge { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-badge svg { width: 33px; height: 33px; display: block; }
.nav-links { display: flex; align-items: center; gap: 10px; min-width: 0; }
.nav-link { font-size: 0.88rem; font-weight: 600; color: var(--indigo-dark); text-decoration: none; white-space: nowrap; }
.nav-link:hover { text-decoration: underline; }
.nav-link-portal {
  padding: 6px 13px;
  border-radius: 999px;
  background: var(--indigo-soft);
  color: var(--indigo-dark);
  font-size: 0.82rem;
  font-weight: 700;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.nav-link-portal:hover {
  background: var(--indigo);
  color: #fff;
  text-decoration: none;
}

/* ---------- player profile pill ---------- */
.player-pill {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 4px 10px 4px 4px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  max-width: 100%;
  cursor: pointer;
  font-family: 'Inter', system-ui, sans-serif;
  transition: all 0.15s ease;
}
.player-pill:hover {
  border-color: var(--indigo);
  background: #fafbff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, 0.12);
}
.player-avatar {
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  color: #fff;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.74rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.player-pill.is-guest .player-avatar {
  background: var(--indigo-soft);
  color: var(--indigo-dark);
}
.player-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.player-edit-icon {
  width: 12px;
  height: 12px;
  stroke: var(--muted);
  flex: none;
}
.player-pill:hover .player-edit-icon {
  stroke: var(--indigo-dark);
}

/* ---------- mobile header menu ---------- */
.games-menu-btn {
  display: none;
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.games-menu-btn svg { width: 18px; height: 18px; }
.games-menu-btn:hover,
.games-menu-btn[aria-expanded="true"] {
  border-color: var(--indigo);
  background: var(--indigo-soft);
  color: var(--indigo-dark);
}

.games-mobile-menu {
  position: absolute;
  top: calc(var(--nav-height) + 6px);
  right: 12px;
  left: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 8px;
  box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 45;
}
.games-mobile-menu[hidden] { display: none !important; }
.games-mobile-menu a {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 11px;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
  transition: background 0.12s ease;
}
.games-mobile-menu a:hover,
.games-mobile-menu a:active {
  background: var(--indigo-soft);
  color: var(--indigo-dark);
}

@media (max-width: 640px) {
  .games-top-nav { padding: 0 12px; }
  .brand { font-size: 1.02rem; gap: 7px; }
  .brand-badge svg { width: 29px; height: 29px; }
  .nav-links { gap: 8px; }
  .nav-link-materi,
  .nav-link-portal { display: none; }
  .games-menu-btn { display: inline-flex; }
  .player-name { max-width: 110px; }
}
@media (max-width: 380px) {
  .player-pill { padding: 3px 8px 3px 3px; gap: 6px; }
  .player-name { max-width: 82px; font-size: 0.78rem; }
}

/* ---------- player modal ---------- */
.player-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: modalFadeIn 0.15s ease;
}
.player-modal-backdrop[hidden] {
  display: none !important;
}
@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.player-modal-card {
  background: #fff;
  border-radius: 20px;
  border: 1px solid var(--line);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.18);
  width: 100%;
  max-width: 420px;
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.player-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.player-modal-head h3 {
  font-size: 1.18rem;
  font-weight: 800;
  color: var(--ink);
}
.player-modal-close {
  appearance: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-modal-close svg { width: 18px; height: 18px; }
.player-modal-close:hover {
  background: var(--indigo-soft);
  color: var(--indigo-dark);
}
.player-modal-desc {
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}
.player-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 4px;
}
.player-form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
}
.player-form-input {
  appearance: none;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.player-form-input:focus {
  outline: none;
  border-color: var(--indigo);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.player-form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}
.btn-secondary {
  background: #f1f5f9;
  color: #334155;
  padding: 10px 16px;
  font-size: 0.88rem;
}
.btn-secondary:hover {
  background: #e2e8f0;
}
.player-form-actions .btn-primary {
  padding: 10px 18px;
  font-size: 0.88rem;
}

/* ---------- layout ---------- */
.wrap { max-width: 940px; margin: 0 auto; padding: 30px 16px 50px; position: relative; z-index: 1; }

/* ---------- hero ---------- */
.hero-logo { width: 84px; height: 84px; display: block; margin-bottom: 14px; }
.kicker {
  display: inline-block; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em;
  color: var(--indigo-dark); background: var(--indigo-soft);
  padding: 5px 11px; border-radius: 999px; margin-bottom: 12px;
}
.hero h1 { font-size: clamp(2.1rem, 7vw, 3rem); font-weight: 800; line-height: 1.05; }
.hero h1 .hl { color: var(--indigo); }
.hero p { margin-top: 10px; color: var(--muted); font-size: 1rem; line-height: 1.55; max-width: 52ch; }

/* ---------- spotlight ---------- */
.game-spotlight {
  margin-top: 24px;
  background: linear-gradient(135deg, #ffffff 0%, #f6f5fe 100%);
  border: 1.5px solid rgba(99, 102, 241, 0.2);
  border-radius: 20px;
  padding: 18px 20px;
  box-shadow: 0 10px 26px rgba(99, 102, 241, 0.08);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
@media (min-width: 680px) {
  .game-spotlight {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
  }
}
.spotlight-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.spotlight-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #b45309;
  background: var(--gold-soft);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 4px 10px;
  border-radius: 999px;
  width: fit-content;
}
.spotlight-badge svg { width: 14px; height: 14px; flex: none; stroke: #b45309; fill: none; }
.spotlight-title {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--ink);
}
.spotlight-desc {
  font-size: 0.92rem;
  color: var(--muted);
  line-height: 1.45;
  max-width: 50ch;
}
.spotlight-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
}
.btn-spotlight {
  flex-shrink: 0;
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  color: #fff;
  box-shadow: 0 8px 18px rgba(67, 56, 202, 0.28);
  white-space: nowrap;
}
.btn-spotlight:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(67, 56, 202, 0.36);
}

/* ---------- toolbar & filters ---------- */
.game-toolbar {
  margin-top: 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.game-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.game-filters::-webkit-scrollbar { display: none; }
.filter-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.filter-btn:hover {
  border-color: var(--indigo);
  color: var(--indigo-dark);
  background: #fafbff;
}
.filter-btn.active {
  background: var(--indigo-dark);
  color: #fff;
  border-color: var(--indigo-dark);
  box-shadow: 0 4px 12px rgba(67, 56, 202, 0.2);
}
.filter-count {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
}
.filter-btn.active .filter-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}
.filter-status-text {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- game cards ---------- */
.game-grid { display: grid; gap: 16px; margin-top: 18px; }
@media (min-width: 880px) { .game-grid { grid-template-columns: 1fr 1fr; } }

.game-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
  box-shadow: 0 10px 26px rgba(30, 27, 75, 0.06);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  animation: cardFadeIn 0.25s ease;
}
.game-card:hover { transform: translateY(-3px); box-shadow: 0 16px 32px rgba(30, 27, 75, 0.1); }
.game-card.is-hidden { display: none !important; }

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

.game-empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 20px;
  color: var(--muted);
}

.game-visual {
  background: var(--indigo-soft); border-radius: 16px; min-height: 118px;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}

/* Spell: letter tiles */
.tiles { display: inline-flex; gap: 7px; }
.tile {
  width: 46px; height: 52px; border-radius: 10px;
  background: linear-gradient(160deg, var(--indigo), var(--indigo-dark));
  color: #fff; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.45rem;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 5px 0 #312e81;
}
.tile:nth-child(1) { transform: rotate(-5deg); }
.tile:nth-child(3) { transform: rotate(5deg); }

/* Sprint: bolt badge */
.bolt-badge {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--gold-soft);
  display: inline-flex; align-items: center; justify-content: center;
}
.bolt-badge svg { width: 42px; height: 42px; }

/* Builder: word tiles */
.tiles-visual { display: inline-flex; gap: 7px; align-items: center; }
.tiles-visual i {
  font-style: normal; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.06rem;
  background: #fff; color: var(--ink); border: 2px solid var(--line); border-bottom-width: 4px;
  border-radius: 11px; padding: 9px 13px;
}
.tiles-visual i.on { background: linear-gradient(135deg, var(--indigo), var(--indigo-dark)); color: #fff; border-color: var(--indigo-dark); }

/* Roleplay: overlapping chat bubbles */
.chat-visual { width: 96px; height: 96px; }

/* Echo: speaker badge */
.echo-badge {
  width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, #14b8a6, #0f766e);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(13, 148, 136, .28);
}
.echo-badge svg { width: 44px; height: 44px; }

/* Right or Wrong: split check/cross badge */
.rw-badge {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--indigo);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(30, 27, 75, .28);
}
.rw-badge svg { width: 48px; height: 48px; }

/* Tense Tap: clock/tap badge */
.tt-badge {
  width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(79, 70, 229, .28);
}
.tt-badge svg { width: 44px; height: 44px; stroke: #fff; fill: none; }

/* Cari Kata: magnifier badge */
.find-badge {
  width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 20px rgba(217, 119, 6, .28);
}
.find-badge svg { width: 42px; height: 42px; }

/* Match: mini pair of cards */
.mini-cards { display: inline-flex; gap: 9px; }
.mini-card {
  width: 62px; height: 76px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 2px solid var(--line); background: #fff;
  box-shadow: 0 6px 14px rgba(30, 27, 75, 0.08);
}
.mini-word { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.15rem; color: var(--indigo-dark); transform: rotate(-4deg); }
.mini-emoji { font-size: 2rem; transform: rotate(4deg); }

.game-card h2 { font-size: 1.32rem; font-weight: 800; }
.game-card p { color: var(--muted); font-size: 0.94rem; line-height: 1.55; flex: 1; }

.game-meta { display: flex; flex-wrap: wrap; gap: 7px; }
.meta-chip {
  font-size: 0.74rem; font-weight: 700; color: var(--indigo-dark);
  background: var(--indigo-soft); padding: 4px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px;
}
.meta-chip svg { width: 12px; height: 12px; flex: none; stroke: currentColor; fill: none; }
.meta-skill { color: #4338ca; background: #e0e7ff; }
.meta-free { color: #047857; background: var(--mint-soft); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: 'Inter', sans-serif; font-size: 0.96rem; font-weight: 700;
  padding: 13px 18px; border-radius: 14px; border: none; cursor: pointer;
  text-decoration: none; transition: transform 0.1s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn svg { width: 17px; height: 17px; flex: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--indigo), var(--indigo-dark));
  color: #fff; box-shadow: 0 8px 18px rgba(67, 56, 202, 0.28);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(67, 56, 202, 0.34); }
.btn-primary:active { transform: translateY(1px); }

/* ---------- note & footer ---------- */
.note-strip {
  margin-top: 22px; display: flex; gap: 9px; align-items: flex-start;
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  padding: 12px 14px; font-size: 0.86rem; line-height: 1.5; color: var(--muted);
}
.note-strip svg { width: 17px; height: 17px; flex: none; margin-top: 1px; color: var(--rose); }

.games-footer {
  border-top: 1px solid var(--line); padding: 22px 16px 30px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 0.85rem; color: var(--muted); text-align: center;
}
.games-footer a { color: var(--indigo-dark); font-weight: 600; text-decoration: none; }
.games-footer a:hover { text-decoration: underline; }

/* ---------- emoji ---------- */
.games-emoji { font-family: 'Noto Color Emoji', sans-serif; }
html.apple-emoji .games-emoji { font-family: 'Apple Color Emoji', sans-serif; }
