/* 사과게임 — 디자인 v2 (apple.css 위에 덮어씀, 솔로+멀티 공용) 과수원 저녁놀 */
body { background: radial-gradient(1100px 560px at 10% -12%, rgba(220,38,38,.18), transparent 60%), radial-gradient(1000px 520px at 95% 0%, rgba(245,158,11,.12), transparent 60%), radial-gradient(900px 500px at 50% 115%, rgba(101,163,13,.12), transparent 60%), #0e0806; }

/* 떠다니는 잎사귀 (배경 장식) */
.ap-app { position: relative; }
.ap-app::before, .ap-app::after { content: "🍃"; position: fixed; top: -40px; font-size: 22px; opacity: .22; pointer-events: none; z-index: 0; animation: apv2-leaf 14s linear infinite; }
.ap-app::before { left: 12%; }
.ap-app::after { content: "🍂"; left: 78%; animation-duration: 18s; animation-delay: -7s; }
@keyframes apv2-leaf { 0% { transform: translate3d(0,-40px,0) rotate(0); } 100% { transform: translate3d(60px,110vh,0) rotate(540deg); } }
.ap-app > * { position: relative; z-index: 1; }

/* 카드 공통 */
.ap-setup, .ap-lobby, .ap-end-card, .ap-hud, .ap-lb-panel, .ap-end-mini-lb, .ap-info-card, .ap-leaderboard, .ap-top-mini {
  background: linear-gradient(160deg, rgba(42,31,24,.94), rgba(22,15,12,.97));
  border: 1px solid rgba(255,255,255,.09);
  box-shadow: 0 14px 38px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.06);
}

