/* 슈퍼마리오 — 네오 아케이드 스타일 시트 */
:root {
  --bg-deep: #0a0b10;
  --panel-border: rgba(255, 255, 255, 0.08);
  --neon-blue: #390099;
  --neon-magenta: #9e0059;
  --neon-gold: #ffbd00;
  --neon-cyan: #00f5d4;
  --led-red: #ff0055;
  --led-yellow: #ffcc00;
  --led-green: #00ff66;
  --glass: rgba(16, 18, 27, 0.75);
  
  --font-game: "Press Start 2P", monospace;
  --font-ui: "IBM Plex Sans KR", sans-serif;
  --cabinet-wood: #26140b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
}

body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background-color: var(--bg-deep);
  font-family: var(--font-ui);
  color: #f1f2f6;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
}

/* 앰비언트 백그라운드 */
.ambient-glow {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: 
    radial-gradient(circle at 10% 20%, rgba(158, 0, 89, 0.15) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(57, 0, 153, 0.18) 0%, transparent 45%),
    linear-gradient(180deg, #05060a 0%, #10121d 100%);
}

/* 전체 게임 가로 컨테이너 */
.game-wrapper {
  width: min(720px, 100% - 1.5rem);
  margin: 1rem auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  background: var(--glass);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 
    0 24px 64px rgba(0, 0, 0, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

/* 1. 아케이드 상단 헤더 */
.arcade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.75rem;
}

.logo-area .badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--neon-cyan);
  text-shadow: 0 0 8px rgba(0, 245, 212, 0.4);
}

.game-title {
  margin: 0.25rem 0 0 0;
  font-family: var(--font-game);
  font-size: 1.15rem;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffbd00, #ff0055);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 2px 8px rgba(255, 189, 0, 0.3));
}

.header-decor {
  display: flex;
  gap: 8px;
}

.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.led.red {
  background-color: var(--led-red);
  box-shadow: 0 0 10px var(--led-red);
}

.led.yellow {
  background-color: #bb9900;
}

.led.green {
  background-color: #007733;
}

@keyframes flash {
  0%, 100% { opacity: 1; filter: brightness(1.2) drop-shadow(0 0 8px var(--led-red)); }
  50% { opacity: 0.4; filter: brightness(0.8); }
}

.led.flashing {
  animation: flash 1s infinite;
}

/* 2. CRT 캐비닛 스크린 프레임 */
.screen-cabinet {
  background-color: #12141c;
  border-radius: 20px;
  padding: 12px;
  box-shadow: 
    inset 0 4px 12px rgba(0, 0, 0, 0.9),
    0 12px 32px rgba(0, 0, 0, 0.5);
  border: 4px solid #1c1f2b;
}

.crt-bezel {
  position: relative;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  border: 10px solid #1a1a1a;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.9);
}

/* CRT 글레어(빛반사 효과) */
.crt-glare {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0.01) 50%, transparent 100%);
  pointer-events: none;
  z-index: 5;
}

/* CRT 주사선 (Scanlines) */
.crt-scanlines {
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
  background-size: 100% 4px, 6px 100%;
  pointer-events: none;
  z-index: 4;
}

/* 3. 게임 실시간 HUD 정보 */
.hud {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background-color: #000;
  padding: 10px;
  border-bottom: 2px solid #222;
  font-family: var(--font-game);
  font-size: 0.5rem;
  text-align: center;
  gap: 4px;
}

@media (max-width: 480px) {
  .hud {
    font-size: 0.4rem;
    padding: 6px;
  }
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hud-label {
  color: #8e909a;
}

.hud-value {
  color: #fff;
  font-weight: bold;
}

/* 4. 캔버스 영역 */
.canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background-color: #5c94fc; /* 마리오 하늘색 기본 배경 */
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: -moz-crisp-edges;
  image-rendering: -webkit-crisp-edges;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* 5. 스크린 오버레이 모달 */
.screen-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(5, 6, 12, 0.9);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10;
  text-align: center;
  padding: 1.5rem;
  backdrop-filter: blur(4px);
}

.screen-overlay[hidden] {
  display: none !important;
}

.overlay-title {
  font-family: var(--font-game);
  font-size: clamp(1.2rem, 4vw, 2rem);
  margin: 0 0 0.5rem 0;
  letter-spacing: 2px;
  color: #fff;
}

.overlay-subtitle {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--neon-cyan);
  letter-spacing: 0.15em;
  margin: 0 0 1.5rem 0;
}

