/* 노키아 스네이크 게임 스타일 */
@font-face { 
  font-family: "nokia"; 
  src: url("../fonts/nokiafc.ttf"); 
}

/* 스네이크 게임 전용 스타일 - magic8ball 구조 참고 */
* {
  box-sizing: border-box;
}

html, body {
  margin: 0 !important;
  padding: 0 !important;
  height: 100% !important;
  background: rgb(18, 65, 145) !important;
  /* font-family: "nokia", monospace !important; */
  overflow: hidden !important;
}

/* PC용 - 사이드바가 있을 때 */
body {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding-left: 0; /* 기본값 - 사이드바 없음 */
  padding-top: 0; /* 기본값 - 상단바 없음 */
  min-height: 100vh !important;
  gap: 10px;
}

/* 사이드바가 있는 경우 (PC 넓은 화면) */
@media (min-width: 1024px) {
  body {
    padding-left: 250px; /* 사이드바 너비 */
    padding-top: 15px;
    padding-bottom: 15px;
    justify-content: flex-start;
    overflow-y: auto;
    gap: 10px;
  }
  
  .snake-game-screen {
    transform: scale(1.0);
    transform-origin: center;
  }
  
  .snake-game-screen-wrapper {
    margin: 10px 0;
  }
  
  .snake-game-controls {
    margin-top: 10px;
    margin-bottom: 10px;
  }
  
  .snake-game-info {
    margin: 10px 0;
  }
  
  .snake-page-title {
    margin-bottom: 10px;
    font-size: clamp(22px, 3vw, 32px);
    padding: 5px 0 5px 0;
  }
}

/* 상단바가 있는 경우 (모바일 또는 좁은 화면) */
@media (max-width: 1023px) {
  body {
    padding-left: 0;
    padding-top: 60px; /* 상단바 높이 */
    min-height: calc(100vh - 60px) !important;
  }
  
  .snake-game-screen {
    width: min(340px, 95vw);
    transform: scale(min(1, calc(95vw / 340px)));
    transform-origin: center;
  }
}

.snake-game-container {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  justify-items: center;
  height: 100%;
  width: 100vw;
  background-color: rgb(18, 65, 145);
  font-family: "nokia", monospace;
  font-size: 12px;
  color: #000;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.snake-game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.snake-game-screen-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 20px 0;
  flex-shrink: 0;
}

.snake-game-footer {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
}

/* 페이지 타이틀 */
.snake-page-title {
  color: #EEEEEE !important;
  text-align: center;
  font-family: "nokia", monospace;
  font-size: clamp(22px, 5vw, 30px);
  font-weight: bold;
  margin: 0;
  padding: 20px 0 10px 0;
  width: 100%;
  flex-shrink: 0;
}

.snake-game-screen {
  width: 334px; /* 최소 여백: 8px(좌) + 320px(콘텐츠) + 6px(우) = 334px */
  height: 196px; /* 최소 여백: 8px + 점수영역(38px) + 게임영역(150px) = 196px */
  background-color: #9bba5a;
  border: 4px solid #000;
  position: relative;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  margin: 0 auto;
}

.snake-game-area {
  width: 320px; /* JavaScript 그리드와 정확히 일치: 20 × 16px = 320px */
  height: 144px; /* JavaScript 그리드와 정확히 일치: 9 × 16px = 144px */
  position: absolute;
  top: 37px; /* 점수 표시 영역 바로 아래 (4px + 30px + 3px) */
  left: 50%;
  transform: translateX(-50%); /* 중앙 정렬 */
  margin: 0 auto; /* 좌우 여백 균등하게 */

  background-color: #9bba5a;
  border: 3px solid #000; /* 모든 면에 3px 두께 테두리 */
  
  /* Canvas 픽셀 아트 최적화 */
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  image-rendering: -webkit-optimize-contrast;
}

