:root {
  --bg: #050816;
  --card: #0f172a;
  --card-border: #1e293b;
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #facc15;
  --danger: #ef4444;
  --success: #4ade80;
  --live: #f97316;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at top, #0f172a 0%, var(--bg) 70%);
  color: var(--text);
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

.screen {
  display: none;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
  flex-direction: column;
}

.hidden {
  display: none !important;
}

button,
input,
select {
  touch-action: manipulation;
}

/* ===== 로비 화면 ===== */
#screen-lobby {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(12px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right))
    calc(235px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  gap: 12px;
  max-width: 1120px;
  margin: 0 auto;
}

#screen-lobby.chat-collapsed {
  padding-bottom: calc(105px + env(safe-area-inset-bottom));
}

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 32px;
  filter: drop-shadow(0 0 8px rgba(250, 204, 21, 0.6));
}

.title-with-version {
  display: flex;
  align-items: center;
  gap: 6px;
}

.version-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.16);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: var(--accent-2);
  letter-spacing: 0.2px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--muted);
}

.lobby-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn-install-app {
  appearance: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.14);
  border: 1px solid rgba(250, 204, 21, 0.45);
  color: var(--accent-2);
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn-install-app:hover {
  background: rgba(250, 204, 21, 0.24);
}

.btn-install-app:active {
  transform: scale(0.96);
}

.btn-install-app.install-ready {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.24), rgba(250, 204, 21, 0.22));
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.btn-sound-toggle {
  background: rgba(74, 222, 128, 0.14);
  border-color: rgba(74, 222, 128, 0.45);
  color: var(--success);
}

.btn-sound-toggle:hover {
  background: rgba(74, 222, 128, 0.24);
}

.btn-sound-toggle.muted {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.4);
  color: var(--muted);
}

.btn-sound-toggle.waiting {
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.5);
  color: var(--gold);
}

.btn-sound-toggle.waiting:hover {
  background: rgba(250, 204, 21, 0.24);
}

.status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--accent);
  white-space: nowrap;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

@media (min-width: 720px) {
  .lobby-grid {
    grid-template-columns: 1.15fr 1fr;
    align-items: start;
  }
  .join-card {
    grid-column: 1 / -1;
  }
}

@media (max-width: 719px) {
  .lobby-header {
    flex-wrap: wrap;
  }
  .player-slot {
    min-height: 32px;
    padding: 5px 8px;
  }
}

.card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.35);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.card-title-row h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.role-hint,
.mini-note {
  font-size: 11px;
  color: var(--muted);
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.input-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--muted);
}

.input-row input {
  width: 100%;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid #334155;
  background: #020617;
  color: var(--text);
  font-size: 16px;
  user-select: text;
  -webkit-user-select: text;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.control-option-row {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.control-option-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.control-option-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
}

.control-option-desc {
  font-size: 11px;
  color: var(--muted);
}

.switch-toggle {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.switch-slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #334155;
  border: 1px solid #475569;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.switch-slider::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  left: 2px;
  top: 2px;
  border-radius: 50%;
  background: #f8fafc;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.45);
  transition: transform 0.18s ease;
}

.switch-toggle input:checked + .switch-slider {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.85), rgba(34, 211, 238, 0.85));
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.45);
}

.switch-toggle input:checked + .switch-slider::before {
  transform: translateX(22px);
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, #0284c7, #38bdf8);
  color: #020617;
  flex: 1;
}

.btn-secondary {
  background: #1e293b;
  color: var(--text);
  border: 1px solid #334155;
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid #334155;
}

.btn-start {
  width: 100%;
  padding: 14px;
  font-size: 16px;
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #090d16;
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.35);
}

.setting-group {
  margin-bottom: 12px;
}

.setting-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.chip-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 9px 10px;
  border-radius: 10px;
  background: #0b1222;
  border: 1px solid #334155;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.chip-btn small {
  font-size: 10px;
  font-weight: 500;
  color: var(--muted);
}

.chip-btn.active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.16);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.22);
}

.chip-btn.chip-live.active {
  border-color: var(--live);
  background: rgba(249, 115, 22, 0.18);
  box-shadow: 0 0 12px rgba(249, 115, 22, 0.28);
}

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

.pill-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1222;
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.pill-btn.active {
  background: var(--accent);
  color: #020617;
  border-color: var(--accent);
}

.settings-card.readonly .chip-btn,
.settings-card.readonly .pill-btn,
.settings-card.readonly .bot-controls button,
.settings-card.readonly .speed-slider {
  opacity: 0.72;
  pointer-events: none;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.slider-header .setting-label {
  margin-bottom: 0;
}

.slider-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

.speed-slider {
  width: 100%;
  height: 28px;
  touch-action: pan-x;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 4px 0;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: var(--muted);
}

.rule-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.rule-badges span {
  font-size: 11px;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.22);
  padding: 4px 8px;
  border-radius: 6px;
  color: #cbd5e1;
}

.player-slots {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-bottom: 12px;
}

