/* 버튼 느낌을 바꿀 때는 아래 변수와 .mode-btn 블록만 고치면 됩니다. */
:root {
  --bg: #07060d;
  --bg-glow: #1d1038;
  --text: #eef2ff;
  --muted: #8f8cab;
  --panel: #0f0d1a;
  --line: #2e2a4a;
  --neon-red: #ff2e63;
  --neon-blue: #00e5ff;
  --neon-yellow: #ffe14d;
  --neon-dark: #0b0a12;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background:
    linear-gradient(rgba(0, 229, 255, 0.05) 1px, transparent 1px) 0 0 / 100% 44px,
    linear-gradient(90deg, rgba(0, 229, 255, 0.05) 1px, transparent 1px) 0 0 / 44px 100%,
    radial-gradient(ellipse at 50% 0%, var(--bg-glow), var(--bg) 70%);
  background-attachment: fixed;
  color: var(--text);
  font-family: "Pretendard", "Noto Sans KR", system-ui, sans-serif;
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100%;
  padding: 76px 16px 32px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  text-align: center;
}
.screen.active { display: flex; }

/* ---------- 메인 메뉴 ---------- */
.title {
  margin: 0;
  font-size: clamp(56px, 16vw, 140px);
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff;
  text-shadow:
    0 0 6px #fff,
    0 0 18px var(--neon-red),
    0 0 48px var(--neon-red),
    4px 4px 0 var(--neon-blue);
  animation: title-flicker 5s linear infinite;
}

@keyframes title-flicker {
  0%, 91%, 94%, 97%, 100% { opacity: 1; }
  92%, 96% { opacity: 0.55; }
}

.tagline { margin: 0 0 16px; color: var(--muted); font-size: 18px; }

.mode-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 28px;
  width: 100%;
  max-width: 760px;
}

.mode-btn {
  --c: var(--neon-red);
  --cut: 22px;
  position: relative;
  isolation: isolate;
  flex: 1 1 280px;
  max-width: 360px;
  padding: 36px 24px;
  border: 0;
  background: none;
  color: var(--c);
  font: inherit;
  cursor: pointer;
  filter: drop-shadow(0 0 5px var(--c)) drop-shadow(0 0 16px var(--c));
  animation: neon-pulse 2s ease-in-out infinite;
  transition: transform 0.12s, filter 0.15s, color 0.15s;
}
.mode-btn.blue { --c: var(--neon-blue); }

/* 각진 모서리: ::before 가 네온 테두리, ::after 가 어두운 안쪽 면 */
.mode-btn::before, .mode-btn::after {
  content: "";
  position: absolute;
  z-index: -1;
  clip-path: polygon(
    var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut)
  );
}
.mode-btn::before { inset: 0; background: var(--c); }
.mode-btn::after { inset: 3px; background: var(--neon-dark); transition: background 0.15s; }

.mode-btn > span { display: block; }
.mode-name {
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.06em;
  text-shadow: 0 0 10px currentColor;
}
.mode-desc { margin-top: 10px; font-size: 15px; color: var(--text); opacity: 0.85; }

@keyframes neon-pulse {
  0%, 100% { filter: drop-shadow(0 0 4px var(--c)) drop-shadow(0 0 12px var(--c)); }
  50% { filter: drop-shadow(0 0 8px var(--c)) drop-shadow(0 0 28px var(--c)); }
}

/* 올리면 네온으로 꽉 차고, 누르면 쑥 들어감 */
.mode-btn:hover {
  animation: none;
  color: var(--neon-dark);
  transform: scale(1.06);
  filter: drop-shadow(0 0 10px var(--c)) drop-shadow(0 0 36px var(--c));
}
.mode-btn:hover::after { background: var(--c); }
.mode-btn:hover .mode-name { text-shadow: none; }
.mode-btn:hover .mode-desc { color: var(--neon-dark); opacity: 1; }
.mode-btn:active {
  transform: scale(0.95);
  filter: drop-shadow(0 0 4px var(--c)) brightness(1.25);
}
.mode-btn:focus-visible, .sub-btn:focus-visible, input:focus-visible {
  outline: 3px solid var(--neon-yellow);
  outline-offset: 4px;
}

/* ---------- 하위 화면 ---------- */
.heading {
  margin: 0;
  font-size: 40px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 0.04em;
  color: #fff;
  text-shadow: 0 0 6px #fff, 0 0 20px var(--neon-blue), 0 0 44px var(--neon-blue);
}
.status { margin: 0; font-size: 22px; font-weight: 700; }
.note { margin: 0; min-height: 1.4em; color: var(--muted); font-size: 14px; }

