:root {
  --bg: #161022;
  --panel: #221a36;
  --panel-deep: #1a1329;
  --line: #3a2e5c;
  --ink: #f5efff;
  --ink-dim: #b6a9d6;
  --blue: #5b9dff;
  --red: #ff6b6b;
  --gold: #ffcb47;
  --violet: #8b7bff;
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, system-ui, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
}

#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.splash-screen {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: stretch;
  background-color: var(--bg);
  background-image: linear-gradient(
      180deg,
      rgba(17, 12, 30, 0.92) 0%,
      rgba(17, 12, 30, 0.55) 26%,
      rgba(17, 12, 30, 0.12) 52%,
      rgba(17, 12, 30, 0.04) 100%
    ),
    url("/assets/hero-CNo8bKjJ.png");
  background-size: cover, cover;
  background-position: center, center bottom;
  background-repeat: no-repeat, no-repeat;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.splash-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-start {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(14px, 2.6vh, 30px);
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: clamp(28px, 7vh, 84px) 5vw;
}

.splash-title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  text-shadow: 0 3px 14px rgba(0, 0, 0, 0.7);
}

.splash-kicker {
  letter-spacing: 0.4em;
  font-size: clamp(12px, 1.6vmin, 18px);
  color: var(--violet);
  font-weight: 700;
}

.splash-main-title {
  font-size: clamp(44px, 9vmin, 104px);
  font-weight: 900;
}

.splash-subtitle {
  font-size: clamp(16px, 2.4vmin, 26px);
  color: var(--ink-dim);
  font-weight: 600;
}

.splash-prompt {
  font-size: clamp(15px, 2vmin, 22px);
  font-weight: 900;
  color: #171226;
  background: #ffd23f;
  border: 3px solid #000;
  border-radius: 12px;
  box-shadow: 5px 5px 0 #000;
  padding: 14px 38px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.65;
    transform: scale(0.97);
  }
}

.game-shell {
  position: absolute;
  inset: 0;
}

#game-container {
  position: absolute;
  inset: 0;
}

#game-container canvas {
  display: block;
}

.corner-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 8px;
  z-index: 80;
}

.corner-button {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  border: 2.5px solid #000;
  background: #fff;
  color: #171226;
  font-size: 22px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #000;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.corner-button:hover {
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #000;
}

.corner-button:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #000;
}

.toast {
  position: absolute;
  left: 50%;
  bottom: 4%;
  transform: translate(-50%, 12px);
  background: #fff;
  border: 3px solid #000;
  color: #171226;
  font-size: clamp(15px, 2vmin, 22px);
  font-weight: 800;
  padding: 12px 26px;
  border-radius: 12px;
  box-shadow: 4px 4px 0 #000;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
  z-index: 45;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(13, 9, 24, 0.9);
  backdrop-filter: blur(6px);
  padding: 3vmin;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  overflow: auto;
}

.menu-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.menu-panel {
  width: min(1060px, 96vw);
  background: #faf7f0;
  border: 4px solid #000;
  border-radius: 22px;
  box-shadow: 10px 10px 0 #000;
  padding: clamp(20px, 3.2vmin, 42px);
  text-align: center;
  color: #171226;
}

.menu-kicker {
  letter-spacing: 0.3em;
  color: #4f46e5;
  font-weight: 800;
  font-size: clamp(11px, 1.5vmin, 16px);
}

.menu-panel h2 {
  font-size: clamp(34px, 5.6vmin, 64px);
  font-weight: 900;
  margin: 6px 0 4px;
  color: #171226;
}

.menu-copy {
  color: #4a4458;
  font-size: clamp(13px, 1.9vmin, 19px);
  font-weight: 600;
  margin-bottom: clamp(14px, 2.2vmin, 24px);
}

.menu-course {
  display: flex;
  flex-direction: column;
  gap: clamp(12px, 2vmin, 22px);
  text-align: left;
}

.course-block {
  background: #fffdf7;
  border: 3px solid #000;
  border-radius: 14px;
  box-shadow: 5px 5px 0 #000;
  padding: clamp(12px, 2vmin, 20px);
}