.snake-game-cell {
  width: 16px;
  height: 16px;
  position: absolute;
  background: url('/images/snake_sprite.png') -100px -100px;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* 스네이크 부분들 - 스프라이트 좌표 */

/* 스네이크 머리 */
.head-up { background-position: 0px 0px; }
.head-right { background-position: 0px -17px; }
.head-down { background-position: 0px -34px; }
.head-left { background-position: 0px -51px; }

/* 스네이크 몸통 */
.body-up { background-position: -34px 0px; }
.body-right { background-position: -34px -17px; }
.body-down { background-position: -34px -34px; }
.body-left { background-position: -34px -51px; }

/* 스네이크 꼬리 */
.tail-up { background-position: -51px 0px; }
.tail-right { background-position: -51px -17px; }
.tail-down { background-position: -51px -34px; }
.tail-left { background-position: -51px -51px; }

/* 스네이크 코너 */
.corner-upright { background-position: -85px 0px; }
.corner-upleft { background-position: -85px -17px; }
.corner-downright { background-position: -85px -34px; }
.corner-downleft { background-position: -85px -51px; }
.corner-rightup { background-position: -102px 0px; }
.corner-rightdown { background-position: -102px -17px; }
.corner-leftup { background-position: -102px -34px; }
.corner-leftdown { background-position: -102px -51px; }

/* 음식 */
.food { background-position: -153px 0px; }

/* 스네이크 bola 효과 (음식을 먹었을 때) */
.body-up.bola { background-position: -68px 0px; }
.body-right.bola { background-position: -68px -17px; }
.body-down.bola { background-position: -68px -34px; }
.body-left.bola { background-position: -68px -51px; }

.corner-upright.bola { background-position: -119px 0px; }
.corner-upleft.bola { background-position: -119px -17px; }
.corner-downright.bola { background-position: -119px -34px; }
.corner-downleft.bola { background-position: -119px -51px; }
.corner-rightup.bola { background-position: -136px 0px; }
.corner-rightdown.bola { background-position: -136px -17px; }
.corner-leftup.bola { background-position: -136px -34px; }
.corner-leftdown.bola { background-position: -136px -51px; }

/* 아이템 (버그) - 원본 사이트 좌표 */
.bixo.a1 { background-position: -153px -32px; }
.bixo.b1 { background-position: -170px -32px; }
.bixo.a2 { background-position: -187px -32px; }
.bixo.b2 { background-position: -204px -32px; }
.bixo.a3 { background-position: -221px -32px; }
.bixo.b3 { background-position: -238px -32px; }
.bixo.a4 { background-position: -255px -32px; }
.bixo.b4 { background-position: -272px -32px; }
.bixo.a5 { background-position: -289px -32px; }
.bixo.b5 { background-position: -306px -32px; }

/* 점수 표시 - 노키아 3310 스타일 */
.snake-score-display {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%); /* 중앙 정렬 */
  height: 30px; /* 점수 표시 영역 높이 */
  width: 320px; /* 게임 영역과 정확히 동일한 크기 */
  font-family: "nokia", monospace;
  font-size: 16px;
  font-weight: bold;
  color: #000;
  z-index: 5;
  border-bottom: 3px solid #000; /* 점수영역과 게임영역 사이 구분선만 */
  background-color: #9bba5a;
  display: flex;
  align-items: center;
  padding: 0 8px;
  box-sizing: border-box; /* 패딩과 보더를 포함한 크기 계산 */
}

/* 아이템 타이머 표시 */
.snake-bug-timer {
  position: absolute;
  top: 4px;
  right: 12px;
  height: 30px;
  font-family: "nokia", monospace;
  font-size: 16px;
  font-weight: bold;
  color: #000;
  z-index: 10;
  display: none;
  align-items: center;
  padding: 0 8px;
}

.snake-score-left {
  display: inline-block;
}

.snake-score-right {
  display: none;
}

.snake-score-digit {
  display: inline;
  font-family: "nokia", monospace;
  font-size: 14px;
  font-weight: bold;
  color: #000;
}



/* 메뉴 화면 */
.snake-menu-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background-color: #9bba5a;
  z-index: 10;
}

.snake-logo {
  margin-top: 25px;
  margin-bottom: 25px;
}

.snake-logo img {
  max-width: 180px !important;
  height: auto !important;
}

.snake-difficulty-menu {
  display: flex;
  flex-direction: row;
  gap: 30px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 0px;
}

.snake-menu-item {
  display: flex;
  align-items: center;
  font-family: "nokia", monospace;
  font-size: 16px;
  color: #000;
  cursor: pointer;
  padding: 5px;
}

.snake-menu-item .arrow {
  margin-right: 5px;
  font-weight: bold;
  visibility: hidden;
}

.snake-menu-item.selected .arrow {
  visibility: visible;
}

.snake-menu-item:hover {
  color: #2d4a2d;
}

/* 게임 오버 화면 */
.snake-game-over-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(155, 186, 90, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  z-index: 20;
}

.snake-game-over-text {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 20px;
  color: #000;
}

.snake-final-score {
  font-size: 16px;
  margin-bottom: 20px;
  color: #000;
}

/* 기존 복잡한 모바일 미디어 쿼리들은 제거 - 위의 통합 쿼리로 대체 */

/* 터치 버튼 (모바일용) - 방향키 모양 */
.snake-mobile-controls {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 280px; /* 더 넓게 조정 */
  height: 200px; /* 더 높게 조정 */
  z-index: 1000;
}

.snake-touch-button {
  width: 80px;
  height: 80px;
  background-color: rgba(18, 65, 145, 0.5); /* 더 투명하게 조정 */
  border: 2px solid rgba(255, 255, 255, 0.7);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px; /* 폰트 크기 증가 */
  color: #fff;
  cursor: pointer;
  user-select: none;
  position: absolute;
  font-weight: bold;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}

