/* ── 크레이지 아케이드 (Crazy Arcade BnB) 스타일시트 ── */
:root {
  --bg-gradient: linear-gradient(135deg, #0d47a1 0%, #1976d2 50%, #42a5f5 100%);
  --panel-bg: rgba(255, 255, 255, 0.94);
  --panel-dark: rgba(13, 27, 42, 0.85);
  --border-color: rgba(255, 255, 255, 0.25);
  --accent-blue: #0288d1;
  --accent-cyan: #00e5ff;
  --accent-gold: #ffb300;
  --accent-red: #f44336;
  --text-dark: #1e293b;
  --text-light: #f8fafc;
  --shadow-box: 0 10px 25px rgba(0, 0, 0, 0.25);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--bg-gradient);
  color: var(--text-dark);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
  padding-bottom: 24px;
}

/* ── 상단 탑바 ── */
.topbar {
  width: 100%;
  max-width: 1060px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(10, 25, 47, 0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  z-index: 100;
}

.top-left, .top-right, .top-center {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  transition: background 0.18s;
}
.back-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 99px;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s;
}
.user-badge:hover {
  transform: scale(1.04);
}

.lucci-display {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 14px;
  background: rgba(255, 215, 0, 0.2);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 99px;
  color: #fff9c4;
  font-size: 13.5px;
  font-weight: 800;
}
.lucci-display small {
  font-weight: 500;
  color: #fff;
  opacity: 0.8;
}

.icon-nav-btn {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}
.icon-nav-btn:hover {
  background: rgba(255, 255, 255, 0.24);
}

/* ── 앱 컨테이너 ── */
#app {
  width: 100%;
  max-width: 1060px;
  flex: 1;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.screen[hidden] {
  display: none !important;
}

/* ── 로비 화면 ── */
.lobby-header {
  text-align: center;
  margin-bottom: 20px;
  color: #fff;
}
.lobby-title-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}
.bubble-icon {
  font-size: 32px;
  animation: float 2.5s ease-in-out infinite alternate;
}
@keyframes float {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}
.lobby-header h1 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.5px;
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.sub-badge {
  font-size: 11px;
  font-weight: 800;
  background: var(--accent-cyan);
  color: #004d40;
  padding: 3px 8px;
  border-radius: 99px;
}
.lobby-subtitle {
  font-size: 14px;
  color: #e0f2fe;
  opacity: 0.9;
}

.lobby-layout {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 20px;
}
@media (max-width: 860px) {
  .lobby-layout {
    grid-template-columns: 1fr;
  }
}

.lobby-panel {
  background: var(--panel-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-box);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel-section-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 6px;
  margin-bottom: 8px;
}
.panel-section-title small {
  font-size: 11px;
  color: #64748b;
  font-weight: 500;
}

/* 캐릭터 목록 그리드 */
.char-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding-right: 4px;
}
.char-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 8px 4px;
  text-align: center;
  cursor: pointer;
  transition: all 0.16s ease;
  position: relative;
}
.char-card:hover {
  transform: translateY(-2px);
  border-color: #60a5fa;
}
.char-card.selected {
  border-color: #0288d1;
  background: #e1f5fe;
  box-shadow: 0 4px 10px rgba(2, 136, 209, 0.25);
}
.char-card.locked {
  opacity: 0.65;
}
.char-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 4px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  overflow: hidden;
  position: relative;
}
.char-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
  transition: transform 0.16s ease;
  pointer-events: none;
}
.char-card:hover .char-thumb-img {
  transform: scale(1.12);
}
.char-name {
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  white-space: nowrap;
}
.lock-badge {
  font-size: 9px;
  background: #ff5722;
  color: #fff;
  border-radius: 4px;
  padding: 1px 4px;
  margin-top: 2px;
}

/* 캐릭터 스탯 상세 박스 */
.char-preview-box {
  background: #f1f5f9;
  border-radius: var(--radius-md);
  padding: 14px;
  border: 1px solid #cbd5e1;
}
.preview-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.preview-emoji {
  width: 62px;
  height: 62px;
  background: #fff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  padding: 4px;
  flex-shrink: 0;
}
.char-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  animation: charFloat 2.2s ease-in-out infinite alternate;
}
@keyframes charFloat {
  0% { transform: translateY(0); }
  100% { transform: translateY(-4px); }
}
.preview-header h3 {
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
}
.preview-header p {
  font-size: 12px;
  color: #64748b;
}