.player-slot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 9px;
  border-radius: 9px;
  background: #0b1222;
  border: 1px solid #1e293b;
  font-size: 12px;
  min-height: 36px;
}

.player-slot.empty {
  border-style: dashed;
  color: #475569;
  justify-content: center;
}

.slot-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.color-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
}

.slot-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 600;
}

.slot-tag {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: #334155;
  color: #e2e8f0;
  flex-shrink: 0;
}

.slot-score {
  font-weight: 700;
  color: var(--accent-2);
  flex-shrink: 0;
}

.start-hint {
  margin: 6px 0 0;
  font-size: 11px;
  text-align: center;
  color: var(--muted);
}

/* ===== 인게임 화면 (모바일 뷰포트 고정) ===== */
#screen-game {
  height: 100dvh;
  overflow: hidden;
  touch-action: none;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  gap: 6px;
}

.game-hud {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 5px 8px;
  flex-shrink: 0;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}

.hud-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.hud-badge.mode {
  background: rgba(56, 189, 248, 0.18);
  color: var(--accent);
}

.hud-badge.role {
  background: rgba(250, 204, 21, 0.18);
  color: var(--accent-2);
}

.hud-badge.role.tagger {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.hud-stat {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}

.timer-wrap {
  display: flex;
  align-items: center;
  gap: 5px;
}

.hud-timer {
  font-size: 18px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.hud-timer.fever {
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.7);
}

.fever-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 5px;
  border-radius: 4px;
  background: #ef4444;
  color: #fff;
}

.survival-track {
  width: 82px;
  height: 4px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
}

.survival-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #38bdf8, #4ade80);
  transform-origin: left center;
  transform: scaleX(0);
  will-change: transform;
}

.hud-right {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
}

.hud-score {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-2);
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1222;
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
}

.icon-btn.waiting {
  border-color: rgba(250, 204, 21, 0.55);
  background: rgba(250, 204, 21, 0.16);
  color: var(--gold);
}

.game-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
}

.canvas-wrap {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  background: #030712;
  box-shadow: 0 0 28px rgba(15, 23, 42, 0.9);
  touch-action: none;
}

.side-panel {
  display: none;
}

@media (min-width: 900px) and (min-height: 521px) {
  .side-panel {
    display: flex;
    flex-direction: column;
    width: 260px;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 10px;
    gap: 10px;
    overflow: hidden;
  }

  .side-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
  }

  .side-section h3 {
    margin: 0 0 6px;
    font-size: 13px;
  }

  .scoreboard-list,
  .event-log {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .scoreboard-list li {
    display: flex;
    justify-content: space-between;
    padding: 4px 6px;
    background: #0b1222;
    border-radius: 6px;
  }

  .event-log li {
    color: var(--muted);
    line-height: 1.35;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(30, 41, 59, 0.6);
  }
}

.game-bottom-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 6px 8px;
  flex-shrink: 0;
}

.buff-chips {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  gap: 4px;
  align-items: center;
  min-height: 28px;
}

.buff-chips::-webkit-scrollbar {
  display: none;
}

.buff-hint {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.buff-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: #e0f2fe;
  white-space: nowrap;
  flex-shrink: 0;
}

.buff-chip.shield {
  background: rgba(74, 222, 128, 0.16);
  border-color: rgba(74, 222, 128, 0.5);
  color: #dcfce7;
}

.buff-chip.deploy {
  background: rgba(250, 204, 21, 0.16);
  border-color: rgba(250, 204, 21, 0.5);
  color: #fef9c3;
}

.buff-chip.instant {
  background: rgba(168, 85, 247, 0.2);
  border-color: rgba(192, 132, 252, 0.55);
  color: #f3e8ff;
}

.buff-chip.debuff {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(248, 113, 113, 0.55);
  color: #fee2e2;
}

/* ===== 캔버스 좌상단 활성 아이템 HUD ===== */
.active-items-hud {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: min(44vw, 196px);
  pointer-events: none;
}

.active-items-hud:empty {
  display: none;
}

.active-item-card {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 8px 7px;
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(56, 189, 248, 0.5);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  font-size: 11px;
  line-height: 1.15;
}

.active-item-card.buff {
  border-color: rgba(56, 189, 248, 0.65);
  --item-accent: #38bdf8;
}

.active-item-card.shield {
  border-color: rgba(74, 222, 128, 0.65);
  --item-accent: #4ade80;
}

.active-item-card.deploy {
  border-color: rgba(250, 204, 21, 0.65);
  --item-accent: #facc15;
}

.active-item-card.instant {
  border-color: rgba(192, 132, 252, 0.7);
  --item-accent: #c084fc;
}

.active-item-card.debuff {
  border-color: rgba(248, 113, 113, 0.75);
  --item-accent: #ef4444;
}

