/* ===== MINI GAME ZONE — 게임 공통 크롬 ===== */
:root {
  --bg: #17141F;
  --bg2: #221D31;
  --panel: #2A2438;
  --wall: #4A3F66;
  --ink: #F4EFFA;
  --ink-2: #B9AFD0;
  --violet: #8B7CFF;
  --violet-deep: #6A5AE0;
  --gold: #FFD166;
  --danger: #FF6B5E;
  --mint: #5CE0B3;
  --radius: 14px;
  --shadow: 0 4px 14px rgba(0,0,0,.35);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: radial-gradient(circle at 25% 15%, rgba(139,124,255,.14), transparent 45%),
                    radial-gradient(circle at 80% 85%, rgba(92,224,179,.10), transparent 45%);
}
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--gold); color: #201A33; font-weight: 800;
  padding: 10px 18px; border-radius: 0 0 14px 0;
}
.skip-link:focus { left: 0; }

/* ----- 상단바 ----- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 26px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  background: rgba(23,20,31,.9);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 50;
}
.logo { font-family: 'Press Start 2P', monospace; font-size: 1rem; letter-spacing: .04em; }
.logo-back { color: var(--mint); text-decoration: none; font-size: .6rem; margin-right: 10px; }
.logo-back:hover { text-decoration: underline; }
.logo-dot { color: var(--gold); }
.switches { display: flex; gap: 8px; }
.switch {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: .8rem; font-weight: 700; color: var(--ink-2);
  background: var(--panel); border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.switch .track {
  width: 34px; height: 19px; border-radius: 999px;
  background: #453D5C; position: relative; transition: background .15s;
}
.switch .thumb {
  position: absolute; left: 2px; top: 2px; width: 15px; height: 15px;
  border-radius: 50%; background: #fff; transition: transform .15s;
}
.switch[aria-checked="true"] .track { background: var(--violet); }
.switch[aria-checked="true"] .thumb { transform: translateX(15px); }

/* ----- 게임 영역 (레이아웃은 각 게임 CSS가 담당) ----- */

/* ----- 오버레이 ----- */
.overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background: rgba(23,20,31,.82);
  backdrop-filter: blur(4px);
  border-radius: var(--radius);
  z-index: 5;
}
.overlay[hidden] { display: none; }
.overlay-card {
  text-align: center; padding: 30px; max-width: 380px;
}
.overlay-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.5rem; color: var(--gold); margin-bottom: 14px;
  text-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
.overlay-mascot {
  font-size: 3rem; margin-bottom: 10px;
  animation: mascotFloat 2.2s ease-in-out infinite;
}
@keyframes mascotFloat { 50% { transform: translateY(-8px) rotate(-4deg); } }
.overlay-msg { font-size: .95rem; color: var(--ink-2); line-height: 1.7; margin-bottom: 22px; }

.btn-primary {
  font: inherit; font-weight: 800; font-size: 1rem;
  background: var(--violet); color: #fff;
  border: none; border-radius: 12px; padding: 13px 30px;
  cursor: pointer; box-shadow: 0 6px 0 #453B7A, var(--shadow);
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #453B7A, var(--shadow-lg); }
.btn-primary:active { transform: translateY(2px); box-shadow: 0 3px 0 #453B7A, var(--shadow); }

.status-line {
  text-align: center; margin-top: 14px;
  font-size: .95rem; font-weight: 700; color: var(--gold);
  min-height: 1.4em;
}
.controls-line {
  text-align: center; margin-top: 4px;
  font-size: .84rem; color: var(--ink-2); line-height: 1.6;
}

/* ----- 기록 패널 ----- */
.records {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.records-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.records h2 { font-size: 1.05rem; font-weight: 800; }
.records-actions { display: flex; gap: 6px; }
.btn-ghost {
  font: inherit; font-size: .76rem; font-weight: 700;
  background: transparent; color: var(--ink-2);
  border: 1px solid rgba(255,255,255,.15); border-radius: 9px;
  padding: 6px 10px; cursor: pointer;
}
.btn-ghost:hover { background: rgba(255,255,255,.06); color: var(--ink); }
.records-hint { font-size: .8rem; color: var(--ink-2); margin-bottom: 12px; }
.records-hint b { color: var(--gold); }
.log-table { width: 100%; border-collapse: collapse; font-size: .8rem; }
.log-table th {
  text-align: left; color: var(--ink-2); font-weight: 700;
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.1);
  font-size: .7rem; letter-spacing: .06em;
}
.log-table td { padding: 7px 8px; border-bottom: 1px solid rgba(255,255,255,.05); }
.log-table .win { color: var(--mint); font-weight: 700; }
.log-table .rank-1 td:first-child { color: #FFD166; font-weight: 800; }
.log-table .rank-2 td:first-child { color: #C9C3DD; font-weight: 800; }
.log-table .rank-3 td:first-child { color: #D2936B; font-weight: 800; }

/* ----- 모바일 일시정지 버튼 — 게임 영역 우상단 ----- */
.pause-btn {
  position: absolute; top: 10px; right: 10px; z-index: 40;
  font: 700 .78rem/1 Pretendard, sans-serif;
  color: var(--ink); background: rgba(23,20,31,.72);
  border: 1px solid rgba(255,255,255,.18); border-radius: 999px;
  padding: 7px 12px; cursor: pointer; backdrop-filter: blur(4px);
}
.pause-btn[hidden] { display: none; }

/* ----- 순위 등록 (이름 입력) — 게임 공통 ----- */
.name-entry {
  margin-bottom: 16px;
  background: rgba(139,124,255,.12);
  border: 1px solid rgba(139,124,255,.35);
  border-radius: 12px; padding: 12px 14px;
}
.name-hint { font-size: .8rem; font-weight: 700; color: var(--gold); margin-bottom: 8px; }
.name-row { display: flex; gap: 8px; }
.name-row input {
  flex: 1; min-width: 0;
  font: inherit; font-weight: 700; font-size: .9rem;
  background: #17141F; color: var(--ink);
  border: 1px solid rgba(255,255,255,.15); border-radius: 9px;
  padding: 8px 12px; text-align: center;
}
.log-empty { text-align: center; color: var(--ink-2); padding: 18px 0; }

/* ----- 공통 키프레임 ----- */
@keyframes shake {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(-5px,2px); }
  50% { transform: translate(5px,-2px); }
  75% { transform: translate(-3px,-1px); }
}

/* ----- 움직임 줄이기 ----- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01s !important; transition-duration: .01s !important; }
}
html.reduce-motion * { animation-duration: .01s !important; transition-duration: .01s !important; }