.course-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.course-head span {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 2.5px solid #000;
  background: #4f46e5;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.course-head strong {
  font-size: clamp(16px, 2.2vmin, 22px);
  color: #171226;
}

.course-head em {
  margin-left: auto;
  font-style: normal;
  color: #8a5a00;
  font-weight: 800;
  font-size: clamp(13px, 1.8vmin, 18px);
}

[hidden] {
  display: none !important;
}

.grade-picker,
.time-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.time-picker {
  grid-template-columns: repeat(3, 1fr);
}

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

.party-picker,
.count-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

/* 공통 네오브루탈 선택 버튼 */
.grade-picker button,
.time-picker button,
.mode-picker button,
.party-picker button,
.count-picker button {
  border: 3px solid #000;
  background: #fff;
  color: #171226;
  border-radius: 12px;
  box-shadow: 4px 4px 0 #000;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-align: center;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.1s ease;
}

.grade-picker button,
.time-picker button {
  padding: clamp(10px, 1.6vmin, 16px) 6px;
  min-height: 58px;
}

.mode-picker button {
  padding: clamp(12px, 2vmin, 20px) 14px;
  min-height: 78px;
}

.party-picker button,
.count-picker button {
  padding: clamp(12px, 2vmin, 18px) 12px;
  min-height: 70px;
}

/* 호버: 위로 들림 */
.grade-picker button:hover,
.time-picker button:hover,
.mode-picker button:hover,
.party-picker button:hover,
.count-picker button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 6px 6px 0 #000;
  background: #fffaf0;
}

/* 누름: 쿵 */
.grade-picker button:active,
.time-picker button:active,
.mode-picker button:active,
.party-picker button:active,
.count-picker button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.grade-picker button span {
  font-size: clamp(18px, 2.6vmin, 30px);
  font-weight: 900;
  color: #4f46e5;
}

.grade-picker button strong,
.time-picker button strong,
.mode-picker button strong,
.party-picker button strong,
.count-picker button strong {
  font-size: clamp(14px, 2vmin, 22px);
  font-weight: 800;
}

.mode-picker button span {
  font-size: clamp(12px, 2vmin, 20px);
  font-weight: 900;
  color: #4f46e5;
  letter-spacing: 0.06em;
}

.party-picker button span {
  font-size: clamp(18px, 2.8vmin, 30px);
}

.time-picker button em,
.mode-picker button em,
.party-picker button em,
.count-picker button em {
  font-style: normal;
  color: #6a6478;
  font-size: clamp(11px, 1.5vmin, 15px);
  font-weight: 600;
}