.stat-bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.stat-row {
  display: flex;
  align-items: center;
  font-size: 11.5px;
  gap: 8px;
}
.stat-label {
  width: 82px;
  font-weight: 700;
  color: #475569;
}
.stat-track {
  flex: 1;
  height: 8px;
  background: #e2e8f0;
  border-radius: 99px;
  overflow: hidden;
}
.stat-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.25s ease;
}
.stat-fill.blue { background: #0288d1; }
.stat-fill.cyan { background: #00bcd4; }
.stat-fill.amber { background: #ff9800; }
.stat-val {
  width: 42px;
  text-align: right;
  font-weight: 800;
  color: #1e293b;
}

/* ── 우측 패널 설정들 ── */
.setting-group {
  margin-bottom: 12px;
}
.setting-group.dual {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.setting-lbl {
  font-size: 12px;
  font-weight: 800;
  color: #475569;
  display: block;
  margin-bottom: 6px;
}

.mode-grid, .rule-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.mode-btn, .rule-btn {
  flex: 1;
  min-width: 85px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 700;
  color: #334155;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
}
.mode-btn.selected, .rule-btn.selected {
  background: #0288d1;
  border-color: #0277bd;
  color: #fff;
  box-shadow: 0 3px 8px rgba(2, 136, 209, 0.3);
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
@media (max-width: 600px) {
  .map-grid { grid-template-columns: repeat(2, 1fr); }
}
.map-card {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  display: flex;
  gap: 8px;
  align-items: center;
  transition: all 0.15s;
}
.map-card:hover {
  border-color: #0288d1;
}
.map-card.selected {
  border-color: #0288d1;
  background: #e0f2fe;
}
.map-badge {
  width: 14px;
  height: 28px;
  border-radius: 4px;
}
.map-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
}
.map-desc {
  font-size: 10px;
  color: #64748b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 110px;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.pill-btn {
  padding: 6px 10px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}
.pill-btn.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
}

/* 시작 버튼 */
.start-btn-wrap {
  margin-top: 8px;
}
.big-start-btn {
  width: 100%;
  padding: 16px;
  background: linear-gradient(135deg, #00c853 0%, #43a047 100%);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 200, 83, 0.4);
  transition: all 0.18s ease;
}
.big-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 200, 83, 0.55);
}
.big-start-btn:active {
  transform: translateY(1px);
}

/* ── 인게임 화면 ── */
#gameScreen {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.game-hud {
  width: 100%;
  max-width: 640px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.hud-left, .hud-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-stat-chip {
  font-size: 12.5px;
  font-weight: 800;
}
.hud-player-stats {
  display: flex;
  gap: 12px;
  font-size: 13px;
  color: #bae6fd;
}

.quick-slots {
  display: flex;
  gap: 5px;
}
.slot-btn {
  background: #1e293b;
  border: 1.5px solid #475569;
  color: #fff;
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 3px;
}
.slot-btn small {
  font-weight: 800;
  color: #fde047;
}
.slot-btn.pulse-alert {
  animation: pulse-border 0.6s infinite alternate;
}
@keyframes pulse-border {
  from { border-color: #ff1744; box-shadow: 0 0 8px #ff1744; }
  to { border-color: #ffd600; box-shadow: 0 0 14px #ffd600; }
}

.pause-btn {
  background: #334155;
  border: none;
  color: #fff;
  border-radius: 6px;
  width: 32px;
  height: 32px;
  font-size: 14px;
  cursor: pointer;
}

/* 캔버스 랩 */
.canvas-wrap {
  width: 100%;
  max-width: 640px;
  aspect-ratio: 15 / 13;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  border: 4px solid rgba(255, 255, 255, 0.2);
}
#gameCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ── 모바일 가상 컨트롤 ── */
.mobile-controls {
  display: none;
  width: 100%;
  max-width: 640px;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
}

@media (max-width: 820px) {
  .mobile-controls {
    display: flex;
  }
}

.virtual-dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.dpad-mid {
  display: flex;
  align-items: center;
}
.dpad-center {
  width: 44px;
  height: 44px;
}
.dpad-btn {
  width: 46px;
  height: 46px;
  background: rgba(15, 23, 42, 0.75);
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 12px;
  color: #fff;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
}
.dpad-btn:active {
  background: #0288d1;
}

.virtual-actions {
  display: flex;
  gap: 12px;
}
.action-btn.bomb-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0288d1, #00e5ff);
  border: 3px solid #fff;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 14px rgba(2, 136, 209, 0.5);
  touch-action: none;
}
.action-btn.bomb-btn small {
  font-size: 9px;
  font-weight: 800;
}
.action-btn.bomb-btn:active {
  transform: scale(0.94);
}

/* ── 모달 공통 ── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
}
.modal[hidden] {
  display: none !important;
}

.modal-dialog {
  background: #fff;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.4);
}
.modal-dialog.small {
  max-width: 420px;
}
.modal-dialog.guide-dialog {
  max-width: 680px;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header.center {
  justify-content: center;
}
.modal-header h2 {
  font-size: 19px;
  font-weight: 800;
  color: #0f172a;
}
.close-modal-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #94a3b8;
  cursor: pointer;
}
.close-modal-btn:hover { color: #0f172a; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
}
.modal-body.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

/* 상점 모달 */
.shop-subheading {
  font-size: 14px;
  font-weight: 800;
  color: #0288d1;
  margin-bottom: 8px;
}
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 10px 14px;
}
.shop-item-icon {
  width: 46px;
  height: 46px;
  background: #e0f2fe;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}
.shop-item-icon .char-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 2px;
}
.shop-item-info {
  flex: 1;
}
.shop-item-name {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 6px;
}
.hotkey-badge {
  font-size: 10px;
  background: #e2e8f0;
  color: #475569;
  padding: 1px 5px;
  border-radius: 4px;
}
.lux-badge {
  font-size: 9px;
  background: #f59e0b;
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px;
}
.hidden-badge {
  font-size: 9px;
  background: #ef4444;
  color: #fff;
  padding: 1px 5px;
  border-radius: 4px;
}
.shop-item-desc {
  font-size: 11.5px;
  color: #64748b;
  margin: 2px 0;
}
.shop-item-stock {
  font-size: 11px;
  color: #0288d1;
}
.buy-btn {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: #0288d1;
  color: #fff;
  border: none;
  font-size: 12.5px;
  font-weight: 800;
  cursor: pointer;
}
.buy-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
}

/* 프로필 모달 */
.prof-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #f1f5f9;
  padding: 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}
