:root {
  --bg-gradient-start: #0b132b;
  --bg-gradient-end: #1c2541;
  --accent-cyan: #00f5d4;
  --accent-pink: #f72585;
  --accent-yellow: #fee440;
  --accent-blue: #4cc9f0;
  --glass-bg: rgba(15, 23, 42, 0.75);
  --glass-border: rgba(255, 255, 255, 0.15);
  --text-main: #ffffff;
  --text-muted: #94a3b8;
  --font-family: 'Outfit', 'Noto Sans KR', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #050b14;
  font-family: var(--font-family);
  color: var(--text-main);
  display: flex;
  justify-content: center;
  align-items: center;
}

#app-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: 500px;
  max-height: 900px;
  background: linear-gradient(180deg, var(--bg-gradient-start), var(--bg-gradient-end));
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7), 0 0 30px rgba(76, 201, 240, 0.2);
  border-radius: 16px;
}

@media (min-width: 501px) and (min-height: 901px) {
  #app-container {
    height: 90vh;
    border: 1px solid var(--glass-border);
  }
}

canvas#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

/* 상단바 */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  pointer-events: auto;
}

.score-container {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  padding: 8px 18px;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.score-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
}

.score-value {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  line-height: 1.1;
  text-shadow: 0 0 10px rgba(0, 245, 212, 0.5);
}

.stat-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.combo-badge {
  background: linear-gradient(135deg, var(--accent-pink), #7209b7);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  animation: pulseCombo 0.6s infinite alternate;
  box-shadow: 0 0 12px rgba(247, 37, 133, 0.6);
}

@keyframes pulseCombo {
  from { transform: scale(1); }
  to { transform: scale(1.08); }
}

.shield-badge {
  background: linear-gradient(135deg, #4361ee, var(--accent-blue));
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 0 10px rgba(76, 201, 240, 0.5);
}

.controls-top {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.icon-btn:hover {
  transform: scale(1.1);
  background: rgba(255, 255, 255, 0.25);
  border-color: var(--accent-cyan);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.muted {
  opacity: 0.5;
  filter: grayscale(80%);
}

/* 오버레이 화면 (Start, GameOver, Pause) */
.screen-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 11, 20, 0.84);
  backdrop-filter: blur(16px);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
  pointer-events: auto;
  overflow-y: auto;
}

.screen-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: rgba(20, 30, 55, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: translateY(20px);
  transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.screen-overlay.active .modal-card {
  transform: translateY(0);
}

.logo-area {
  margin-bottom: 0;
}

.logo-plane {
  font-size: 46px;
  display: inline-block;
  animation: floatPlane 3s ease-in-out infinite;
  filter: drop-shadow(0 10px 15px rgba(0, 245, 212, 0.4));
}

@keyframes floatPlane {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-10px) rotate(6deg); }
}

.game-title {
  font-size: 34px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -1px;
  color: #fff;
}

.game-title .highlight {
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-blue));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* 미세 조절 세팅 패널 */
.fine-control-panel {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 16px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 1px;
  display: block;
  margin-bottom: 6px;
  text-align: left;
}

.mode-buttons {
  display: flex;
  gap: 6px;
}

.btn-mode {
  flex: 1;
  padding: 8px 6px;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-mode.active {
  background: linear-gradient(135deg, var(--accent-cyan), #00b4d8);
  color: #03071e;
  border-color: var(--accent-cyan);
  box-shadow: 0 4px 12px rgba(0, 245, 212, 0.3);
}

.sensitivity-slider-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
}

.sens-val {
  color: var(--accent-cyan);
}

.custom-range {
  width: 100%;
  height: 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
  cursor: pointer;
}

.custom-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0, 245, 212, 0.8);
}

/* 난이도 버튼 */
.diff-buttons {
  display: flex;
  gap: 6px;
}

.btn-diff {
  flex: 1;
  padding: 8px 0;
  border-radius: 10px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-diff.active {
  background: linear-gradient(135deg, var(--accent-blue), #3a0ca3);
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 4px 12px rgba(76, 201, 240, 0.4);
}

.high-score-display {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent-yellow);
  background: rgba(254, 228, 64, 0.1);
  padding: 6px 14px;
  border-radius: 16px;
  border: 1px dashed rgba(254, 228, 64, 0.3);
}

.btn-primary {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: none;
  background: linear-gradient(135deg, var(--accent-cyan), #00b4d8);
  color: #03071e;
  font-size: 17px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(0, 245, 212, 0.4);
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 12px 28px rgba(0, 245, 212, 0.6);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.btn-secondary {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.18);
}

.guide-text {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  text-align: left;
  background: rgba(0, 0, 0, 0.2);
  padding: 8px 12px;
  border-radius: 10px;
}

/* 게임오버 리포트 카드 */
.gameover-title {
  font-size: 36px;
  font-weight: 900;
  color: var(--accent-pink);
  text-shadow: 0 0 15px rgba(247, 37, 133, 0.6);
}

.gameover-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: -10px;
}

.result-board {
  background: rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.res-label {
  color: var(--text-muted);
  font-weight: 600;
}

.res-val {
  font-weight: 900;
  font-size: 16px;
}

.highlight-score {
  font-size: 22px;
  color: var(--accent-cyan);
  text-shadow: 0 0 8px rgba(0, 245, 212, 0.5);
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hidden {
  display: none !important;
}