.active-item-main {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.active-item-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.active-item-name {
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.active-item-time {
  font-weight: 800;
  font-size: 10px;
  color: var(--item-accent, #38bdf8);
  white-space: nowrap;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.active-item-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(148, 163, 184, 0.22);
}

.active-item-progress-fill {
  height: 100%;
  width: 100%;
  transform-origin: left center;
  background: var(--item-accent, #38bdf8);
  transition: transform 0.08s linear;
}

@media (max-width: 600px) {
  .active-items-hud {
    top: 6px;
    left: 6px;
    width: min(44vw, 152px);
    gap: 4px;
  }
  .active-item-card {
    padding: 4px 6px 6px;
    font-size: 10px;
    background: rgba(15, 23, 42, 0.68);
  }
  .active-item-icon {
    font-size: 12px;
  }
  .active-item-time {
    font-size: 9px;
  }
}

/* ===== 인게임 좌측 하단 조이스틱 & 우측 하단 오렌지 액션 버튼 ===== */
.touch-controls-layer {
  position: absolute;
  inset: 0;
  z-index: 19;
  pointer-events: none;
}

.virtual-joystick {
  position: absolute;
  left: max(14px, env(safe-area-inset-left));
  bottom: 14px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}

.virtual-joystick.active {
  cursor: grabbing;
}

.joystick-ring {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: rgba(15, 23, 42, 0.36);
  border: 2px solid rgba(56, 189, 248, 0.42);
  box-shadow: inset 0 0 18px rgba(56, 189, 248, 0.14), 0 4px 18px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(4px);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.virtual-joystick.active .joystick-ring {
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: inset 0 0 22px rgba(56, 189, 248, 0.25), 0 0 16px rgba(56, 189, 248, 0.35);
}

.joy-dir-arrow {
  position: absolute;
  font-size: 11px;
  font-weight: 800;
  color: rgba(226, 232, 240, 0.42);
  line-height: 1;
  pointer-events: none;
  transition: color 0.1s ease, transform 0.1s ease;
}

.joy-dir-arrow.up {
  top: 7px;
  left: 50%;
  transform: translateX(-50%);
}

.joy-dir-arrow.down {
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
}

.joy-dir-arrow.left {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.joy-dir-arrow.right {
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.virtual-joystick[data-dir="UP"] .joy-dir-arrow.up,
.virtual-joystick[data-dir="DOWN"] .joy-dir-arrow.down,
.virtual-joystick[data-dir="LEFT"] .joy-dir-arrow.left,
.virtual-joystick[data-dir="RIGHT"] .joy-dir-arrow.right {
  color: #38bdf8;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.9);
}

.joystick-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(125, 211, 252, 0.72), rgba(56, 189, 248, 0.38));
  border: 2px solid rgba(224, 242, 254, 0.75);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  transition: transform 0.08s ease-out;
}

.virtual-joystick.active .joystick-knob {
  transition: none;
}

.action-control-wrap {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  bottom: 14px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}

.action-inventory-queue {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: flex-end;
  max-width: 180px;
}

.action-inventory-queue:empty {
  display: none;
}

.queue-slot {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  background: rgba(15, 23, 42, 0.62);
  border: 1px solid rgba(249, 115, 22, 0.35);
  opacity: 0.72;
}

.queue-slot.selected {
  opacity: 1;
  background: rgba(249, 115, 22, 0.48);
  border-color: #fb923c;
  box-shadow: 0 0 8px rgba(249, 115, 22, 0.65);
  transform: scale(1.08);
}

.btn-action-item {
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(251, 146, 60, 0.85);
  background: radial-gradient(circle at 35% 30%, rgba(251, 146, 60, 0.62), rgba(234, 88, 12, 0.46));
  box-shadow: 0 4px 18px rgba(249, 115, 22, 0.4), inset 0 0 14px rgba(255, 237, 213, 0.25);
  backdrop-filter: blur(4px);
  color: #fff7ed;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease, box-shadow 0.15s ease;
}

.btn-action-item:active {
  transform: scale(0.92);
  box-shadow: 0 0 22px rgba(251, 146, 60, 0.75);
}

.btn-action-item.empty {
  opacity: 0.46;
  border-color: rgba(249, 115, 22, 0.42);
  background: rgba(154, 52, 18, 0.28);
  box-shadow: none;
}

.btn-action-item.pulse-use {
  box-shadow: 0 0 26px rgba(250, 204, 21, 0.9);
  transform: scale(1.06);
}

.btn-action-item.pulse-cycle {
  border-color: #facc15;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.75);
}

.action-item-icon {
  font-size: 26px;
  line-height: 1;
}

.action-item-label {
  font-size: 10px;
  font-weight: 800;
  max-width: 78px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.action-item-count {
  font-size: 9px;
  font-weight: 700;
  color: #ffedd5;
  opacity: 0.9;
}

@media (max-width: 600px) {
  .virtual-joystick {
    left: 10px;
    bottom: 10px;
    width: 96px;
    height: 96px;
  }
  .joystick-knob {
    width: 40px;
    height: 40px;
  }
  .action-control-wrap {
    right: 10px;
    bottom: 10px;
  }
  .btn-action-item {
    width: 80px;
    height: 80px;
  }
  .action-item-icon {
    font-size: 22px;
  }
  .action-item-label {
    font-size: 9px;
    max-width: 68px;
  }
  .queue-slot {
    width: 22px;
    height: 22px;
    font-size: 12px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  .virtual-joystick {
    width: 88px;
    height: 88px;
    bottom: 8px;
    left: 8px;
  }
  .joystick-knob {
    width: 36px;
    height: 36px;
  }
  .btn-action-item {
    width: 74px;
    height: 74px;
  }
  .action-item-icon {
    font-size: 20px;
  }
}

@media (max-width: 400px) {
  .hud-badge {
    font-size: 10px;
    padding: 2px 5px;
  }
  .hud-stat {
    font-size: 10px;
  }
  .hud-timer {
    font-size: 15px;
  }
  .survival-track {
    width: 60px;
  }
  .hud-score {
    font-size: 12px;
  }
  .icon-btn {
    width: 30px;
    height: 30px;
    font-size: 14px;
  }
  .emoji-btn {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }
}

@media (max-height: 520px) and (orientation: landscape) {
  #screen-game {
    padding: 4px max(8px, env(safe-area-inset-right)) 4px max(8px, env(safe-area-inset-left));
    gap: 4px;
  }
  .game-hud {
    padding: 3px 8px;
  }
  .hud-timer {
    font-size: 15px;
  }
  .game-bottom-bar {
    padding: 4px 8px;
  }
  .emoji-btn {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }
}

.emoji-bar {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.emoji-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #0b1222;
  font-size: 17px;
  cursor: pointer;
}

/* ===== 토스트 ===== */
.toast-container {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 20;
  pointer-events: none;
  width: 90%;
  max-width: 340px;
}

.toast {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  animation: fadeSlide 0.2s ease;
}

.toast.lobby-toast {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  width: min(92vw, 420px);
  pointer-events: none;
  animation: lobbyToastFade 0.2s ease;
}

@keyframes lobbyToastFade {
  from {
    opacity: 0;
    transform: translate(-50%, -6px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

@keyframes fadeSlide {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== 모달 ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  border: 1px solid #334155;
  border-radius: 18px;
  padding: 18px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.65);
}

.roulette-card {
  max-width: 440px;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 16px;
}

.roulette-banner-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 10px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  background: #050816;
}

.roulette-mode-banner {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.roulette-meta {
  margin: 0 0 6px;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700;
}

.roulette-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
}

#roulette-canvas {
  width: min(230px, 56vw);
  max-width: 240px;
  height: auto;
}

.roulette-result {
  margin: 12px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-2);
}

/* 가위바위보 결투 모달 */
.rps-round {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
}

.rps-header h3 {
  margin: 8px 0 4px;
  font-size: 20px;
}

.rps-header p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.rps-timer-track {
  width: 100%;
  height: 8px;
  background: #1e293b;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 16px;
}

.rps-timer-fill {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #facc15);
  transform-origin: left center;
  transform: scaleX(1);
  will-change: transform;
}

.rps-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.rps-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px 8px;
  border-radius: 14px;
  border: 2px solid #334155;
  background: #0b1222;
  color: var(--text);
  font-size: 32px;
  cursor: pointer;
}

.rps-btn span {
  font-size: 13px;
  font-weight: 700;
}

.rps-btn.selected {
  border-color: var(--accent-2);
  background: rgba(250, 204, 21, 0.2);
}

.rps-result-text {
  margin: 12px 0 0;
  min-height: 20px;
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-2);
}

/* 라운드 종료 결과 모달 */
.awards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.award-item {
  background: #0b1222;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 8px;
  font-size: 12px;
}

.award-item strong {
  display: block;
  color: var(--accent-2);
  margin-bottom: 2px;
}

.leaderboard-wrap {
  text-align: left;
  background: #0b1222;
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 12px;
  max-height: 210px;
  overflow-y: auto;
}

.leaderboard-wrap h3 {
  margin: 0 0 8px;
  font-size: 13px;
}

.final-leaderboard {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
}

.final-leaderboard li {
  display: flex;
  justify-content: space-between;
}

.auto-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0 10px;
}

/* ===== 실시간 방 목록(서버 브라우저) ===== */
.room-browser {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #1e293b;
}

.room-browser-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.room-browser-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
}

.room-browser-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  background: rgba(148, 163, 184, 0.12);
  padding: 2px 8px;
  border-radius: 999px;
}