.snake-touch-button:active {
  background-color: rgba(18, 65, 145, 0.8);
  transform: scale(0.95);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* 방향키 배치 */
.snake-touch-button[data-direction="up"] {
  top: 0;
  left: 50%;
  transform: translateX(-50%);
}

.snake-touch-button[data-direction="left"] {
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

.snake-touch-button[data-direction="right"] {
  top: 50%;
  right: 0;
  transform: translateY(-50%);
}

.snake-touch-button[data-direction="down"] {
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}

@media (max-width: 768px) {
  body {
    flex-direction: column;
    justify-content: flex-start;
    gap: 10px;
    padding-bottom: 20px;
  }
  
  .snake-mobile-controls {
    display: block;
    position: fixed !important;
    bottom: 20px !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 1000 !important;
  }
  
  .snake-game-info {
    margin-top: 15px;
    margin-bottom: 20px;
    order: 3;
  }
  
  .snake-control-button {
    width: 80px;
    height: 40px;
    font-size: 14px;
    padding: 5px 8px;
  }
  
  .snake-game-controls {
    position: relative;
    margin-top: 10px;
    order: 2;
  }
  
  .snake-game-screen-wrapper {
    order: 1;
  }
  
  .snake-page-title {
    padding: 5px 0 5px 0;
    font-size: clamp(22px, 4.5vw, 24px);
  }
}

/* 숨김 클래스 */
.snake-hidden {
  display: none !important;
}

/* 애니메이션 */
.snake-blink {
  animation: snake-blink 0.5s infinite;
}

@keyframes snake-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* 게임 컨트롤 버튼 */
.snake-game-controls {
  position: relative;
  display: flex;
  gap: 15px;
  z-index: 30;
  justify-content: center;
  margin-top: 15px;
  flex-shrink: 0;
}

.snake-control-button {
  height: 40px;
  padding: 8px 12px;
  background-color: #9bba5a;
  border: 2px solid #000;
  border-radius: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #000;
  cursor: pointer;
  font-family: "nokia", monospace;
  font-weight: bold;
  white-space: nowrap;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

.snake-control-button:hover {
  background-color: #8aa84a;
}

.snake-control-button:active {
  background-color: #7a983a;
}

/* 게임 정보 표시 */
.snake-game-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  margin: 15px 0;
  height: auto;
  text-align: center;
  font-size: 16px;
  color: #EEEEEE;
  font-family: "nokia", monospace;
  flex-shrink: 0;
}

.snake-difficulty-info {
  font-size: 16px;
  margin-bottom: 5px;
  font-weight: bold;
}

.snake-best-scores-info {
  font-size: 14px;
  margin-bottom: 5px;
  line-height: 1.4;
}

.snake-best-scores-table {
  margin: 5px auto;
  font-size: 14px;
}

.snake-best-scores-table table {
  border-collapse: collapse;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
  color: #FFFFFF;
  border: 1px solid #FFFFFF;
  table-layout: fixed;
}

.snake-best-scores-table th,
.snake-best-scores-table td {
  padding: 2px 4px;
  text-align: center;
  border: 1px solid #FFFFFF;
}

.snake-best-scores-table th {
  background-color: rgba(155, 186, 90, 0.5);
  font-weight: bold;
  padding: 3px 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.snake-best-scores-table thead tr:first-child th {
  background-color: rgba(155, 186, 90, 0.7);
  border-bottom: none;
}

.snake-best-scores-table thead tr:first-child th:first-child {
  border-right: none;
}

.snake-best-scores-table tr:hover {
  background-color: rgba(155, 186, 90, 0.2);
}

.snake-best-scores-section {
  text-align: center;
  margin-bottom: 10px;
}

/* 게임 모드 섹션 */
.snake-game-mode-section {
  width: 100%;
  margin-bottom: 10px;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 5px;
}

.snake-game-mode-title {
  font-size: 16px;
  font-weight: bold;
  color: #FFFFFF;
}

.snake-game-mode-options {
  display: flex;
  flex-direction: row;
  gap: 10px;
  justify-content: center;
}

.snake-game-mode-option {
  cursor: pointer;
  padding: 0px 5px;
  transition: all 0.2s ease;
}

.snake-game-mode-option.selected span,
.snake-game-mode-option.hover span {
  font-weight: bold;
}

.snake-game-mode-option:hover {
  color: #9bba5a;
}

.snake-best-scores-title {
  font-size: 16px;
  font-weight: bold;
  margin-bottom: 8px;
  color: #FFFFFF;
}

.snake-best-scores-info div {
  margin-bottom: 2px;
}

.snake-controls-info {
  margin-top: 10px;
  font-size: 16px;
  opacity: 0.9;
  font-family: "nokia", monospace;
}

@media (max-width: 768px) {
  .snake-controls-info {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .snake-controls-info {
    font-size: 12px;
  }
} 