.overlay-desc {
  font-size: 0.9rem;
  line-height: 1.6;
  color: #b0b4c3;
  margin: 0 0 1.5rem 0;
  max-width: 20rem;
}

.text-red {
  color: var(--led-red) !important;
  text-shadow: 0 0 12px rgba(255, 0, 85, 0.4);
}

.text-gold {
  color: var(--neon-gold) !important;
  text-shadow: 0 0 12px rgba(255, 189, 0, 0.4);
}

.instructions-panel {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  max-width: 24rem;
}

.key-guide {
  font-size: 0.75rem;
  line-height: 1.6;
  color: #a0a5b5;
  margin: 4px 0;
  text-align: left;
}

.clear-rewards {
  font-family: var(--font-game);
  font-size: 0.6rem;
  color: #fff;
  line-height: 2;
  margin-bottom: 1.5rem;
  text-align: left;
}

.btn-play {
  padding: 0.8rem 2.5rem;
  font-family: var(--font-ui);
  font-weight: bold;
  font-size: 1rem;
  color: #05060a;
  background: linear-gradient(135deg, #ffbd00 0%, #ff8800 100%);
  border: none;
  border-radius: 30px;
  cursor: pointer;
  box-shadow: 
    0 4px 15px rgba(255, 136, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all 0.2s ease;
}

.btn-play:hover {
  transform: translateY(-2px);
  filter: brightness(1.1);
  box-shadow: 
    0 6px 20px rgba(255, 136, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-play:active {
  transform: translateY(1px);
}

/* 마리오 글자 위아래 통통 튀는 애니메이션 */
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.bounce-anim {
  animation: bounce 2s infinite ease-in-out;
}

/* 6. 모바일 가상 조이패드 */
.virtual-controller {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0.5rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 18px;
}

/* 방향패드 (D-PAD) */
.dpad {
  display: flex;
  gap: 12px;
}

.ctrl-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 58px;
  height: 58px;
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 1.15rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.1s ease;
}

.dpad .ctrl-btn {
  background: radial-gradient(circle at 35% 35%, #3d414a, #1b1d22);
  box-shadow: 
    0 4px 10px rgba(0, 0, 0, 0.5),
    inset 0 2px 2px rgba(255, 255, 255, 0.1),
    inset 0 -4px 6px rgba(0, 0, 0, 0.4);
}

.dpad .ctrl-btn:active {
  background: #1b1d22;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
}

/* 액션 버튼그룹 (A, B) */
.action-buttons {
  display: flex;
  gap: 20px;
}

.btn-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.btn-label {
  font-size: 0.55rem;
  font-family: var(--font-game);
  color: #636775;
}

.action-b {
  background: radial-gradient(circle at 35% 35%, #00d9ff, #005a8b) !important;
  box-shadow: 
    0 4px 10px rgba(0, 217, 255, 0.3),
    inset 0 2px 2px rgba(255, 255, 255, 0.3),
    inset 0 -4px 6px rgba(0, 0, 0, 0.4);
}

.action-b:active {
  background: #005a8b !important;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
}

.action-a {
  background: radial-gradient(circle at 35% 35%, #ff3366, #990022) !important;
  box-shadow: 
    0 4px 10px rgba(255, 51, 102, 0.3),
    inset 0 2px 2px rgba(255, 255, 255, 0.3),
    inset 0 -4px 6px rgba(0, 0, 0, 0.4);
}

.action-a:active {
  background: #990022 !important;
  box-shadow: 
    0 2px 4px rgba(0, 0, 0, 0.5),
    inset 0 1px 2px rgba(0, 0, 0, 0.6);
  transform: scale(0.95);
}

/* 7. 푸터 단축키 및 라이센스 정보 */
.arcade-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 0.75rem;
}

.shortcut-info {
  font-size: 0.75rem;
  color: #7b8091;
}

.shortcut-info strong {
  color: var(--neon-cyan);
}

.copyright {
  font-size: 0.65rem;
  color: #4c4f5c;
  letter-spacing: 0.05em;
  margin: 0;
}

/* 데스크탑 조작 시 모바일 가상버튼은 투명도를 낮춤 */
@media (hover: hover) {
  .virtual-controller {
    opacity: 0.75;
    transition: opacity 0.3s ease;
  }
  .virtual-controller:hover {
    opacity: 1;
  }
}

/* 터치 지원 안하는 PC 등 대화면인 경우 컨트롤러가 필요 없는 분들을 위한 반응형 레이아웃 */
@media (min-width: 768px) {
  /* PC에서는 가상패드를 아주 깔끔하고 부담 없게 렌더링 */
}