.room-browser-actions {
  display: flex;
  gap: 6px;
}

.btn-mini {
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
  border-radius: 8px;
  background: #1e293b;
  color: var(--text);
  border: 1px solid #334155;
}

.room-browser-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  max-height: 196px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 719px) {
  .room-browser-list {
    grid-template-columns: 1fr;
    max-height: 168px;
  }
}

.room-browser-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 14px 10px;
  border: 1px dashed #334155;
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}

.room-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #0b1222;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.08s ease, background 0.15s ease;
}

.room-item:hover {
  border-color: var(--accent);
  background: #0f1b33;
}

.room-item:active {
  transform: scale(0.98);
}

.room-item.current {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.18);
}

.room-item.full {
  border-color: rgba(239, 68, 68, 0.45);
  opacity: 0.78;
}

.room-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.room-item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.room-code {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-current-badge {
  font-size: 10px;
  font-weight: 700;
  color: #020617;
  background: var(--accent);
  padding: 1px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.room-meta {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-item-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.room-phase {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
}

.room-phase.lobby {
  background: rgba(74, 222, 128, 0.16);
  color: var(--success);
  border: 1px solid rgba(74, 222, 128, 0.4);
}

.room-phase.playing {
  background: rgba(249, 115, 22, 0.16);
  color: var(--live);
  border: 1px solid rgba(249, 115, 22, 0.4);
}

.room-phase.full {
  background: rgba(239, 68, 68, 0.16);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.room-players-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
}

/* ===== 로비 채팅창 (화면 하단 고정 도크) ===== */
.lobby-chat {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(8px, env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 1092px);
  z-index: 40;
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(10px);
  border: 1px solid #334155;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.55);
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 10px 12px;
}

.lobby-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.lobby-chat-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quick-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.quick-chat-btn {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0b1222;
  color: #cbd5e1;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.quick-chat-btn:active {
  transform: scale(0.96);
}

.chat-toggle-btn {
  border-color: #475569;
  color: var(--accent);
}

.lobby-chat-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  height: 110px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 10px;
  border-radius: 10px;
  background: #020617;
  border: 1px solid #1e293b;
  font-size: 12px;
}

@media (max-width: 719px) {
  .lobby-chat-list {
    height: 96px;
  }
}

.lobby-chat.collapsed .lobby-chat-list,
.lobby-chat.collapsed .quick-chat-chips {
  display: none;
}

.lobby-chat-empty {
  margin: auto;
  text-align: center;
  font-size: 11px;
  color: #64748b;
}

.chat-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  line-height: 1.38;
  word-break: break-word;
}

.chat-item .color-dot {
  margin-top: 4px;
}

.chat-item-body {
  min-width: 0;
  flex: 1;
}

.chat-author {
  font-weight: 700;
  color: #e2e8f0;
  margin-right: 5px;
}

.chat-item.me .chat-author {
  color: var(--accent);
}

.chat-text {
  color: #cbd5e1;
}

.lobby-chat-form {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.lobby-chat-form input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 9px;
  border: 1px solid #334155;
  background: #020617;
  color: var(--text);
  font-size: 16px;
  user-select: text;
  -webkit-user-select: text;
}

.lobby-chat-form button {
  padding: 8px 14px;
  flex-shrink: 0;
}

/* ===== 자동재생 차단 시 노출되는 레트로 PRESS START 입장 오버레이 ===== */
.press-start-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at 50% 35%, rgba(15, 23, 42, 0.86), rgba(2, 6, 23, 0.94));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  animation: fadeSlide 0.2s ease-out;
}