.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots {
  0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; }
}

.spinner {
  width: 64px; height: 64px;
  border: 6px solid var(--line);
  border-top-color: var(--neon-red);
  border-radius: 50%;
  filter: drop-shadow(0 0 8px var(--neon-red));
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sub-btn {
  padding: 12px 28px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, color 0.15s, background 0.15s;
}
.sub-btn:hover {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.55);
}
.sub-btn.primary {
  border-color: var(--neon-blue);
  color: var(--neon-blue);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.45), inset 0 0 10px rgba(0, 229, 255, 0.2);
}
.sub-btn.primary:hover { background: var(--neon-blue); color: var(--neon-dark); }

.room-panel {
  width: 100%;
  max-width: 380px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0;
  box-shadow: 0 0 24px rgba(0, 229, 255, 0.12);
}
.room-code { margin: 0; font-size: 32px; font-weight: 900; letter-spacing: 0.25em; color: var(--neon-yellow); text-shadow: 0 0 12px var(--neon-yellow); }
.divider { color: var(--muted); font-size: 13px; }

.join-form { display: flex; gap: 8px; }
.join-form input {
  flex: 1;
  min-width: 0;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

/* ---------- 레벨 / 경험치 (왼쪽 위 고정) ---------- */
.player-level {
  position: fixed;
  top: 12px;
  left: 68px; /* 톱니바퀴 버튼 바로 오른쪽 */
  min-height: 46px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border: 2px solid var(--neon-yellow);
  box-shadow: 0 0 12px rgba(255, 225, 77, 0.35);
}
.lv { font-size: 22px; font-weight: 900; font-style: italic; color: var(--neon-yellow); text-shadow: 0 0 10px var(--neon-yellow); }
.xp { width: 120px; display: flex; flex-direction: column; gap: 3px; }
.xp .bar i { width: 0; box-shadow: 0 0 8px var(--neon-yellow); transition: width 0.4s; }
.xp-text { font-size: 11px; color: var(--muted); text-align: left; }

/* ---------- 설정 (오른쪽 위 톱니바퀴) ---------- */
.gear-btn {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.gear-btn svg { transition: transform 0.4s; }
.gear-btn:hover { color: var(--neon-blue); border-color: var(--neon-blue); box-shadow: 0 0 12px rgba(0, 229, 255, 0.55); }
.gear-btn:hover svg { transform: rotate(60deg); }
.gear-btn:focus-visible { outline: 3px solid var(--neon-yellow); outline-offset: 4px; }

.settings {
  width: min(460px, calc(100vw - 32px)); /* 화면 가운데에 뜨는 모달 */
  max-height: calc(100vh - 32px);
  padding: 22px;
  border: 2px solid var(--neon-blue);
  background: var(--panel);
  color: var(--text);
  text-align: center;
  box-shadow: 0 0 30px rgba(0, 229, 255, 0.35);
  overflow-y: auto;
}
.settings::backdrop { background: rgba(7, 6, 13, 0.75); }
.settings .heading { margin-bottom: 14px; font-size: 32px; }
.set-group { margin-bottom: 16px; padding-top: 12px; border-top: 2px solid var(--line); text-align: left; }
.set-group h3 { margin: 0 0 8px; font-size: 14px; letter-spacing: 0.1em; color: var(--neon-yellow); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; font-size: 15px; font-weight: 700; }
.set-row input[type="range"] { flex: 0 1 200px; min-width: 0; accent-color: var(--neon-blue); cursor: pointer; }
.set-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--neon-blue); cursor: pointer; }
.set-buttons { display: flex; gap: 8px; }
.sub-btn.small { padding: 7px 14px; font-size: 14px; }
.sub-btn.danger:hover { border-color: var(--neon-red); color: var(--neon-red); box-shadow: 0 0 12px rgba(255, 46, 99, 0.55); }
.sound-status { margin: 8px 0 0; padding: 8px 10px; border: 1px solid var(--line); font-size: 12px; line-height: 1.6; color: var(--muted); white-space: pre-line; }
.set-group .note { text-align: left; }

