/* 환타지오락실 — 네온 아케이드 */
:root {
  --bg: #141026;
  --bg2: #1e1838;
  --ink: #f2eefc;
  --dim: #9a8fc0;
  --neon: #ff5fa8;
  --neon2: #4de3c1;
  --gold: #ffd76e;
  --card: #241d42;
  --line: rgba(255,255,255,.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 800px at 50% -10%, #2a2050 0%, var(--bg) 60%);
  color: var(--ink);
  font-family: ui-rounded, "Apple SD Gothic Neo", "Pretendard", system-ui, sans-serif;
  display: flex; justify-content: center;
  touch-action: manipulation; user-select: none; -webkit-user-select: none;
}
#app { width: 100%; max-width: 460px; min-height: 100%; display: flex; flex-direction: column; }

/* ── 메뉴 ── */
#menu { padding: 18px 14px 40px; }
.menu-head { text-align: center; }
.menu-head h1 {
  margin: 6px 0 2px; font-size: 34px; letter-spacing: -1px;
  color: var(--ink); text-shadow: 0 0 18px rgba(255,95,168,.55);
}
.menu-head h1 span { color: var(--neon); }
.menu-head .sub { margin: 2px 0 12px; color: var(--dim); font-size: 12.5px; }
.menu-tools { display: flex; gap: 6px; justify-content: center; align-items: center; flex-wrap: wrap; }
#cat-chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.chip {
  border: 1px solid var(--line); background: var(--card); color: var(--dim);
  border-radius: 999px; padding: 6px 12px; font-size: 12.5px; cursor: pointer;
}
.chip.on { background: var(--neon); border-color: var(--neon); color: #fff; box-shadow: 0 0 12px rgba(255,95,168,.4); }
.chip:active { transform: scale(.95); }
.total { margin: 10px 0 0; color: var(--dim); font-size: 12px; }
.total b { color: var(--neon2); }

#tile-grid {
  margin-top: 14px; display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
.tile {
  position: relative; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 10px 10px; text-align: center; cursor: pointer;
  transition: transform .12s, box-shadow .12s; overflow: hidden;
}
.tile:active { transform: scale(.96); }
.tile .ico { font-size: 30px; line-height: 1; display: block; filter: drop-shadow(0 0 8px rgba(255,255,255,.15)); }
.tile .nm { display: block; margin-top: 7px; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .cat { display: block; margin-top: 2px; font-size: 10px; color: var(--dim); }
.tile .stars { display: block; margin-top: 4px; font-size: 10.5px; color: var(--gold); min-height: 13px; }
.tile .num { position: absolute; top: 6px; left: 8px; font-size: 9.5px; color: var(--dim); opacity: .7; }
.tile.done { border-color: rgba(77,227,193,.5); }
.tile.done::after { content: "✓"; position: absolute; top: 5px; right: 8px; color: var(--neon2); font-size: 12px; }

/* ── 게임 화면 ── */
#stage { flex: 1; display: flex; flex-direction: column; padding: 10px 10px 14px; }
#game-hud { display: flex; align-items: center; gap: 10px; padding: 2px 2px 8px; }
#btn-back {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  width: 38px; height: 38px; border-radius: 12px; font-size: 16px; cursor: pointer; flex: none;
}
.hud-title { flex: 1; min-width: 0; }
.hud-title b { display: block; font-size: 16px; }
.hud-title small { display: block; color: var(--dim); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-score { text-align: right; flex: none; }
.hud-score b { display: block; font-size: 18px; color: var(--neon2); }
.hud-score small { display: block; color: var(--dim); font-size: 10.5px; }

#cv-wrap { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; }
#cv {
  background: #0d0a1a; border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 0 60px rgba(80,60,160,.12);
  touch-action: none; display: block;
}
#hint {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(20,16,38,.88); border: 1px solid var(--line); color: var(--ink);
  border-radius: 999px; padding: 7px 16px; font-size: 12.5px; pointer-events: none;
  white-space: nowrap; animation: hintfade .3s;
}
@keyframes hintfade { from { opacity: 0; transform: translate(-50%, 6px); } }

/* ── 게임 오버 ── */
#over {
  position: fixed; inset: 0; background: rgba(10,8,20,.72); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.over-card {
  width: min(320px, 88%); background: var(--bg2); border: 1px solid var(--line);
  border-radius: 22px; padding: 24px 20px 18px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.6); animation: pop .25s ease-out;
}
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
#over-emoji { font-size: 44px; }
.over-card h2 { margin: 8px 0 4px; font-size: 21px; }
#over-score { margin: 2px 0; font-size: 16px; color: var(--neon2); font-weight: 700; }
#over-best { margin: 0 0 14px; font-size: 12px; color: var(--dim); }
.over-btns { display: flex; gap: 8px; }
.btn {
  flex: 1; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 14px; padding: 12px 10px; font-size: 14.5px; font-weight: 700; cursor: pointer;
}
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--neon); border-color: var(--neon); color: #fff; box-shadow: 0 4px 16px rgba(255,95,168,.4); }
.btn.ghost { background: transparent; border: none; color: var(--dim); margin-top: 6px; font-weight: 400; font-size: 13px; }
.newrec { color: var(--gold); font-weight: 700; }