.press-start-card {
  width: 100%;
  max-width: 360px;
  padding: 28px 22px 22px;
  border-radius: 22px;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.96), rgba(11, 18, 34, 0.98));
  border: 1.5px solid rgba(56, 189, 248, 0.45);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.72), 0 0 36px rgba(56, 189, 248, 0.18);
  text-align: center;
}

.press-start-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--gold);
  background: rgba(250, 204, 21, 0.14);
  border: 1px solid rgba(250, 204, 21, 0.42);
  margin-bottom: 12px;
}

.press-start-logo {
  font-size: 54px;
  line-height: 1.1;
  margin-bottom: 8px;
  filter: drop-shadow(0 6px 18px rgba(56, 189, 248, 0.45));
  animation: pressLogoFloat 2.4s ease-in-out infinite;
}

@keyframes pressLogoFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.press-start-title {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: var(--text);
}

.press-start-sub {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
}

.btn-press-start {
  width: 100%;
  padding: 15px 18px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #38bdf8, #3b82f6 55%, #a855f7);
  color: #ffffff;
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  box-shadow: 0 8px 26px rgba(56, 189, 248, 0.42);
  animation: pressStartPulse 1.8s ease-in-out infinite;
}

.btn-press-start:hover {
  filter: brightness(1.08);
}

@keyframes pressStartPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 8px 24px rgba(56, 189, 248, 0.38);
  }
  50% {
    transform: scale(1.025);
    box-shadow: 0 10px 32px rgba(56, 189, 248, 0.65);
  }
}

.press-start-hint {
  margin: 12px 0 14px;
  font-size: 12px;
  color: #cbd5e1;
}

.btn-enter-muted {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  padding: 7px 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-enter-muted:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.55);
}

/* ===== 튜토리얼 모드 버튼, 사전 안내 & 아이템 도감 모달, 인게임 코치 HUD ===== */
.btn-tutorial-open {
  appearance: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(74, 222, 128, 0.22));
  border: 1px solid rgba(56, 189, 248, 0.55);
  color: #e0f2fe;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.22);
  transition: transform 0.14s ease, filter 0.14s ease;
}

.btn-tutorial-open:hover {
  filter: brightness(1.12);
}

