/* ===== 색상·크기 변수: 여기 값만 바꿔도 전체 분위기가 바뀌어요 ===== */
:root {
  --bg-top: #18345a;
  --bg-bottom: #080d1c;
  --text: #eaf3ff;
  --text-dim: #9eb2d3;
  --panel: #10203a;
  --border: #33507a;
  --accent: #48c8ff;
  --danger: #ff5470;
  --gold: #ffd166;
  --radius: 14px;
  --stage-h: 72vh; /* 게임 화면 최대 높이 */
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at 50% 10%, var(--bg-top), var(--bg-bottom) 70%);
  color: var(--text);
  font-family: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(100%, 560px);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

/* ----- 상단 바 ----- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.logo { margin: 0; font-size: 1.3rem; letter-spacing: .06em; }
.top-buttons { display: flex; gap: 8px; }

.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  touch-action: manipulation;
}
.icon-btn:hover:not(:disabled) { border-color: var(--accent); }
.icon-btn:disabled { opacity: .35; cursor: default; }

/* ----- 점수판 ----- */
.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0d1a30cc;
}
.stat .label { font-size: .72rem; color: var(--text-dim); }
.stat b { display: inline-block; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.hearts { font-size: .95rem !important; letter-spacing: -2px; }
.bump { animation: bump .25s ease; }
@keyframes bump { 50% { transform: scale(1.35); } }

/* ----- 게임 화면 + 오버레이 ----- */
.stage {
  position: relative;
  width: min(100%, calc(var(--stage-h) * 3 / 4));
  aspect-ratio: 3 / 4;
  margin: 0 auto;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #091426;
  box-shadow: 0 16px 60px #0008;
  touch-action: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  border-radius: var(--radius);
  background: #050a14b8;
  backdrop-filter: blur(3px);
  text-align: center;
  animation: fade-in .2s ease;
}
.overlay h2 { margin: 0; font-size: 2rem; letter-spacing: .05em; }
.overlay p { margin: 0; color: var(--text-dim); line-height: 1.6; }
@keyframes fade-in { from { opacity: 0; transform: scale(.98); } }

.howto { margin: 4px 0; padding: 0; list-style: none; color: var(--text-dim); line-height: 2; }
.hint { font-size: .8rem; }
.final { font-size: 1.15rem; }
.final b { color: var(--text); font-size: 1.6rem; }
.new-best { color: var(--gold) !important; font-weight: 700; }

kbd {
  display: inline-block;
  min-width: 1.8em;
  padding: 1px 6px;
  border: 1px solid #496184;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #1b2b46;
  color: #fff;
  font: inherit;
  font-size: .85em;
}

.primary-btn {
  margin-top: 6px;
  padding: 12px 34px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #061322;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px #48c8ff55;
  touch-action: manipulation;
  transition: transform .1s;
}
.primary-btn:hover { transform: translateY(-1px); }
.primary-btn:active { transform: scale(.97); }

button:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ----- 터치 조작: 기본은 숨김 ----- */
#touch-controls, .howto-touch { display: none; }

/* 손가락으로 조작하는 기기(휴대폰·태블릿) */
@media (pointer: coarse) {
  :root { --stage-h: 60svh; }
  .app { padding-top: 8px; }
  .logo { font-size: 1.1rem; }
  .topbar, .hud { margin-bottom: 6px; }
  .howto-keys { display: none; }
  .howto-touch { display: block; }
  #touch-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    max-width: 420px;
    margin: 12px auto 0;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  .move-controls { display: flex; gap: 10px; }
  #touch-controls button {
    display: grid;
    place-items: center;
    width: 72px;
    height: 62px;
    border: 1px solid #6090bd;
    border-radius: var(--radius);
    background: #1a3556;
    color: var(--text);
    font-size: 1.35rem;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
  }
  #touch-controls button:active { background: #2d5a83; transform: scale(.96); }
  #touch-controls #fire { width: 96px; background: #b63e61; border-color: #f17a91; font-size: 1.05rem; font-weight: 700; }
}

/* 움직임을 줄이도록 설정한 사용자 배려 */
@media (prefers-reduced-motion: reduce) {
  .overlay, .bump { animation: none; }
}
