/* Arrow Out — 안드로이드 res/values/colors.xml 매핑 */
:root {
  --background: #ffffff;
  --surface: #f4f5fa;
  --ink: #3b3e66;
  --periwinkle: #6c7ae0;
  --periwinkle-dark: #5563c9;
  --text-secondary: #9aa0c0;
  --heart: #ff4d5e;
  --heart-empty: #d9dce8;
  --star: #ffc04a;
  --star-empty: #e2e5f0;
  --divider: #e7eaf4;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #eef0fb;
  color: var(--ink);
  font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
  overscroll-behavior: none;
  user-select: 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: 260px;
  max-width: 82vw;
  height: 54px;
  margin: 0 auto;
  background: var(--periwinkle);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
  border-radius: 27px;
  box-shadow: 0 6px 16px rgba(108, 122, 224, 0.4);
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn-primary:active {
  transform: scale(0.97);
  filter: brightness(0.96);
}
.btn-text {
  display: block;
  margin: 8px auto 0;
  background: transparent;
  color: var(--periwinkle-dark);
  font-size: 15px;
  font-weight: 600;
  padding: 8px 16px;
}

/* 원형 버튼 (설정 / 경로보기) — 원본 bg_circle(#EBEDFB) */
.circle-btn {
  position: absolute;
  border: none;
  border-radius: 50%;
  background: #ebedfb;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 8px rgba(59, 62, 102, 0.14);
  z-index: 5;
}
.settings-btn {
  width: 46px;
  height: 46px;
  top: calc(8px + env(safe-area-inset-top, 0px));
  right: 14px;
}
.grid-btn {
  width: 56px;
  height: 56px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}
.grid-btn.active {
  background: var(--periwinkle);
  color: #fff;
  box-shadow: 0 4px 12px rgba(108, 122, 224, 0.45);
}

/* ── 타이틀 (원본 activity_home) ───────── */
#screen-title {
  /* bg_home_gradient: 위 순백 → 아래 라벤더 */
  background: linear-gradient(180deg, #ffffff 0%, #f6f7fe 50%, #e9ecfb 100%);
}
.title-maze {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(108, 122, 224, 0.08) 1.4px, transparent 1.5px);
  background-size: 30px 30px;
  pointer-events: none;
}
.title-center {
  position: absolute;
  left: 0;
  right: 0;
  top: 40%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.emblem {
  margin-bottom: 16px;
  line-height: 0;
}
.wordmark {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 52px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
}
.wm-ink {
  color: var(--ink);
}
.wm-peri {
  color: var(--periwinkle);
}
.tagline {
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
  padding: 0 24px;
}
.btn-play {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 72px);
  max-width: 360px;
  bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--periwinkle);
  color: #fff;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: none;
  border-radius: 32px;
  box-shadow: 0 8px 20px rgba(108, 122, 224, 0.4);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.btn-play:active {
  transform: translateX(-50%) scale(0.98);
  filter: brightness(0.96);
}
.play-ico {
  flex: none;
}

/* ── 게임 (원본 activity_main) ─────────── */
#screen-game {
  background: var(--background);
}
.hud-level {
  position: absolute;
  left: 20px;
  top: calc(8px + env(safe-area-inset-top, 0px));
  height: 46px;
  display: flex;
  align-items: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  z-index: 4;
}
.hearts {
  position: absolute;
  top: calc(58px + env(safe-area-inset-top, 0px));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  font-size: 26px;
  line-height: 1;
  z-index: 3;
}
.heart {
  color: var(--heart);
  transition: color 0.2s ease, transform 0.2s ease;
}
.heart.empty {
  color: var(--heart-empty);
}
.progress-track {
  position: absolute;
  top: calc(100px + env(safe-area-inset-top, 0px));
  left: 16px;
  right: 16px;
  height: 4px;
  background: var(--heart-empty);
  border-radius: 2px;
  overflow: hidden;
  z-index: 3;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--periwinkle);
  border-radius: 2px;
  transition: width 0.25s ease;
}

.board-wrap {
  position: absolute;
  top: calc(116px + env(safe-area-inset-top, 0px));
  left: 4px;
  right: 4px;
  bottom: calc(84px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  justify-content: center;
}
.board-stage {
  position: relative;
  width: 100%;
  height: 100%;
  background: transparent;
  overflow: hidden;
  line-height: 0;
}
#board {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.board-glow {
  position: absolute;
  inset: 0;
  border-radius: 14px;
  background: #ffd700;
  opacity: 0;
  pointer-events: none;
}
.board-glow.show {
  animation: ao-glow 700ms ease-out;
}
@keyframes ao-glow {
  0% {
    opacity: 0;
  }
  40% {
    opacity: 0.4;
  }
  100% {
    opacity: 0;
  }
}
.board-celebrate {
  animation: ao-pulse 600ms ease-in-out;
}
@keyframes ao-pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

/* ── 튜토리얼 오버레이 ─────────────────── */
.tutorial-overlay {
  position: absolute;
  inset: 0;
  background: rgba(40, 43, 74, 0.86);
  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: 56px;
  line-height: 1;
}
.tut-text {
  margin-top: 22px;
  font-size: 18px;
  font-weight: 600;
  color: #fff;
  line-height: 1.35;
}
.tut-continue {
  margin-top: 28px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

/* ── 다이얼로그 (승리 / 실패 / 설정) ───── */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(59, 62, 102, 0.5);
  z-index: 30;
}
.modal.active {
  display: flex;
}
.dialog-card {
  background: #fff;
  color: var(--ink);
  border-radius: 26px;
  padding: 30px 26px;
  width: 320px;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 16px 48px rgba(59, 62, 102, 0.4);
  animation: ao-popin 240ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes ao-popin {
  0% {
    transform: scale(0.84);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.dialog-left {
  text-align: left;
}
.dialog-emoji {
  font-size: 46px;
  line-height: 1;
}
.dialog-title {
  margin: 10px 0 0;
  font-size: 24px;
  font-weight: 800;
  color: var(--ink);
}
.dialog-msg {
  margin: 8px 0 22px;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.stars {
  margin: 12px 0 22px;
  font-size: 30px;
  letter-spacing: 6px;
}
.stars .star {
  color: var(--star-empty);
}
.stars .star.on {
  color: var(--star);
  text-shadow: 0 2px 8px rgba(255, 192, 74, 0.5);
}

.dialog-h3 {
  margin: 0 0 18px;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 0;
  font-size: 16px;
  color: var(--ink);
  border-bottom: 1px solid var(--divider);
}
.btn-reset {
  margin-top: 18px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--heart);
  background: transparent;
  color: var(--heart);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  border-radius: 12px;
  cursor: pointer;
}

/* Material3 스위치 */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: rgba(59, 62, 102, 0.22);
  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: #fff;
  transition: transform 0.2s ease;
}
.switch:checked {
  background: rgba(108, 122, 224, 0.55);
}
.switch:checked::before {
  transform: translateX(18px);
  background: var(--periwinkle);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}
.btn-dialog {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--periwinkle);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 12px;
  border-radius: 8px;
}
.btn-dialog:active {
  background: rgba(108, 122, 224, 0.12);
}