.btn-tutorial-open:active {
  transform: scale(0.96);
}

.btn-tutorial-secondary {
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  font-size: 12px;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.42);
  color: #bae6fd;
}

.btn-tutorial-secondary:hover {
  background: rgba(14, 165, 233, 0.22);
}

/* 인게임 하단 AUTO 모드 토글 버튼 */
.btn-ingame-auto {
  appearance: none;
  font-family: inherit;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid #475569;
  background: #0b1222;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn-ingame-auto:hover {
  border-color: rgba(56, 189, 248, 0.6);
  color: var(--text);
}

.btn-ingame-auto.active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.24), rgba(74, 222, 128, 0.2));
  border-color: var(--accent);
  color: #e0f2fe;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.28);
}

.btn-ingame-auto:active {
  transform: scale(0.96);
}

.round-over-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.tutorial-modal-card {
  max-width: 660px;
  width: 100%;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 16px;
  gap: 12px;
  border-color: rgba(56, 189, 248, 0.45);
}

.tutorial-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-shrink: 0;
}

.tutorial-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.tutorial-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0b1222;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.tutorial-close-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.tutorial-mode-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  flex-shrink: 0;
}

.tutorial-mode-tab {
  appearance: none;
  font-family: inherit;
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid #334155;
  background: #0b1222;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.14s ease, background 0.14s ease, color 0.14s ease;
}

.tutorial-mode-tab.active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.18);
  color: var(--text);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.tutorial-modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
  min-height: 0;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tutorial-view {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tutorial-mode-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: rgba(11, 18, 34, 0.85);
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 14px;
}

.tutorial-mode-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tutorial-mode-title {
  margin: 0;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.tutorial-mode-badge {
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.14);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: var(--accent);
}

.tutorial-mode-summary {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #cbd5e1;
}

.tutorial-gimmick-box {
  background: rgba(250, 204, 21, 0.09);
  border: 1px solid rgba(250, 204, 21, 0.46);
  border-radius: 10px;
  padding: 11px 12px;
}

.tutorial-gimmick-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-2);
  margin-bottom: 5px;
}

.tutorial-gimmick-desc {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: #fef3c7;
}

.tutorial-rules-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14px;
  line-height: 1.55;
  color: #e2e8f0;
}

.tutorial-quick-controls {
  padding: 9px 11px;
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid #334155;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
  font-weight: 600;
}

.btn-tutorial-items-trigger {
  width: 100%;
  padding: 13px 14px;
  font-size: 15px;
  font-weight: 800;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.18), rgba(250, 204, 21, 0.16));
  border: 1.5px solid rgba(56, 189, 248, 0.55);
  color: #f8fafc;
  text-align: center;
}

.btn-tutorial-items-trigger:hover {
  filter: brightness(1.1);
}

.tutorial-items-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.btn-tutorial-back {
  appearance: none;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 800;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid rgba(56, 189, 248, 0.5);
  background: rgba(56, 189, 248, 0.12);
  color: #bae6fd;
  cursor: pointer;
}

.btn-tutorial-back:hover {
  background: rgba(56, 189, 248, 0.22);
}

.tutorial-items-heading {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

.tutorial-item-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tutorial-filter-btn {
  appearance: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: #0b1222;
  color: var(--muted);
  cursor: pointer;
}

.tutorial-filter-btn.active {
  border-color: var(--accent);
  background: rgba(56, 189, 248, 0.16);
  color: var(--text);
}

.tutorial-items-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}

.tutorial-item-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(11, 18, 34, 0.92);
  border: 1px solid #1e293b;
  border-radius: 10px;
  padding: 11px 12px;
}

.tutorial-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.tutorial-item-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text);
}

.role-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #bae6fd;
  white-space: nowrap;
}

.role-badge.shared {
  background: rgba(249, 115, 22, 0.16);
  border-color: rgba(249, 115, 22, 0.5);
  color: #fed7aa;
}

.tutorial-item-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
}

.tutorial-modal-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #1e293b;
  flex-shrink: 0;
}

.tutorial-footer-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.tutorial-footer-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.tutorial-start-btn {
  flex: 1;
  padding: 12px 14px;
  font-size: 15px;
}

/* 인게임 튜토리얼 코치 배너 */
.tutorial-coach {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: min(94%, 460px);
  z-index: 22;
  pointer-events: none;
  background: rgba(9, 13, 28, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.6);
  border-radius: 12px;
  padding: 8px 11px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(5px);
}

.tutorial-coach.completed {
  border-color: rgba(250, 204, 21, 0.8);
  box-shadow: 0 8px 26px rgba(250, 204, 21, 0.2);
}

.tutorial-coach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.tutorial-coach-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
}

.tutorial-coach.completed .tutorial-coach-badge {
  color: var(--accent-2);
}

.tutorial-coach-actions {
  display: flex;
  gap: 4px;
  pointer-events: auto;
}

.tutorial-mini-btn {
  appearance: none;
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: rgba(15, 23, 42, 0.95);
  color: #e2e8f0;
  cursor: pointer;
}