/* ---------- 입장 화면 (자동 재생이 막혔을 때만) ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  background: var(--bg);
  cursor: pointer;
}
.gate[hidden] { display: none; }
.gate-text {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--neon-yellow);
  text-shadow: 0 0 12px var(--neon-yellow);
  animation: gate-blink 1.2s ease-in-out infinite;
}
@keyframes gate-blink { 50% { opacity: 0.35; } }

/* ---------- 캐릭터 선택 ---------- */
.char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 780px;
}
.char-card {
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}
.char-card canvas { width: 120px; height: auto; }
.char-desc { min-height: 2.8em; font-size: 12px; line-height: 1.4; color: var(--text); opacity: 0.8; }
.char-card:hover { border-color: var(--c); transform: translateY(-3px); }
.char-card.selected {
  border-color: var(--c);
  box-shadow: 0 0 18px var(--c), inset 0 0 18px color-mix(in srgb, var(--c) 25%, transparent);
}
.char-card:focus-visible { outline: 3px solid var(--neon-yellow); outline-offset: 4px; }
.char-name { font-size: 20px; font-weight: 900; color: var(--c); text-shadow: 0 0 8px var(--c); }
.char-type { font-size: 13px; color: var(--muted); }
.stat { width: 100%; display: flex; align-items: center; gap: 8px; font-size: 12px; }
.stat span { width: 30px; text-align: left; color: var(--muted); }
.stat .bar { flex: 1; }
.stat .bar i { background: var(--c); }

/* ---------- 경기 화면 ---------- */
/* 화면이 낮아도 스크롤 없이 한눈에 들어오도록 링 너비를 높이에 맞춤 */
#screen-game { --ring-w: min(900px, max(320px, calc((100vh - 430px) * 16 / 9))); gap: 12px; padding: 76px 16px 16px; }

.practice-bar {
  width: 100%;
  max-width: var(--ring-w);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--panel);
  border: 2px solid var(--neon-yellow);
  box-shadow: 0 0 12px rgba(255, 225, 77, 0.25);
}
.practice-bar[hidden] { display: none; }
.practice-title { align-self: center; font-size: 18px; font-weight: 900; font-style: italic; color: var(--neon-yellow); text-shadow: 0 0 10px var(--neon-yellow); }
.practice-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); text-align: left; }
.practice-bar select {
  padding: 8px 10px;
  border: 2px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.practice-bar select:hover, .practice-bar select:focus-visible { border-color: var(--neon-blue); outline: none; }
.practice-bar select:disabled { opacity: 0.4; cursor: default; }

kbd {
  margin-left: 6px;
  padding: 1px 7px;
  border: 1px solid currentColor;
  font: inherit;
  font-size: 13px;
  opacity: 0.8;
}

.hud {
  width: 100%;
  max-width: var(--ring-w);
  display: flex;
  align-items: center;
  gap: 16px;
}
.hud-side { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; text-align: left; }
.hud-side.right { text-align: right; }
.hud-name { font-size: 16px; font-weight: 900; letter-spacing: 0.08em; color: var(--c); text-shadow: 0 0 8px currentColor; }
.hud-timer {
  min-width: 64px;
  font-size: 40px;
  font-weight: 900;
  font-style: italic;
  color: var(--neon-yellow);
  text-shadow: 0 0 12px var(--neon-yellow);
}

.bar { display: flex; height: 16px; background: var(--panel); border: 2px solid var(--line); }
.bar.thin { height: 8px; }
.hud-side.right .bar { justify-content: flex-end; }
.bar i { display: block; width: 100%; background: var(--neon-yellow); }
.bar.hp i { background: var(--c); box-shadow: 0 0 10px var(--c); }

.ring-wrap { position: relative; width: 100%; max-width: var(--ring-w); }
#ring {
  display: block;
  width: 100%;
  height: auto;
  background: rgba(7, 6, 13, 0.75);
  border: 2px solid var(--line);
  box-shadow: 0 0 24px rgba(255, 46, 99, 0.18);
}

.result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: rgba(7, 6, 13, 0.8);
}
.result[hidden] { display: none; }
.result-text {
  margin: 0;
  font-size: clamp(36px, 9vw, 72px);
  font-weight: 900;
  font-style: italic;
  color: #fff;
  text-shadow: 0 0 6px #fff, 0 0 22px var(--neon-red), 0 0 50px var(--neon-red);
}
.result-xp { margin: 0; font-size: 20px; font-weight: 900; color: var(--neon-yellow); text-shadow: 0 0 10px var(--neon-yellow); }
.result-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }

.pad { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.pad-btn {
  --c: var(--neon-blue);
  min-width: 64px;
  padding: 14px 16px;
  border: 2px solid var(--c);
  background: var(--neon-dark);
  color: var(--c);
  font: inherit;
  font-size: 18px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 0 10px color-mix(in srgb, var(--c) 50%, transparent);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.pad-btn.red { --c: var(--neon-red); }
.pad-btn:active { background: var(--c); color: var(--neon-dark); }

@media (prefers-reduced-motion: reduce) {
  .spinner, .dots::after, .title { animation: none; }
  .mode-btn { transition: none; animation: none; }
}
