/* 안드로이드 res/values/colors.xml 매핑 */
:root {
  --bg-primary: #5b7ba5;
  --bg-secondary: #4a6a94;
  --text-primary: #ffffff;
  --text-secondary: #d0d8e8;
  --accent: #e8945a;
  --accent-dark: #c07840;
  --surface: #ffffff;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  overscroll-behavior: none;
}
#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
}
.screen {
  position: absolute;
  inset: 0;
  display: none;
}
.screen.active {
  display: block;
}
.hidden {
  display: none !important;
}

/* 공통 버튼 */
.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary {
  display: block;
  width: 240px;
  max-width: 80vw;
  height: 56px;
  margin: 0 auto;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.05em;
  border-radius: 28px;
  box-shadow: 0 6px 16px rgba(192, 120, 64, 0.4);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn-primary:active {
  transform: scale(0.97);
  filter: brightness(0.95);
}
.btn-text {
  display: block;
  margin: 10px auto 0;
  background: transparent;
  color: var(--accent-dark);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
}

.gear-btn {
  position: absolute;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: 12px;
  width: 44px;
  height: 44px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 22px;
  cursor: pointer;
  z-index: 5;
}

/* ── 타이틀 ───────────────────────────── */
#screen-title {
  background: var(--bg-primary);
}
.title-bg {
  position: absolute;
  inset: -20px; /* blur 가장자리 가림 */
  width: calc(100% + 40px);
  height: calc(100% + 40px);
  object-fit: cover;
  filter: blur(8px);
  opacity: 0.85;
}
.title-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.19);
}
.glass-card {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  width: calc(100% - 64px);
  max-width: 360px;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: 24px;
  padding: 40px 24px;
  text-align: center;
}
.title-icon {
  font-size: 64px;
  margin-bottom: 16px;
  line-height: 1;
}
.game-title {
  margin: 0;
  font-size: 48px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.05em;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.38);
}
.game-subtitle {
  margin: 6px 0 36px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
  letter-spacing: 0.12em;
}

/* ── 게임 ─────────────────────────────── */
#screen-game {
  background: var(--bg-primary);
}
.game-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  /* 콘텐츠 높이 44px = 기어 버튼 높이 → Level 글자가 기어와 세로 중앙 정렬 */
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 0;
  z-index: 4;
}
.hud-level {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}
.board-wrap {
  position: absolute;
  /* 상단바(Level/기어)와 보드 사이에 여유 간격 */
  top: calc(80px + env(safe-area-inset-top, 0px));
  left: 2px;
  right: 2px;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  /* 보드 vertical_bias 0.3 근사: 살짝 위로 */
  padding-bottom: 5vh;
}
.board-stage {
  position: relative;
  display: inline-block;
  line-height: 0;
}
#board {
  touch-action: none;
  display: block;
}
/* 황금빛 글로우 (클리어 축하) */
.board-glow {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: #ffd700;
  opacity: 0;
  pointer-events: none;
}
.board-glow.show {
  animation: jm-glow 700ms ease-out;
}
@keyframes jm-glow {
  0% {
    opacity: 0;
  }
  40% {
    opacity: 0.45;
  }
  100% {
    opacity: 0;
  }
}
/* 보드 펄스 (클리어 축하: 1.0 → 1.05 → 1.0) */
.board-celebrate {
  animation: jm-pulse 600ms ease-in-out;
}
@keyframes jm-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

/* ── 튜토리얼 오버레이 ─────────────────── */
.tutorial-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.tutorial-overlay.active {
  display: flex;
}
.tutorial-inner {
  text-align: center;
  padding: 40px;
}
.tut-icon {
  font-size: 64px;
  line-height: 1;
}
.tut-text {
  margin-top: 24px;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
}
.tut-continue {
  margin-top: 32px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.67);
}
.tut-dots {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: center;
}
.tut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
}
.tut-dot.active {
  background: #fff;
}

/* ── 다이얼로그 (완료 / 설정) ──────────── */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 30;
}
.modal.active {
  display: flex;
}
.dialog-card {
  background: var(--surface);
  color: #222;
  border-radius: 28px;
  padding: 32px 28px;
  width: 320px;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.dialog-left {
  text-align: left;
}
.dialog-emoji {
  font-size: 48px;
  line-height: 1;
}
.dialog-title {
  margin: 12px 0 0;
  font-size: 24px;
  font-weight: 700;
  color: #222;
}
.dialog-msg {
  margin: 8px 0 24px;
  font-size: 15px;
  color: #666;
}
.dialog-h3 {
  margin: 0 0 20px;
  font-size: 20px;
  font-weight: 700;
  color: #222;
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 16px;
  color: #222;
}

/* Material3 스위치 (안드로이드 switch_*_color 그대로) */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(0, 0, 0, 0.27); /* OFF track #44000000 */
  cursor: pointer;
  outline: none;
  transition: background 0.2s ease;
}
.switch::before {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #bdbdbd; /* OFF thumb */
  transition: transform 0.2s ease, background 0.2s ease;
}
.switch:checked {
  background: rgba(91, 123, 165, 0.6); /* ON track #995B7BA5 */
}
.switch:checked::before {
  transform: translateX(18px);
  background: #5b7ba5; /* ON thumb dialog_primary */
}

/* 다이얼로그 하단 액션 영역 + 텍스트 버튼 (Material 다이얼로그 버튼) */
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}
.btn-dialog {
  background: transparent;
  border: none;
  cursor: pointer;
  color: #5b7ba5; /* dialog_primary */
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 8px;
}
.btn-dialog:active {
  background: rgba(91, 123, 165, 0.12);
}