.tutorial-mini-btn:hover {
  border-color: var(--accent);
}

.tutorial-coach-mission {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.35;
}

.tutorial-coach-hint {
  font-size: 12px;
  color: #cbd5e1;
  margin-top: 3px;
  line-height: 1.4;
}

.tutorial-coach-tip {
  margin-top: 5px;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(250, 204, 21, 0.14);
  border: 1px solid rgba(250, 204, 21, 0.4);
  color: #fef08a;
  font-size: 11.5px;
  font-weight: 700;
}

.tutorial-stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 6px;
}

.tutorial-step-pill {
  font-size: 10.5px;
  font-weight: 700;
  text-align: center;
  padding: 3px 4px;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.85);
  color: var(--muted);
  border: 1px solid rgba(51, 65, 85, 0.8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tutorial-step-pill.current {
  border-color: rgba(56, 189, 248, 0.7);
  color: #e0f2fe;
}

.tutorial-step-pill.done {
  background: rgba(74, 222, 128, 0.18);
  border-color: rgba(74, 222, 128, 0.6);
  color: #bbf7d0;
}

#screen-game.tutorial-active .toast-container,
#screen-game.tutorial-active .active-items-hud {
  top: 108px;
}

@media (max-width: 600px) {
  .tutorial-modal-card {
    padding: 13px;
    gap: 10px;
  }
  .tutorial-mode-tabs {
    grid-template-columns: repeat(2, 1fr);
  }
  .tutorial-items-grid {
    grid-template-columns: 1fr;
  }
  .tutorial-coach {
    top: 6px;
    width: min(96%, 380px);
    padding: 7px 9px;
  }
  .tutorial-coach-mission {
    font-size: 12px;
  }
  .tutorial-coach-hint {
    font-size: 11px;
  }
  #screen-game.tutorial-active .toast-container,
  #screen-game.tutorial-active .active-items-hud {
    top: 96px;
  }
}

@media (max-width: 400px) {
  .btn-ingame-auto {
    font-size: 11px;
    padding: 5px 8px;
  }
}

/* ===== 튜토리얼 아이템 획득 일시정지 프리젠테이션 & 스포트라이트 ===== */
.tutorial-item-present {
  position: absolute;
  inset: 0;
  z-index: 26;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 12px 118px;
  background: rgba(2, 6, 23, 0.74);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  pointer-events: auto;
  animation: fadeSlide 0.18s ease-out;
}

.present-card {
  width: min(94%, 440px);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(160deg, rgba(15, 23, 42, 0.98), rgba(9, 13, 28, 0.98));
  border: 1.5px solid rgba(56, 189, 248, 0.65);
  border-radius: 16px;
  padding: 15px;
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.75), 0 0 28px rgba(56, 189, 248, 0.18);
  display: flex;
  flex-direction: column;
  gap: 11px;
  text-align: left;
}

.present-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.present-badge {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-2);
  background: rgba(250, 204, 21, 0.14);
  border: 1px solid rgba(250, 204, 21, 0.45);
  border-radius: 999px;
  padding: 3px 10px;
}

.present-item-hero {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(11, 18, 34, 0.9);
  border: 1px solid #1e293b;
  border-radius: 12px;
  padding: 12px;
}

.present-item-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  background: radial-gradient(circle at 35% 30%, rgba(56, 189, 248, 0.24), rgba(15, 23, 42, 0.9));
  border: 1px solid rgba(56, 189, 248, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  line-height: 1;
  flex-shrink: 0;
}

.present-item-text {
  min-width: 0;
  flex: 1;
}

.present-item-name {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 900;
  color: var(--text);
}

.present-item-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #e2e8f0;
}

.present-guide-title {
  font-size: 13.5px;
  font-weight: 800;
  color: #fed7aa;
}

.present-steps {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.present-step-card {
  background: rgba(11, 18, 34, 0.85);
  border: 1.5px solid #334155;
  border-radius: 11px;
  padding: 10px;
  opacity: 0.72;
  transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.present-step-card.active {
  opacity: 1;
  border-color: rgba(251, 146, 60, 0.9);
  background: rgba(249, 115, 22, 0.14);
  box-shadow: 0 0 18px rgba(249, 115, 22, 0.28);
  transform: translateY(-1px);
}

.present-step-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 5px;
  flex-wrap: wrap;
}

.present-step-num {
  font-size: 14px;
  font-weight: 900;
  color: #ffedd5;
}

.present-gesture-pill {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(251, 146, 60, 0.45);
  color: #fdba74;
  white-space: nowrap;
}

.present-step-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: #e2e8f0;
}

.present-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-present-use {
  background: linear-gradient(135deg, #0ea5e9, #38bdf8);
  color: #020617;
  font-size: 14px;
  padding: 11px 14px;
  flex: 1;
}

.present-resume-btn {
  width: auto;
  flex: 1;
  padding: 11px 14px;
  font-size: 15px;
}

/* 실제 우측 하단 오렌지 액션 버튼 스포트라이트 */
#touch-controls-layer.tutorial-presenting {
  z-index: 29;
}