/* ===== Setup ===== */
.ap-setup { position: relative; overflow: hidden; }
.ap-setup::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: linear-gradient(90deg, #7f1d1d, #ef4444, #f59e0b, #65a30d); }
.ap-setup::after { content: ""; position: absolute; width: 260px; height: 260px; left: -100px; bottom: -110px; border-radius: 50%; background: #dc2626; filter: blur(80px); opacity: .22; pointer-events: none; }
.ap-setup > * { position: relative; z-index: 1; }
.ap-setup-emoji { display: inline-block; animation: apv2-bounce 2.2s ease-in-out infinite; filter: drop-shadow(0 8px 14px rgba(220,38,38,.45)); }
@keyframes apv2-bounce { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-10px) rotate(6deg); } }
.ap-setup-title { background: linear-gradient(90deg, #fca5a5, #ef4444 50%, #fbbf24); -webkit-background-clip: text; background-clip: text; color: transparent; font-size: 36px; }
.ap-setup-btn { transition: transform .15s cubic-bezier(.2,1.5,.4,1), box-shadow .2s, filter .2s; }
.ap-setup-btn:hover:not(:disabled) { transform: translateY(-3px); filter: brightness(1.08); }
.ap-setup-btn:not(.ap-setup-btn-secondary) { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 10px 26px rgba(220,38,38,.42); }
.ap-setup-input { transition: border-color .2s, box-shadow .2s; }
.ap-setup-input:focus { outline: none; border-color: #ef4444; box-shadow: 0 0 0 4px rgba(239,68,68,.22); }
.ap-setup-preview { animation: apv2-float 3s ease-in-out infinite; }
@keyframes apv2-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* ===== 로비 ===== */
.ap-lobby-invite, .ap-lobby-options { background: rgba(0,0,0,.28); border-radius: 14px; }
.ap-lobby-invite-code { text-shadow: 0 0 18px rgba(239,68,68,.55); letter-spacing: 5px; }
.ap-lobby-roster li, .ap-lobby-roster > * { animation: apv2-pop .35s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes apv2-pop { from { opacity: 0; transform: scale(.85) translateY(6px); } to { opacity: 1; transform: none; } }

/* ===== HUD ===== */
.ap-hud { border-radius: 18px; position: relative; overflow: hidden; }
.ap-hud::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, #ef4444, #f59e0b, #65a30d); opacity: .8; }
.ap-hud-block { padding: 2px 6px; }
.ap-hud-score-value { text-shadow: 0 0 16px rgba(245,158,11,.55); font-variant-numeric: tabular-nums; }
.ap-hud-time-value { font-variant-numeric: tabular-nums; }
.ap-icon-btn { border-radius: 12px; transition: transform .12s, background .2s, border-color .2s; }
.ap-icon-btn:hover { transform: translateY(-2px); border-color: rgba(239,68,68,.6); }
.ap-icon-btn:active { transform: scale(.92); }

/* ===== 보드: 나무 상자 ===== */
.ap-board-wrap { border-radius: 20px; background: linear-gradient(160deg, #3a2a1e, #22170f); border: 2px solid #6b4a30; box-shadow: 0 0 0 4px rgba(0,0,0,.35), 0 18px 44px rgba(0,0,0,.6), inset 0 2px 0 rgba(255,255,255,.08), inset 0 -8px 20px rgba(0,0,0,.35); }
.ap-canvas { border-radius: 14px; box-shadow: inset 0 4px 14px rgba(0,0,0,.55); }
.ap-drag-sum { backdrop-filter: blur(6px); }
.ap-float-num { text-shadow: 0 2px 10px rgba(0,0,0,.6); }
.ap-combo-cutin.ap-show { text-shadow: 0 0 24px rgba(245,158,11,.8); }
.ap-credit { opacity: .55; }

/* ===== 랭킹 패널 ===== */
.ap-lb-title, .ap-end-mini-lb-title, .ap-leaderboard-title { font-weight: 900; }
.ap-lb-tab { transition: background .2s, transform .1s; border-radius: 12px; }
.ap-lb-tab.active { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 4px 12px rgba(220,38,38,.4); }
.ap-lb-list li { transition: background .2s; border-radius: 10px; animation: apv2-slide .4s both; }
.ap-lb-list li:nth-child(2) { animation-delay: .05s; } .ap-lb-list li:nth-child(3) { animation-delay: .1s; } .ap-lb-list li:nth-child(n+4) { animation-delay: .15s; }
@keyframes apv2-slide { from { opacity: 0; transform: translateX(-12px); } to { opacity: 1; transform: none; } }
.ap-lb-rank-1 { color: #facc15; text-shadow: 0 0 12px rgba(250,204,21,.6); }
.ap-lb-rank-2 { color: #e5e7eb; }
.ap-lb-rank-3 { color: #fdba74; }

/* ===== 게임 종료 ===== */
.ap-end-card { position: relative; overflow: hidden; animation: apv2-endin .6s cubic-bezier(.2,1.2,.4,1) both; }
@keyframes apv2-endin { from { opacity: 0; transform: translateY(18px) scale(.95); } to { opacity: 1; transform: none; } }
.ap-end-card::before { content: ""; position: absolute; left: 50%; top: 80px; width: 280px; height: 280px; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(circle, rgba(245,158,11,.22), transparent 65%); pointer-events: none; }
.ap-end-card > * { position: relative; }
.ap-end-grade { animation: apv2-grade .8s .2s cubic-bezier(.2,1.8,.4,1) both; text-shadow: 0 6px 28px currentColor; }
@keyframes apv2-grade { from { opacity: 0; transform: scale(.2) rotate(-20deg); } to { opacity: 1; transform: none; } }
.ap-end-score { font-variant-numeric: tabular-nums; text-shadow: 0 0 22px rgba(245,158,11,.55); }
.ap-end-stats { background: rgba(0,0,0,.3); border-radius: 16px; }
.ap-end-login-cta { border-radius: 18px; }
.ap-btn-primary { background: linear-gradient(135deg, #ef4444, #b91c1c); box-shadow: 0 10px 26px rgba(220,38,38,.4); transition: transform .15s cubic-bezier(.2,1.5,.4,1), filter .2s; }
.ap-btn-primary:hover { transform: translateY(-3px); filter: brightness(1.08); }
.ap-btn-secondary, .ap-btn-ghost { transition: transform .15s, border-color .2s; }
.ap-btn-secondary:hover, .ap-btn-ghost:hover { transform: translateY(-2px); }

/* 멀티 최종 순위 */
.ap-final-ranking li { background: linear-gradient(160deg, rgba(42,31,24,.92), rgba(22,15,12,.96)); border: 1px solid rgba(255,255,255,.09); border-radius: 16px; animation: apv2-slide .5s both; }
.ap-final-ranking li:nth-child(2) { animation-delay: .1s; } .ap-final-ranking li:nth-child(3) { animation-delay: .2s; } .ap-final-ranking li:nth-child(n+4) { animation-delay: .3s; }
.ap-final-ranking li.ap-final-rank-1 { background: linear-gradient(135deg, rgba(250,204,21,.22), rgba(251,146,60,.1) 60%, rgba(22,15,12,.96)); border-color: rgba(250,204,21,.6); box-shadow: 0 0 0 1px rgba(250,204,21,.3), 0 14px 38px rgba(250,204,21,.2); }
.ap-final-avatar { display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px rgba(255,255,255,.14); }
.ap-top-mini { border-radius: 14px; }
.ap-toast { backdrop-filter: blur(8px); }

@media (prefers-reduced-motion: reduce) {
  .ap-app::before, .ap-app::after { display: none; }
  .ap-setup-emoji, .ap-setup-preview, .ap-end-card, .ap-end-grade, .ap-lb-list li, .ap-final-ranking li, .ap-lobby-roster li, .ap-lobby-roster > * { animation: none !important; }
}

/* 모바일 상단 헤더가 390px에서 가로 스크롤을 만드는 기존 문제 완화 */
@media (max-width: 480px) {
  .topbar { padding: 0 8px; }
  .topbar .right { gap: 2px; }
  .topbar .nav-link { padding: 5px 5px; font-size: 12px; }
  .topbar .nav-login { padding: 5px 9px; }
}

/* ===== 2026-11-01 폰 세로 화면: 판을 크게, 위쪽 칸은 납작하게 ===== */
/* 숨겨진 알림창이 폰 화면 아래에 살짝 보이던 것 막기 */
.ap-toast:not(.show) { opacity: 0; visibility: hidden; }
@media (max-width: 640px) and (orientation: portrait) {
  .ap-hud { display: flex !important; align-items: center; justify-content: space-between; gap: 4px; padding: 6px 10px !important; }
  .ap-hud-block { flex: 1 1 0; padding: 0 2px; }
  .ap-hud-label { font-size: 10px; margin-bottom: 0; letter-spacing: 0; }
  .ap-hud-time-value, .ap-hud-score-value, .ap-hud-combo-value { font-size: 21px; }
  .ap-hud-controls { flex: 0 0 auto; flex-direction: row !important; gap: 4px; }
  .ap-hud-controls .ap-icon-btn { width: 30px; height: 30px; font-size: 13px; }
  .ap-board-wrap { padding: 8px !important; }
  /* 멀티: 위쪽 1·2등 미니보드 납작하게 */
  .ap-top-mini-boards { gap: 6px !important; margin-bottom: 6px; }
  .ap-top-mini { padding: 4px 8px !important; }
  .ap-top-mini-head { gap: 4px; font-size: 12px; }
  .ap-top-mini-avatar { width: 18px !important; height: 18px !important; font-size: 10px; }
  .ap-top-mini-canvas { max-height: 38px !important; }
}
