/* ═══════════════════════════════════════════════════════════════
   Kana Games Arcade — neo-Tokyo study arena
   ═══════════════════════════════════════════════════════════════ */

#tab-games {
  position: relative;
}

.kana-game-card,
.kg-bingo-cell,
.kg-scavenge-card,
.kg-memory-card {
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
}

.kana-game-card {
  width: 100%;
}

.kg-arena {
  position: relative;
  padding: 8px 0 40px;
}

.kg-arena::before {
  content: '';
  position: absolute;
  inset: -20px -12px 0;
  border-radius: 28px;
  background:
    radial-gradient(ellipse 70% 50% at 15% 0%, rgba(255, 101, 132, 0.12), transparent 55%),
    radial-gradient(ellipse 55% 45% at 90% 20%, rgba(0, 245, 212, 0.08), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(168, 85, 247, 0.06), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

.kg-arena > * { position: relative; z-index: 1; }

.kg-3d-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px 20px;
  align-items: center;
  padding: 20px 24px;
  margin-bottom: 28px;
  border-radius: 20px;
  text-decoration: none;
  background:
    radial-gradient(ellipse 70% 80% at 0% 50%, rgba(168, 85, 247, 0.2), transparent 55%),
    radial-gradient(ellipse 50% 60% at 100% 50%, rgba(0, 245, 212, 0.12), transparent 50%),
    rgba(12, 14, 32, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s, border-color 0.3s, box-shadow 0.3s;
}

.kg-3d-banner:hover {
  transform: translateY(-4px);
  border-color: rgba(0, 245, 212, 0.45);
  box-shadow: 0 28px 60px rgba(168, 85, 247, 0.2);
}

.kg-3d-badge {
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #a855f7;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.35);
  border-radius: 6px;
  padding: 4px 10px;
  grid-row: span 2;
}

.kg-3d-title {
  font-family: 'Noto Sans JP', 'Space Grotesk', sans-serif;
  font-size: 1.25rem;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
}

.kg-3d-desc {
  grid-column: 2;
  font-size: 0.8rem;
  color: #888;
  line-height: 1.5;
}

.kg-3d-cta {
  grid-row: span 2;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--mint, #00f5d4);
  white-space: nowrap;
}

@media (max-width: 600px) {
  .kg-3d-banner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .kg-3d-badge, .kg-3d-cta { grid-row: auto; }
  .kg-3d-desc { grid-column: 1; }
}

/* ── Lobby header ───────────────────────────────────────────── */
.kg-lobby-head {
  text-align: center;
  margin-bottom: 28px;
}

.kg-lobby-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sakura, #ff6584);
  margin-bottom: 10px;
}

.kg-lobby-eyebrow::before,
.kg-lobby-eyebrow::after {
  content: '';
  width: 24px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--sakura, #ff6584));
}
.kg-lobby-eyebrow::after {
  background: linear-gradient(90deg, var(--sakura, #ff6584), transparent);
}

.kg-lobby-title {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.03em;
  margin: 0 0 10px;
  background: linear-gradient(135deg, #fff 30%, var(--sakura, #ff6584) 70%, var(--mint, #00f5d4));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kg-lobby-sub {
  font-size: 0.88rem;
  color: #888;
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── Character set picker ───────────────────────────────────── */
.kg-set-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-bottom: 28px;
  padding: 10px 14px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  width: fit-content;
  margin-left: auto;
  margin-right: auto;
}

.kg-set-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #666;
  margin-right: 4px;
}

.kg-set-opt {
  position: relative;
  cursor: pointer;
}

.kg-set-opt input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.kg-set-pill {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #aaa;
  border: 1px solid transparent;
  transition: all 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.kg-set-opt input:checked + .kg-set-pill {
  color: #fff;
  background: linear-gradient(135deg, rgba(230, 57, 70, 0.25), rgba(255, 101, 132, 0.15));
  border-color: rgba(230, 57, 70, 0.45);
  box-shadow: 0 0 20px rgba(230, 57, 70, 0.2);
}

.kg-set-opt:hover .kg-set-pill {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.12);
}

/* ── Game picker cards ──────────────────────────────────────── */
.kana-games-hub {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 32px;
}

.kana-game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 22px 20px 18px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  text-align: left;
  overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.34, 1.4, 0.64, 1),
              border-color 0.3s,
              box-shadow 0.35s;
}

.kana-game-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--kg-accent, #e63946) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.35s;
  pointer-events: none;
}