#touch-controls-layer.tutorial-presenting .virtual-joystick {
  opacity: 0.2;
  pointer-events: none;
}

#touch-controls-layer.tutorial-presenting #action-control-wrap {
  pointer-events: auto;
}

#touch-controls-layer.tutorial-presenting .btn-action-item.demo-tap-use {
  animation: spotlightTapUse 1.1s ease-in-out infinite;
}

#touch-controls-layer.tutorial-presenting .btn-action-item.demo-tap-cycle {
  animation: spotlightTapCycle 1.25s ease-in-out infinite;
}

.action-spotlight-callout {
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #090d16;
  font-size: 12px;
  font-weight: 900;
  padding: 5px 11px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.58);
  animation: calloutBounce 1.1s ease-in-out infinite;
  pointer-events: none;
}

@keyframes spotlightTapUse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 4px rgba(250, 204, 21, 0.6), 0 0 24px rgba(249, 115, 22, 0.8);
  }
  45% {
    transform: scale(0.92);
    box-shadow: 0 0 0 12px rgba(250, 204, 21, 0.15), 0 0 32px rgba(249, 115, 22, 0.95);
  }
}

@keyframes spotlightTapCycle {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 4px rgba(56, 189, 248, 0.7), 0 0 24px rgba(56, 189, 248, 0.75);
  }
  20%,
  50% {
    transform: scale(0.91);
    box-shadow: 0 0 0 10px rgba(56, 189, 248, 0.25), 0 0 30px rgba(56, 189, 248, 0.95);
  }
  35% {
    transform: scale(1.02);
  }
}

@keyframes calloutBounce {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

@media (max-width: 600px) {
  .tutorial-item-present {
    padding: 8px 8px 98px;
  }
  .present-card {
    padding: 12px;
    gap: 9px;
  }
  .present-item-icon {
    width: 46px;
    height: 46px;
    font-size: 30px;
  }
  .present-item-name {
    font-size: 17px;
  }
  .present-item-desc {
    font-size: 13px;
  }
  .present-steps {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .present-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .present-resume-btn,
  .btn-present-use {
    width: 100%;
  }
}

/* ===== 게임 시작 전 3-2-1 카운트다운 인트로 & 튜토리얼 모드 배너 ===== */
.game-intro-overlay {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  pointer-events: none;
  animation: fadeSlide 0.2s ease-out;
}

.game-intro-card {
  width: min(92%, 430px);
  background: rgba(11, 18, 34, 0.96);
  border: 1.5px solid rgba(56, 189, 248, 0.65);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.78), 0 0 28px rgba(56, 189, 248, 0.2);
}

.game-intro-banner-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #050816;
}

.game-intro-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.game-intro-count {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fef08a, #f59e0b);
  border: 2.5px solid #ffffff;
  color: #090d16;
  font-size: 30px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.65);
}

.game-intro-info {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}

.game-intro-role {
  font-size: 16px;
  font-weight: 900;
  color: var(--accent-2);
}

.game-intro-role.tagger {
  color: #fca5a5;
}

.game-intro-sub {
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
}

.tutorial-mode-banner-wrap {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 185px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(56, 189, 248, 0.45);
  background: #050816;
}

.tutorial-mode-banner {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 600px) {
  .game-intro-count {
    width: 46px;
    height: 46px;
    font-size: 25px;
    right: 10px;
    bottom: 10px;
  }
  .game-intro-role {
    font-size: 14.5px;
  }
  .game-intro-sub {
    font-size: 12px;
  }
  .tutorial-mode-banner-wrap {
    max-height: 155px;
  }
}

/* ===== PWA 원클릭 자동 설치 배너 ===== */
.pwa-install-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.96), rgba(30, 58, 138, 0.42));
  border: 1.5px solid rgba(56, 189, 248, 0.58);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42), 0 0 18px rgba(56, 189, 248, 0.16);
  animation: fadeSlide 0.22s ease-out;
}

.pwa-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.pwa-banner-icon {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  border: 1px solid rgba(56, 189, 248, 0.55);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

.pwa-banner-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.pwa-banner-text strong {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text);
}

.pwa-banner-text span {
  font-size: 11.5px;
  color: #cbd5e1;
  line-height: 1.35;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-pwa-install {
  padding: 8px 13px;
  border-radius: 10px;
  background: linear-gradient(135deg, #facc15, #f97316);
  color: #090d16;
  font-size: 12.5px;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(249, 115, 22, 0.35);
}

.btn-pwa-install:hover {
  filter: brightness(1.08);
}

.btn-pwa-close {
  appearance: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid #334155;
  background: rgba(11, 18, 34, 0.9);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.btn-pwa-close:hover {
  color: var(--text);
  border-color: var(--accent);
}

@media (max-width: 600px) {
  .pwa-install-banner {
    flex-wrap: wrap;
    padding: 9px 10px;
  }
  .pwa-banner-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .btn-pwa-install {
    flex: 1;
  }
}
