/* ═══════════════════════════════════════════════════════════════
   SNAKE+ 게임 스타일 (귀엽고 산뜻한 한국 감성)
   ═══════════════════════════════════════════════════════════════ */

/* ─── 게임 페이지 레이아웃 ─────────────────────────────────────── */
.game-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 14px 40px;
  position: relative;
  z-index: 1;
}

/* ─── 게임 헤더 ─────────────────────────────────────────────────── */
.game-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 0 14px;
  margin-bottom: 16px;
  border-bottom: 2px solid rgba(255,122,179,0.12);
}

.back-btn {
  font-family: var(--font);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  background: rgba(255,122,179,0.10);
  border: 1.5px solid rgba(255,122,179,0.25);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.18s;
  display: flex;
  align-items: center;
  gap: 5px;
}
.back-btn:hover {
  background: rgba(255,122,179,0.18);
  transform: translateX(-2px);
}

.game-title {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  flex: 1;
  line-height: 1.2;
}

.game-title span {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* ─── 점수 표시 ─────────────────────────────────────────────────── */
.score-display {
  display: flex;
  gap: 12px;
  align-items: center;
}

.score-item {
  text-align: center;
  background: rgba(255,255,255,0.8);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  box-shadow: var(--shadow-sm);
  min-width: 70px;
}
.score-item .label {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}
.score-item .value {
  font-size: 2rem;
  font-weight: 900;
  color: var(--text);
  line-height: 1;
}
.score-item .value.best { color: var(--primary); }

/* ─── 메인 게임 영역 ─────────────────────────────────────────────── */
.game-main {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─── 캔버스 컨테이너 ───────────────────────────────────────────── */
.canvas-wrapper {
  position: relative;
  flex-shrink: 0;
}

#game-canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  border: 3px solid rgba(255,255,255,0.9);
}

/* 게임 오버레이 */
.canvas-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  border-radius: var(--radius-md);
  animation: fadeInScale 0.25s ease;
}

.canvas-overlay.hidden { display: none; }

.overlay-title {
  font-size: clamp(2.4rem, 5vw, 3.6rem);
  font-weight: 900;
  text-align: center;
  line-height: 1.3;
  background: linear-gradient(135deg, var(--primary), var(--coral));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: float 3s ease-in-out infinite;
}

.overlay-subtitle {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.8;
}

.overlay-subtitle strong, .overlay-subtitle span {
  color: var(--primary);
  font-weight: 800;
  -webkit-text-fill-color: var(--primary);
}

.overlay-score {
  font-size: 4rem;
  font-weight: 900;
  color: var(--accent-dark);
  line-height: 1;
}

/* ─── 사이드 패널 ───────────────────────────────────────────────── */
.side-panel {
  width: 190px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}

@media (max-width: 650px) {
  .side-panel { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .side-panel > * { flex: 1; min-width: 140px; }
}

/* 패널 섹션 */
.panel-section {
  background: rgba(255,255,255,0.85);
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(4px);
}

.panel-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 7px;
  border-bottom: 1.5px solid rgba(255,122,179,0.15);
}

/* ─── 이펙트 표시 ───────────────────────────────────────────────── */
.effect-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 60px;
}

.effect-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 6px 10px;
  background: rgba(255,255,255,0.6);
  border-radius: 10px;
  border-left: 3px solid;
  animation: fadeInUp 0.2s ease;
}