.kana-game-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(from 0deg, transparent, var(--kg-accent, #e63946), transparent 30%);
  opacity: 0;
  animation: kgSpinGlow 4s linear infinite;
  pointer-events: none;
}

.kana-game-card:hover {
  transform: translateY(-8px) scale(1.02);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5), 0 0 40px color-mix(in srgb, var(--kg-accent, #e63946) 25%, transparent);
}

.kana-game-card:hover::before { opacity: 0.12; }
.kana-game-card.active {
  border-color: var(--kg-accent, var(--red, #e63946));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--kg-accent, #e63946) 40%, transparent),
              0 20px 50px rgba(0, 0, 0, 0.45);
}
.kana-game-card.active::before { opacity: 0.18; }
.kana-game-card.active::after { opacity: 0.06; }

.kana-game-card[data-game="bingo"]    { --kg-accent: #ff6584; }
.kana-game-card[data-game="speed"]    { --kg-accent: #fbbf24; }
.kana-game-card[data-game="scavenge"] { --kg-accent: #38bdf8; }
.kana-game-card[data-game="board"]    { --kg-accent: #a855f7; }
.kana-game-card[data-game="memory"]   { --kg-accent: #00f5d4; }

@keyframes kgSpinGlow {
  to { transform: rotate(360deg); }
}

.kg-pick-badge {
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--kg-accent, #e63946);
  background: color-mix(in srgb, var(--kg-accent, #e63946) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--kg-accent, #e63946) 30%, transparent);
  border-radius: 6px;
  padding: 3px 8px;
  margin-bottom: 12px;
}

.kana-game-icon {
  font-size: 2.4rem;
  margin-bottom: 10px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4));
  transition: transform 0.35s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.kana-game-card:hover .kana-game-icon {
  transform: scale(1.15) rotate(-6deg);
}

.kana-game-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.kana-game-desc {
  font-size: 0.74rem;
  color: #777;
  line-height: 1.55;
  flex: 1;
  margin-bottom: 12px;
}

.kg-pick-xp {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--mint, #00f5d4);
  letter-spacing: 0.04em;
}

/* ── Game panels ──────────────────────────────────────────────── */
.kana-game-panel {
  display: none;
  position: relative;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 255, 255, 0.04), transparent 60%),
    rgba(12, 14, 28, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 0;
  overflow: hidden;
  backdrop-filter: blur(16px);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.45);
}

.kana-game-panel.active {
  display: block;
  animation: kgPanelIn 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.kana-game-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 101, 132, 0.35), rgba(0, 245, 212, 0.2), rgba(168, 85, 247, 0.25));
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

@keyframes kgPanelIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

.kg-panel-inner { padding: 24px 26px 28px; }

/* ── HUD toolbar ──────────────────────────────────────────────── */
.kg-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.kg-toolbar-left {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.kg-hud-group {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.kg-score {
  font-size: 0.82rem;
  font-weight: 700;
  color: #888;
  padding: 6px 14px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.kg-score strong {
  color: var(--mint, #00f5d4);
  font-size: 1rem;
}

.kg-combo {
  display: none;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 100px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(230, 57, 70, 0.15));
  border: 1px solid rgba(251, 191, 36, 0.4);
  font-size: 0.78rem;
  font-weight: 800;
  color: #fbbf24;
  animation: kgComboPop 0.35s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.kg-combo.visible { display: inline-flex; }

.kg-combo-fire { font-size: 1rem; }

@keyframes kgComboPop {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.kg-timer-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.kg-timer-ring {
  width: 48px;
  height: 48px;
  transform: rotate(-90deg);
}

.kg-timer-ring-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 4;
}

.kg-timer-ring-fill {
  fill: none;
  stroke: #fbbf24;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear, stroke 0.3s;
}

.kg-timer-ring-fill.urgent {
  stroke: var(--red, #e63946);
  filter: drop-shadow(0 0 6px rgba(230, 57, 70, 0.6));
}

.kg-timer {
  font-family: 'Space Grotesk', monospace;
  font-size: 1.5rem;
  font-weight: 900;
  color: #fbbf24;
  min-width: 3ch;
  transition: color 0.3s;
}

.kg-timer.urgent {
  color: var(--red, #e63946);
  animation: kgTimerPulse 0.8s ease-in-out infinite;
}

@keyframes kgTimerPulse {
  50% { transform: scale(1.08); }
}

.kg-toolbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ── Progress bar ─────────────────────────────────────────────── */
.kg-progress {
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
  margin: 0 22px;
}

.kg-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--red, #e63946), var(--sakura, #ff6584), var(--mint, #00f5d4));
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.34, 1.2, 0.64, 1);
  box-shadow: 0 0 12px rgba(0, 245, 212, 0.4);
}

/* ── Callout (bingo caller) ───────────────────────────────────── */
.kg-callout {
  text-align: center;
  padding: 28px 24px;
  margin: 20px 22px;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(230, 57, 70, 0.15), transparent 70%),
    rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(230, 57, 70, 0.25);
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

.kg-callout.pulse {
  animation: kgCallPulse 0.6s ease;
}

@keyframes kgCallPulse {
  0%   { box-shadow: 0 0 0 0 rgba(230, 57, 70, 0.5); }
  70%  { box-shadow: 0 0 0 16px rgba(230, 57, 70, 0); }
  100% { box-shadow: none; }
}

.kg-callout-label {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #666;
  margin-bottom: 8px;
}

.kg-callout-sound {
  font-size: clamp(2rem, 6vw, 2.8rem);
  font-weight: 900;
  color: #fff;
  letter-spacing: 0.04em;
  text-shadow: 0 0 30px rgba(230, 57, 70, 0.4);
}

.kg-callout-hint {
  font-size: 0.82rem;
  color: #888;
  margin-top: 10px;
  min-height: 1.2em;
}

.kg-replay-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: #ccc;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.kg-replay-btn:hover {
  background: rgba(230, 57, 70, 0.2);
  border-color: var(--red, #e63946);
  color: #fff;
  transform: scale(1.1);
}

/* ── Bingo grid ───────────────────────────────────────────────── */
.kg-bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  max-width: 440px;
  margin: 0 auto 24px;
  padding: 0 22px;
}

.kg-bingo-cell {
  aspect-ratio: 1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.1);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: clamp(1.3rem, 4.5vw, 1.75rem);
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.34, 1.5, 0.64, 1),
              background 0.25s,
              border-color 0.25s,
              box-shadow 0.25s;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.kg-bingo-cell::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 50%, rgba(0, 245, 212, 0.35), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.kg-bingo-cell:hover:not(.marked) {
  transform: scale(1.06);
  border-color: rgba(255, 101, 132, 0.5);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kg-bingo-cell.marked {
  background: rgba(0, 245, 212, 0.15);
  border-color: var(--mint, #00f5d4);
  color: var(--mint, #00f5d4);
  box-shadow: 0 0 20px rgba(0, 245, 212, 0.25);
  animation: kgMarkPop 0.4s cubic-bezier(0.34, 1.5, 0.64, 1);
}

.kg-bingo-cell.marked::after { opacity: 1; }

.kg-bingo-cell.mark-pop {
  animation: kgMarkPop 0.45s cubic-bezier(0.34, 1.6, 0.64, 1);
}

@keyframes kgMarkPop {
  0%   { transform: scale(0.85); }
  50%  { transform: scale(1.12); }
  100% { transform: scale(1); }
}

.kg-bingo-cell.wrong-flash {
  animation: kgShake 0.4s;
  border-color: var(--red, #e63946) !important;
  background: rgba(230, 57, 70, 0.15) !important;
}

@keyframes kgShake {
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ── Speed match ──────────────────────────────────────────────── */
.kg-match-arena {
  position: relative;
  max-width: 700px;
  margin: 20px auto;
  padding: 0 22px;
}

.kg-match-board {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: start;
}

.kg-match-vs {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 48px;
  font-size: 1.4rem;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.15);
  text-shadow: 0 0 20px rgba(251, 191, 36, 0.3);
}

.kg-match-col-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #555;
  margin-bottom: 12px;
  text-align: center;
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
}

.kg-match-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.kg-match-item {
  padding: 16px 14px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  cursor: pointer;
  text-align: center;
  font-weight: 800;
  transition: all 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1.4rem;
  position: relative;
}

.kg-match-item.romaji {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  color: #bbb;
  letter-spacing: 0.02em;
}

.kg-match-item:hover:not(.matched) {
  transform: translateX(4px);
  border-color: rgba(255, 101, 132, 0.35);
  background: rgba(255, 101, 132, 0.06);
}

.kg-match-col:last-child .kg-match-item:hover:not(.matched) {
  transform: translateX(-4px);
}

.kg-match-item.selected {
  border-color: var(--red, #e63946);
  background: rgba(230, 57, 70, 0.15);
  box-shadow: 0 0 24px rgba(230, 57, 70, 0.25);
  transform: scale(1.04);
}

.kg-match-item.matched {
  opacity: 0.3;
  pointer-events: none;
  border-color: var(--mint, #00f5d4);
  transform: scale(0.95);
}

.kg-match-item.match-pop {
  animation: kgMatchPop 0.5s cubic-bezier(0.34, 1.5, 0.64, 1);
}

@keyframes kgMatchPop {
  0%   { transform: scale(1); box-shadow: 0 0 0 0 rgba(0, 245, 212, 0.6); }
  50%  { transform: scale(1.08); box-shadow: 0 0 30px 8px rgba(0, 245, 212, 0.4); }
  100% { transform: scale(0.95); }
}

.kg-match-item.wrong-flash {
  animation: kgShake 0.4s;
  border-color: var(--red, #e63946) !important;
}

.kg-match-item.hint-flash {
  animation: kgHintGlow 1.1s ease-in-out;
  border-color: #fbbf24 !important;
}

@keyframes kgHintGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
  50%      { box-shadow: 0 0 20px 6px rgba(251, 191, 36, 0.7); }
}

/* ── Scavenger hunt ───────────────────────────────────────────── */
.kg-scavenge-prompt-row {
  position: relative;
}

.kg-scavenge-prompt {
  text-align: center;
  color: #bbb;
  font-size: 0.92rem;
  font-weight: 600;
  margin: 16px 22px 20px;
  min-height: 1.4em;
}

.kg-scavenge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
  max-width: 580px;
  margin: 0 auto 24px;
  padding: 0 22px;
}

.kg-scavenge-card {
  aspect-ratio: 1;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.08), rgba(12, 14, 28, 0.9));
  border: 2px dashed rgba(56, 189, 248, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 2.2rem;
  font-weight: 900;
  color: #fff;
  transition: all 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
  position: relative;
  overflow: hidden;
}

.kg-scavenge-card::before {
  content: '?';
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.6rem;
  font-weight: 900;
  color: rgba(56, 189, 248, 0.4);
  transition: opacity 0.3s;
}

.kg-scavenge-card.hidden-char { color: transparent; }

.kg-scavenge-card.hidden-char::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.06) 50%, transparent 60%);
  animation: kgShimmer 2.5s ease-in-out infinite;
}

@keyframes kgShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.kg-scavenge-card.revealed {
  border-style: solid;
  border-color: rgba(56, 189, 248, 0.55);
  background: linear-gradient(145deg, rgba(56, 189, 248, 0.15), rgba(12, 14, 28, 0.8));
  transform: scale(1.05);
  box-shadow: 0 12px 32px rgba(56, 189, 248, 0.2);
  animation: kgRevealFlip 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
}

.kg-scavenge-card.revealed::before { opacity: 0; }

@keyframes kgRevealFlip {
  0%   { transform: rotateY(90deg) scale(0.9); opacity: 0.5; }
  100% { transform: rotateY(0) scale(1.05); opacity: 1; }
}

.kg-scavenge-card.found {
  border-color: var(--mint, #00f5d4);
  border-style: solid;
  background: rgba(0, 245, 212, 0.12);
  pointer-events: none;
  animation: kgFoundGlow 0.5s ease;
}

.kg-scavenge-card.found::before { display: none; }

@keyframes kgFoundGlow {
  0%   { box-shadow: 0 0 0 0 rgba(0, 245, 212, 0.6); }
  100% { box-shadow: 0 0 24px 4px rgba(0, 245, 212, 0.3); }
}

.kg-scavenge-input-wrap {
  max-width: 380px;
  margin: 0 auto 8px;
  padding: 0 22px;
  display: flex;
  gap: 10px;
}

.kg-scavenge-input {
  flex: 1;
  padding: 14px 18px;
  border-radius: 14px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.kg-scavenge-input:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.12);
}

/* ── Board game ───────────────────────────────────────────────── */
.kg-board-arena {
  padding: 20px 22px;
}

.kg-board-track {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  max-width: 560px;
  margin: 0 auto 28px;
  padding: 20px;
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(168, 85, 247, 0.15);
}

.kg-board-space {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 800;
  color: #444;
  position: relative;
  transition: all 0.35s cubic-bezier(0.34, 1.3, 0.64, 1);
}

.kg-board-space.player {
  background: linear-gradient(135deg, rgba(230, 57, 70, 0.35), rgba(255, 101, 132, 0.2));
  border-color: var(--red, #e63946);
  color: #fff;
  transform: scale(1.15);
  box-shadow: 0 0 20px rgba(230, 57, 70, 0.4);
  z-index: 2;
}

.kg-board-space.player::after {
  content: '社';
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 900;
  position: absolute;
  top: -14px;
  font-size: 0.9rem;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

.kg-board-space.goal {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.25), rgba(245, 158, 11, 0.1));
  border-color: #fbbf24;
  font-size: 1.1rem;
}

.kg-dice-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 20px;
}

.kg-dice {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(145deg, #2a2040, #1a1428);
  border: 2px solid rgba(168, 85, 247, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  font-weight: 900;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s;
}

.kg-dice.rolling {
  animation: kgDiceRoll 0.6s ease-in-out;
}

@keyframes kgDiceRoll {
  0%   { transform: rotate(0) scale(1); }
  25%  { transform: rotate(90deg) scale(1.1); }
  50%  { transform: rotate(180deg) scale(0.95); }
  75%  { transform: rotate(270deg) scale(1.05); }
  100% { transform: rotate(360deg) scale(1); }
}

.kg-board-question {
  text-align: center;
  padding: 32px 28px;
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(168, 85, 247, 0.15), transparent 70%),
    rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(168, 85, 247, 0.2);
  border-radius: 20px;
  margin: 0 auto;
  max-width: 420px;
  animation: kgPanelIn 0.4s ease;
}

.kg-board-char {
  font-family: 'Noto Sans JP', sans-serif;
  font-size: clamp(3.5rem, 12vw, 5rem);
  font-weight: 900;
  color: #fff;
  margin-bottom: 8px;
  text-shadow: 0 0 40px rgba(168, 85, 247, 0.4);
  line-height: 1;
}

.kg-board-q-label {
  color: #777;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

.kg-board-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.kg-board-choice {
  padding: 14px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #ccc;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.92rem;
  transition: all 0.22s cubic-bezier(0.34, 1.2, 0.64, 1);
}

.kg-board-choice:hover:not(.eliminated):not(:disabled) {
  border-color: var(--red, #e63946);
  color: #fff;
  background: rgba(230, 57, 70, 0.12);
  transform: translateY(-2px);
}

.kg-board-choice.correct-pick {
  border-color: var(--mint, #00f5d4) !important;
  background: rgba(0, 245, 212, 0.15) !important;
  color: var(--mint, #00f5d4) !important;
}

.kg-board-choice.wrong-pick {
  border-color: var(--red, #e63946) !important;
  background: rgba(230, 57, 70, 0.15) !important;
  animation: kgShake 0.4s;
}

.kg-board-choice.eliminated {
  opacity: 0.2;
  pointer-events: none;
  text-decoration: line-through;
  border-color: rgba(255, 255, 255, 0.04);
}

/* ── Memory cards ─────────────────────────────────────────────── */
.kg-memory-arena {
  padding: 20px 22px;
}

.kg-memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  max-width: 500px;
  margin: 0 auto;
}

.kg-memory-card {
  aspect-ratio: 0.82;
  border-radius: 14px;
  cursor: pointer;
  perspective: 800px;
  position: relative;
}

.kg-memory-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.kg-memory-card.flipped .kg-memory-inner,
.kg-memory-card.peek .kg-memory-inner {
  transform: rotateY(180deg);
}

.kg-memory-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border: 2px solid rgba(255, 255, 255, 0.1);
}

.kg-memory-front {
  background:
    radial-gradient(circle at 30% 30%, rgba(0, 245, 212, 0.15), transparent 50%),
    linear-gradient(145deg, #1a1028, #0d0a18);
  font-size: 1.5rem;
  color: var(--mint, #00f5d4);
  box-shadow: inset 0 0 30px rgba(0, 245, 212, 0.08);
}

.kg-memory-front::before {
  content: '桜';
  position: absolute;
  font-size: 3rem;
  opacity: 0.06;
  font-family: 'Noto Sans JP', sans-serif;
}

.kg-memory-back {
  background: linear-gradient(145deg, #1c1812, #12100c);
  transform: rotateY(180deg);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 1.6rem;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.kg-memory-back.romaji-back {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  color: #ddd;
  letter-spacing: 0.03em;
}

.kg-memory-card.matched .kg-memory-inner {
  opacity: 0.45;
  transform: rotateY(180deg) scale(0.92);
}

.kg-memory-card.match-celebrate .kg-memory-inner {
  animation: kgMemCelebrate 0.6s cubic-bezier(0.34, 1.5, 0.64, 1);
}

@keyframes kgMemCelebrate {
  0%   { transform: rotateY(180deg) scale(1); }
  40%  { transform: rotateY(180deg) scale(1.1); }
  100% { transform: rotateY(180deg) scale(0.92); }
}

.kg-memory-card:not(.flipped):not(.matched):hover .kg-memory-inner {
  transform: translateY(-4px);
}

/* ── Status messages ──────────────────────────────────────────── */
.kg-status {
  text-align: center;
  padding: 12px 22px 0;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--mint, #00f5d4);
  min-height: 1.4em;
}

.kg-status.win {
  font-size: 1rem;
  animation: kgStatusWin 0.5s ease;
}

@keyframes kgStatusWin {
  from { transform: scale(0.9); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* ── Hint button ──────────────────────────────────────────────── */
.kg-hint-btn {
  border-color: rgba(251, 191, 36, 0.5) !important;
  color: #fbbf24 !important;
}

.kg-hint-btn:hover {
  background: rgba(251, 191, 36, 0.12) !important;
  box-shadow: 0 0 16px rgba(251, 191, 36, 0.2) !important;
}

/* ── XP float popup ───────────────────────────────────────────── */
.kg-xp-pop {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--mint, #00f5d4);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  animation: kgXpFloat 1s ease forwards;
}

@keyframes kgXpFloat {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-48px) scale(1.2); }
}

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 700px) {
  .kg-match-board {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .kg-match-vs { display: none; }
  .kg-bingo-grid { max-width: 100%; gap: 8px; }
  .kg-memory-grid { grid-template-columns: repeat(3, 1fr); }
  .kg-board-space { width: 40px; height: 40px; }
  .kg-toolbar { padding: 14px 16px; }
  .kg-panel-inner { padding: 18px 16px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .kana-game-card::after,
  .kg-scavenge-card.hidden-char::after,
  .kg-timer.urgent,
  .kg-dice.rolling {
    animation: none !important;
  }
  .kana-game-card:hover { transform: none; }
  .kg-bingo-cell:hover:not(.marked) { transform: none; }
}