/* 선택됨: 골드 채움 + 눌린 상태 고정 */
.grade-picker button.is-selected,
.mode-picker button.is-selected,
.party-picker button.is-selected,
.time-picker button.is-selected,
.count-picker button.is-selected,
.grade-picker button.is-selected:hover,
.mode-picker button.is-selected:hover,
.party-picker button.is-selected:hover,
.time-picker button.is-selected:hover,
.count-picker button.is-selected:hover {
  background: #ffd23f;
  color: #171226;
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.grade-picker button.is-selected span,
.mode-picker button.is-selected span {
  color: #171226;
}

.time-picker button.is-selected em,
.mode-picker button.is-selected em,
.party-picker button.is-selected em,
.count-picker button.is-selected em {
  color: #5a3d00;
}

.menu-actions {
  margin: clamp(16px, 2.6vmin, 28px) 0 8px;
}

.menu-start {
  font-family: inherit;
  font-size: clamp(20px, 3vmin, 32px);
  font-weight: 900;
  color: #fff;
  background: #4f46e5;
  border: 4px solid #000;
  border-radius: 14px;
  padding: clamp(14px, 2.2vmin, 22px) clamp(48px, 8vmin, 92px);
  cursor: pointer;
  box-shadow: 6px 6px 0 #000;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.menu-start:hover {
  transform: translate(-2px, -2px);
  box-shadow: 8px 8px 0 #000;
}

.menu-start:active {
  transform: translate(3px, 3px);
  box-shadow: 3px 3px 0 #000;
}

.menu-rules {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.menu-rules span {
  background: #fff;
  border: 2.5px solid #000;
  border-radius: 8px;
  box-shadow: 2px 2px 0 #000;
  color: #171226;
  font-size: clamp(11px, 1.5vmin, 15px);
  font-weight: 700;
  padding: 5px 12px;
}

.result-dialog {
  border: none;
  background: transparent;
  padding: 0;
  max-width: none;
}

.result-dialog::backdrop {
  background: rgba(13, 9, 24, 0.82);
  backdrop-filter: blur(5px);
}

.result-panel {
  width: min(720px, 92vw);
  background: #faf7f0;
  border: 4px solid #000;
  border-radius: 22px;
  box-shadow: 10px 10px 0 #000;
  padding: clamp(24px, 4vmin, 46px);
  text-align: center;
  color: #171226;
  font-family: "Pretendard Variable", Pretendard, system-ui, sans-serif;
}

.result-kicker {
  letter-spacing: 0.32em;
  color: #4f46e5;
  font-weight: 800;
  font-size: clamp(11px, 1.5vmin, 16px);
}

.result-panel h2 {
  font-size: clamp(34px, 5.6vmin, 60px);
  font-weight: 900;
  margin: 8px 0 18px;
  color: #171226;
}

.result-panel h2.blue-win {
  color: #1f5fc0;
}

.result-panel h2.red-win {
  color: #c0392b;
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 22px;
}

.result-stats .team-col {
  background: #fff;
  border: 3px solid #000;
  border-radius: 14px;
  box-shadow: 4px 4px 0 #000;
  padding: 16px;
}

.result-stats .team-col.winner {
  background: #ffd23f;
}

.result-stats .team-col h3 {
  font-size: clamp(16px, 2.2vmin, 22px);
  margin-bottom: 8px;
  color: #171226;
}

.result-stats .big-score {
  font-size: clamp(34px, 5vmin, 56px);
  font-weight: 900;
  color: #171226;
}

.result-stats .team-col p {
  color: #5a5568;
  font-size: clamp(12px, 1.7vmin, 16px);
  font-weight: 600;
  margin-top: 6px;
}

.result-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.primary-button {
  font-family: inherit;
  font-size: clamp(17px, 2.4vmin, 24px);
  font-weight: 900;
  color: #fff;
  background: #4f46e5;
  border: 3px solid #000;
  border-radius: 12px;
  padding: 14px 42px;
  cursor: pointer;
  box-shadow: 5px 5px 0 #000;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.primary-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #000;
}

.primary-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

.ghost-button {
  font-family: inherit;
  font-size: clamp(15px, 2vmin, 20px);
  font-weight: 800;
  color: #171226;
  background: #fff;
  border: 3px solid #000;
  border-radius: 12px;
  padding: 14px 30px;
  cursor: pointer;
  box-shadow: 5px 5px 0 #000;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.ghost-button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 7px 7px 0 #000;
}

.ghost-button:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #000;
}

/* 가로모드 전용: 세로일 때 안내로 덮고 게임을 가린다 */
.rotate-notice {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, #241a3e 0%, var(--bg) 72%);
  padding: 8vw;
  text-align: center;
}

.rotate-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.rotate-icon {
  font-size: clamp(64px, 18vw, 120px);
  color: var(--gold);
  animation: rotate-hint 2s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%,
  60%,
  100% {
    transform: rotate(0deg);
  }
  30% {
    transform: rotate(90deg);
  }
}

.rotate-title {
  font-size: clamp(24px, 6vw, 40px);
  font-weight: 900;
}

.rotate-sub {
  font-size: clamp(14px, 3.6vw, 20px);
  color: var(--ink-dim);
  font-weight: 600;
  max-width: 22em;
}

@media (orientation: portrait) {
  .rotate-notice {
    display: grid;
  }
}