.prof-medal {
  font-size: 40px;
}
.prof-rank {
  font-size: 13px;
  color: #0288d1;
  font-weight: 800;
}
.prof-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.prof-item {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.prof-item small {
  display: block;
  font-size: 11px;
  color: #64748b;
  margin-bottom: 2px;
}
.prof-item b {
  font-size: 14px;
  color: #0f172a;
}

/* 가이드 모달 */
.guide-body h4 {
  font-size: 14px;
  color: #0288d1;
  margin: 14px 0 6px;
}
.guide-body ul {
  padding-left: 20px;
  font-size: 13px;
  color: #334155;
  line-height: 1.6;
}

/* 결과 & 일시정지 다이얼로그 버튼 */
.dialog-btns {
  display: flex;
  gap: 10px;
  width: 100%;
}
.btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  font-size: 14px;
  font-weight: 800;
  color: #334155;
  cursor: pointer;
  transition: all 0.15s;
}
.btn.primary {
  background: #0288d1;
  border-color: #0288d1;
  color: #fff;
}
.btn.danger {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.res-reward-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 14px 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}
.res-item {
  display: flex;
  justify-content: space-between;
}
.res-item b {
  color: #0288d1;
}

/* 에러 화면 */
.error-panel {
  background: #fff;
  padding: 30px;
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-box);
  margin: auto;
}