.effect-item.speed   { border-color: var(--accent);   color: #B07000; background: rgba(255,217,61,0.12); }
.effect-item.slow    { border-color: var(--secondary); color: #1A7FAA; background: rgba(94,200,240,0.12); }
.effect-item.double  { border-color: var(--primary);   color: var(--primary-dark); background: rgba(255,122,179,0.12); }
.effect-item.ghost   { border-color: var(--purple);    color: #7755CC; background: rgba(177,151,252,0.12); }

.effect-name { flex: 1; }
.effect-timer {
  font-size: 1.2rem;
  font-weight: 900;
  min-width: 28px;
  text-align: right;
}

.effect-bar {
  width: 100%;
  height: 4px;
  background: rgba(0,0,0,0.07);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.effect-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.1s linear;
}

.effect-item.speed  .effect-bar-fill { background: var(--accent); }
.effect-item.slow   .effect-bar-fill { background: var(--secondary); }
.effect-item.double .effect-bar-fill { background: var(--primary); }
.effect-item.ghost  .effect-bar-fill { background: var(--purple); }

.no-effects {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-light);
  text-align: center;
  padding: 10px 0;
}

/* ─── 아이템 가이드 ─────────────────────────────────────────────── */
.item-guide-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.item-guide-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 3px 0;
}

.item-guide-dot {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 4px;
}

.item-guide-name {
  flex: 1;
  color: var(--text);
  font-weight: 700;
}

.item-guide-effect {
  color: var(--primary);
  font-weight: 800;
  font-size: 1rem;
}

/* ─── 컨트롤 패널 ───────────────────────────────────────────────── */
.control-btn {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 700;
  padding: 9px 12px;
  background: rgba(255,255,255,0.6);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  cursor: pointer;
  width: 100%;
  transition: all 0.15s;
  text-align: left;
}
.control-btn:hover {
  background: rgba(255,122,179,0.08);
  border-color: rgba(255,122,179,0.25);
  color: var(--primary-dark);
}
.control-btn + .control-btn { margin-top: 6px; }

/* ─── 레벨 표시 ─────────────────────────────────────────────────── */
.level-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.level-val {
  font-size: 2.4rem;
  font-weight: 900;
  color: var(--primary);
  line-height: 1;
}

.level-bar-wrap {
  flex: 1;
}

.level-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.level-bar {
  height: 8px;
  background: rgba(0,0,0,0.07);
  border-radius: 4px;
  overflow: hidden;
}

.level-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--purple));
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ─── 모바일 D-PAD ──────────────────────────────────────────────── */
.dpad {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 20px auto 0;
  user-select: none;
}

@media (max-width: 768px), (pointer: coarse) {
  .dpad { display: flex; }
}

.dpad-row {
  display: flex;
  gap: 6px;
}

.dpad-btn {
  width: 58px;
  height: 58px;
  font-size: 1.8rem;
  background: rgba(255,255,255,0.85);
  border: 2px solid rgba(255,122,179,0.2);
  border-radius: 16px;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.12s;
  box-shadow: 0 3px 0 rgba(255,122,179,0.3), var(--shadow-sm);
  font-weight: 900;
}

.dpad-btn:active {
  background: var(--primary);
  color: white;
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(255,122,179,0.3);
}

.dpad-spacer { width: 58px; height: 58px; }

/* ─── 랭킹 테이블 ───────────────────────────────────────────────── */
.ranking-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 1.2rem;
  margin: 14px 0;
}

.ranking-table th {
  color: var(--text-muted);
  font-weight: 700;
  padding: 6px 10px;
  text-align: left;
  font-size: 1.1rem;
  letter-spacing: 0.3px;
  border-bottom: 2px solid var(--border);
}

.ranking-table td {
  padding: 10px 10px;
  background: rgba(255,255,255,0.6);
  font-weight: 700;
  color: var(--text);
}

.ranking-table td:first-child {
  border-radius: 10px 0 0 10px;
}
.ranking-table td:last-child {
  border-radius: 0 10px 10px 0;
}

.ranking-table tr:nth-child(1) td { background: rgba(255,217,61,0.15); color: #B07000; }
.ranking-table tr:nth-child(2) td { background: rgba(200,210,230,0.20); color: #5566AA; }
.ranking-table tr:nth-child(3) td { background: rgba(200,140,80,0.15);  color: #8B5500; }

.rank-medal { font-size: 1.4rem; }

.name-input {
  font-family: var(--font);
  font-size: 1.4rem;
  font-weight: 700;
  background: rgba(255,122,179,0.06);
  border: 2px solid rgba(255,122,179,0.3);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px 16px;
  width: 100%;
  text-align: center;
  letter-spacing: 1px;
  outline: none;
  margin: 10px 0;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255,122,179,0.15);
}
.name-input::placeholder { color: var(--text-light); }

/* ─── 게임 오버 점수 상세 ───────────────────────────────────────── */
.score-breakdown {
  background: rgba(255,255,255,0.7);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  width: 100%;
  margin: 10px 0;
}

.score-row {
  display: flex;
  justify-content: space-between;
  font-size: 1.2rem;
  font-weight: 600;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

.score-row:last-child { border-bottom: none; }
.score-row .sval { color: var(--text); font-weight: 800; }
.score-row.total {
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 900;
  margin-top: 4px;
}
.score-row.total .sval { color: var(--primary); }

/* ─── 랭킹 배지 ─────────────────────────────────────────────────── */
.rank-badge { font-size: 3rem; margin: 6px 0; }

.rank-text { font-size: 1.4rem; font-weight: 800; }
.rank-text.top3   { color: var(--accent-dark); }
.rank-text.normal { color: var(--text-muted); }

/* ─── 파티클 캔버스 ─────────────────────────────────────────────── */
#particle-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
