* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #1a1a1a;
  position: relative;
  overflow-x: hidden;
  transition: background 0.3s ease;
}

body.light-mode {
  background: #f0f0f0;
}

/* 육각형 격자 배경 - 어두운 버전 */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: linear-gradient(
      30deg,
      #2a2a2a 12%,
      transparent 12.5%,
      transparent 87%,
      #2a2a2a 87.5%,
      #2a2a2a
    ),
    linear-gradient(
      150deg,
      #2a2a2a 12%,
      transparent 12.5%,
      transparent 87%,
      #2a2a2a 87.5%,
      #2a2a2a
    ),
    linear-gradient(
      30deg,
      #2a2a2a 12%,
      transparent 12.5%,
      transparent 87%,
      #2a2a2a 87.5%,
      #2a2a2a
    ),
    linear-gradient(
      150deg,
      #2a2a2a 12%,
      transparent 12.5%,
      transparent 87%,
      #2a2a2a 87.5%,
      #2a2a2a
    ),
    linear-gradient(
      60deg,
      #25252577 25%,
      transparent 25.5%,
      transparent 75%,
      #25252577 75%,
      #25252577
    ),
    linear-gradient(
      60deg,
      #25252577 25%,
      transparent 25.5%,
      transparent 75%,
      #25252577 75%,
      #25252577
    );
  background-size: 80px 140px;
  background-position: 0 0, 0 0, 40px 70px, 40px 70px, 0 0, 40px 70px;
  z-index: 0;
  pointer-events: none;
  transition: background-image 0.3s ease;
}

body.light-mode::before {
  background-image: linear-gradient(
      30deg,
      #e8e8e8 12%,
      transparent 12.5%,
      transparent 87%,
      #e8e8e8 87.5%,
      #e8e8e8
    ),
    linear-gradient(
      150deg,
      #e8e8e8 12%,
      transparent 12.5%,
      transparent 87%,
      #e8e8e8 87.5%,
      #e8e8e8
    ),
    linear-gradient(
      30deg,
      #e8e8e8 12%,
      transparent 12.5%,
      transparent 87%,
      #e8e8e8 87.5%,
      #e8e8e8
    ),
    linear-gradient(
      150deg,
      #e8e8e8 12%,
      transparent 12.5%,
      transparent 87%,
      #e8e8e8 87.5%,
      #e8e8e8
    ),
    linear-gradient(
      60deg,
      #d8d8d877 25%,
      transparent 25.5%,
      transparent 75%,
      #d8d8d877 75%,
      #d8d8d877
    ),
    linear-gradient(
      60deg,
      #d8d8d877 25%,
      transparent 25.5%,
      transparent 75%,
      #d8d8d877 75%,
      #d8d8d877
    );
}

.container {
  max-width: 480px;
  margin: 0 auto;
  background: linear-gradient(to bottom, #0a0a0a, #1a1a1a);
  min-height: 100vh;
  position: relative;
  z-index: 1;
  transition: all 0.3s ease;
}

body.light-mode .container {
  background: white;
}

/* 공통 푸터 */
.site-footer {
  background: rgba(10, 10, 10, 0.8);
  border-top: 1px solid rgba(127, 255, 212, 0.12);
  color: #a8b3af;
  text-align: center;
  padding: 22px 30px 28px;
  font-size: 14px;
}

body.light-mode .site-footer {
  background: #f8fffe;
  border-top-color: rgba(95, 212, 180, 0.2);
  color: #546a64;
}

/* 모드 전환 버튼 */
.theme-toggle {
  position: fixed;
  top: 20px;
  right: calc(50% - 240px + 20px);
  z-index: 1000;
  background: rgba(127, 255, 212, 0.1);
  border: 2px solid rgba(127, 255, 212, 0.3);
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 24px;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.theme-toggle:hover {
  background: rgba(127, 255, 212, 0.2);
  border-color: #7fffd4;
  transform: rotate(180deg) scale(1.1);
}

body.light-mode .theme-toggle {
  background: rgba(95, 212, 180, 0.15);
  border-color: rgba(95, 212, 180, 0.4);
}

@media (max-width: 768px) {
  .theme-toggle {
    right: 20px;
  }
}

section {
  padding: 100px 30px;
  position: relative;
}

/* 인사말 섹션 */
#greeting {
  background: linear-gradient(165deg, #000 0%, #1a1a1a 100%);
  text-align: center;
  padding: 200px 30px 140px;
  position: relative;
  overflow: hidden;
  transition: background 0.3s ease;
}

body.light-mode #greeting {
  background: linear-gradient(135deg, #7fffd4 0%, #5fd4b4 100%);
}

#greeting::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(127, 255, 212, 0.1) 0%,
    transparent 70%
  );
  animation: pulse 4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

.avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: linear-gradient(135deg, #7fffd4, #40e0d0);
  margin: 0 auto 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 1;
  animation: float 3s ease-in-out infinite;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

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

#greeting h1 {
  color: #7fffd4;
  font-size: 28px;
  margin-bottom: 0;
  position: relative;
  z-index: 1;
  font-weight: 600;
  transition: color 0.3s ease;
}

body.light-mode #greeting h1 {
  color: white;
}

/* 소개 섹션 */
#about {
  background: rgba(20, 20, 20, 0.5);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(127, 255, 212, 0.1);
  transition: all 0.3s ease;
}

body.light-mode #about {
  background: white;
  border-top: 1px solid rgba(95, 212, 180, 0.2);
}

h2 {
  color: #7fffd4;
  font-size: 26px;
  margin-bottom: 25px;
  padding-left: 15px;
  border-left: 4px solid #7fffd4;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-weight: 600;
  transition: all 0.3s ease;
}

body.light-mode h2 {
  color: #3da88f;
  border-left-color: #3da88f;
}

#about p {
  color: #c0c0c0;
  line-height: 2;
  font-size: 16px;
  margin-bottom: 0;
  padding-left: 15px;
  transition: color 0.3s ease;
}

body.light-mode #about p {
  color: #555;
}

/* 포트폴리오 섹션 */
#portfolio {
  background: rgba(10, 10, 10, 0.8);
  border-top: 1px solid rgba(127, 255, 212, 0.1);
  transition: all 0.3s ease;
}

body.light-mode #portfolio {
  background: #f8fffe;
  border-top: 1px solid rgba(95, 212, 180, 0.2);
}

.project {
  background: linear-gradient(
    135deg,
    rgba(127, 255, 212, 0.05),
    rgba(64, 224, 208, 0.05)
  );
  padding: 25px;
  margin-bottom: 20px;
  border-radius: 15px;
  border: 1px solid rgba(127, 255, 212, 0.2);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  transition: all 0.4s ease;
  position: relative;
  overflow: hidden;
}

body.light-mode .project {
  background: white;
  border: 1px solid rgba(95, 212, 180, 0.3);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}

body.light-mode .project:hover {
  border-color: #5fd4b4;
  box-shadow: 0 5px 15px rgba(95, 212, 180, 0.3);
}

.project::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(127, 255, 212, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.project:hover::before {
  left: 100%;
}

.project:hover {
  transform: translateY(-5px);
  border-color: #7fffd4;
  box-shadow: 0 10px 30px rgba(127, 255, 212, 0.2);
}

.project h3 {
  color: #7fffd4;
  font-size: 20px;
  margin-bottom: 12px;
  font-weight: 600;
  transition: color 0.3s ease;
}

body.light-mode .project h3 {
  color: #5fd4b4;
}

.project p {
  color: #a0a0a0;
  line-height: 1.7;
  font-size: 15px;
  transition: color 0.3s ease;
}

body.light-mode .project p {
  color: #666;
}

/* (removed avatar-badge) */

/* (removed notebook icon for project titles) */

/* 연락처 섹션 */
#contact {
  background: linear-gradient(165deg, #0a0a0a 0%, #000 100%);
  border-top: 1px solid rgba(127, 255, 212, 0.1);
  padding-bottom: 160px;
  transition: all 0.3s ease;
}

body.light-mode #contact {
  background: linear-gradient(135deg, #5fd4b4 0%, #7fffd4 100%);
  border-top: 1px solid rgba(95, 212, 180, 0.2);
}

#contact h2 {
  text-align: left;
}

.contact-info {
  margin-top: 35px;
}

.contact-item {
  background: rgba(127, 255, 212, 0.05);
  padding: 20px;
  margin-bottom: 15px;
  border-radius: 12px;
  border: 1px solid rgba(127, 255, 212, 0.2);
  color: #c0c0c0;
  font-size: 16px;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

body.light-mode .contact-item {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  color: #555;
}

body.light-mode .contact-item:hover {
  background: rgba(255, 255, 255, 0.4);
  border-color: white;
}

.contact-item::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(127, 255, 212, 0.1);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.4s ease, height 0.4s ease;
}

.contact-item:hover::before {
  width: 300px;
  height: 300px;
}

.contact-item:hover {
  border-color: #7fffd4;
  transform: scale(1.02);
  box-shadow: 0 5px 20px rgba(127, 255, 212, 0.2);
}

.contact-item strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  color: #7fffd4;
  text-transform: uppercase;
  letter-spacing: 1px;
  position: relative;
  z-index: 1;
  transition: color 0.3s ease;
}

body.light-mode .contact-item strong {
  color: #2a7a6a;
}

/* 게임 섹션 */
#game {
  background: rgba(15, 15, 15, 0.6);
  border-top: 1px solid rgba(127, 255, 212, 0.1);
  transition: all 0.3s ease;
}

body.light-mode #game {
  background: white;
  border-top: 1px solid rgba(95, 212, 180, 0.2);
}

/* 섹션 여백 확대 (About/Portfolio/Game) */
#about,
#portfolio,
#game {
  padding: 150px 30px;
}

.game-container {
  margin-top: 30px;
}

.game-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 20px;
  color: #7fffd4;
  font-size: 16px;
  font-weight: 600;
}

body.light-mode .game-info {
  color: #3da88f;
}

/* AI 제작 노트 */
#game .ai-note {
  color: #7fffd4;
  font-size: 13px;
  text-align: right;
  margin: 12px 15px 0 0; /* 섹션 우측 여백과 정렬 */
  opacity: 0.9;
}

body.light-mode #game .ai-note {
  color: #3da88f;
}

/* Slide Puzzle styles */
.sp-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.sp-controls label {
  color: #a0a0a0;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

body.light-mode .sp-controls label {
  color: #555;
}

.sp-controls select { margin-left: 0; }

/* Slide puzzle preview button */
.sp-preview-btn {
  -webkit-appearance: none;
  appearance: none;
  padding: 10px 14px;
  border-radius: 10px;
  border: 2px solid rgba(127, 255, 212, 0.45);
  background: rgba(127, 255, 212, 0.08);
  color: #7fffd4;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

.sp-preview-btn:hover {
  border-color: #7fffd4;
  background: rgba(127, 255, 212, 0.14);
  transform: translateY(-1px);
}

body.light-mode .sp-preview-btn {
  border-color: rgba(95, 212, 180, 0.55);
  background: rgba(95, 212, 180, 0.12);
  color: #3da88f;
}

/* Slide puzzle image modal */
.sp-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  z-index: 3000;
}

.sp-modal.show { display: flex; }

.sp-modal-content {
  position: relative;
  background: #0f0f0f;
  border: 1px solid rgba(127, 255, 212, 0.35);
  border-radius: 12px;
  padding: 10px;
  max-width: 90vw; /* ensure fits viewport including padding (border-box) */
  max-height: 86vh;
  overflow: hidden; /* prevent child overflow */
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

body.light-mode .sp-modal-content {
  background: #ffffff;
  border-color: rgba(95, 212, 180, 0.35);
}

.sp-modal-content img {
  display: block;
  width: 100%; /* contain within modal content */
  height: auto;
  max-height: 80vh;
  object-fit: contain;
}

.sp-modal-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid rgba(127, 255, 212, 0.45);
  background: rgba(127, 255, 212, 0.08);
  color: #7fffd4;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.light-mode .sp-modal-close {
  border-color: rgba(95, 212, 180, 0.55);
  background: rgba(95, 212, 180, 0.12);
  color: #3da88f;
}

/* Pretty select (dark) */
.ui-select {
  -webkit-appearance: none;
  appearance: none;
  background-color: rgba(127, 255, 212, 0.08);
  border: 2px solid rgba(127, 255, 212, 0.35);
  color: #7fffd4;
  padding: 10px 36px 10px 12px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%237fffd4'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}

.ui-select:hover {
  border-color: #7fffd4;
}

.ui-select:focus-visible {
  box-shadow: 0 0 0 3px rgba(127, 255, 212, 0.25);
}

/* Pretty select (light) */
body.light-mode .ui-select {
  background-color: rgba(95, 212, 180, 0.1);
  border-color: rgba(95, 212, 180, 0.45);
  color: #3da88f;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%233da88f'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
}

/* 2048 styles */
/* 2048 styles removed */

body.light-mode .ui-select:hover {
  border-color: #3da88f;
}

body.light-mode .ui-select:focus-visible {
  box-shadow: 0 0 0 3px rgba(95, 212, 180, 0.25);
}

.sp-board {
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid rgba(127, 255, 212, 0.3);
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  gap: 4px;
  background: rgba(127, 255, 212, 0.05);
}

body.light-mode .sp-board {
  border-color: rgba(95, 212, 180, 0.4);
  background: rgba(95, 212, 180, 0.06);
}

.sp-shuffle-btn { margin-top: 12px; }

.sp-tile {
  background-size: 100% 100%;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #e0fff6;
  font-weight: 700;
  user-select: none;
  cursor: pointer;
  background-color: rgba(127, 255, 212, 0.08);
  transition: transform 0.15s ease;
}

body.light-mode .sp-tile {
  color: #2a7a6a;
  background-color: rgba(95, 212, 180, 0.12);
}

.sp-tile:hover {
  transform: scale(1.02);
}

.sp-empty {
  background: transparent !important;
  cursor: default;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.card {
  aspect-ratio: 1;
  background: linear-gradient(
    135deg,
    rgba(127, 255, 212, 0.1),
    rgba(64, 224, 208, 0.1)
  );
  border: 2px solid rgba(127, 255, 212, 0.3);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  transform-style: preserve-3d;
  perspective: 1000px;
}

body.light-mode .card {
  background: linear-gradient(135deg, #e8f8f5, #d4f1e8);
  border-color: rgba(95, 212, 180, 0.4);
}

.card.disabled {
  pointer-events: none;
}

.card:hover:not(.flipped):not(.matched):not(.disabled) {
  transform: scale(1.05);
  border-color: #7fffd4;
  box-shadow: 0 5px 20px rgba(127, 255, 212, 0.3);
}

body.light-mode .card:hover:not(.flipped):not(.matched):not(.disabled) {
  border-color: #5fd4b4;
  box-shadow: 0 5px 15px rgba(95, 212, 180, 0.3);
}

.card.flipping {
  animation: flip 0.6s ease-in-out;
}

@keyframes flip {
  0% {
    transform: rotateY(0deg);
  }
  50% {
    transform: rotateY(90deg);
  }
  100% {
    transform: rotateY(0deg);
  }
}

.card.flipped,
.card.matched {
  background: linear-gradient(
    135deg,
    rgba(127, 255, 212, 0.2),
    rgba(64, 224, 208, 0.2)
  );
  border-color: #7fffd4;
}

body.light-mode .card.flipped,
body.light-mode .card.matched {
  background: linear-gradient(135deg, #7fffd4, #5fd4b4);
  border-color: #3da88f;
}

.card.matched {
  opacity: 0.6;
  cursor: default;
}

.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(127, 255, 212, 0.3);
  font-size: 24px;
}

body.light-mode .card-back {
  color: rgba(95, 212, 180, 0.5);
}

.card-front {
  display: none;
}

.card.flipped .card-back,
.card.matched .card-back {
  display: none;
}

.card.flipped .card-front,
.card.matched .card-front {
  display: flex;
}

.reset-btn {
  width: 100%;
  padding: 15px;
  background: linear-gradient(
    135deg,
    rgba(127, 255, 212, 0.2),
    rgba(64, 224, 208, 0.2)
  );
  border: 2px solid #7fffd4;
  border-radius: 12px;
  color: #7fffd4;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

body.light-mode .reset-btn {
  background: linear-gradient(135deg, #7fffd4, #5fd4b4);
  border-color: #3da88f;
  color: white;
}

.reset-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 20px rgba(127, 255, 212, 0.4);
}

body.light-mode .reset-btn:hover {
  box-shadow: 0 5px 15px rgba(95, 212, 180, 0.4);
}

.more-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: transparent;
  border: 2px solid rgba(127, 255, 212, 0.6);
  border-radius: 12px;
  color: #7fffd4;
  text-decoration: none;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  margin-top: 12px;
}

body.light-mode .more-btn {
  background: transparent;
  border-color: #3da88f;
  color: #3da88f;
}

/* Extra spacing for Games page Home button at bottom */
.games-home-btn {
  margin-top: 28px;
}

.more-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(127, 255, 212, 0.25);
}

.more-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(127, 255, 212, 0.35);
}

body.light-mode .more-btn:hover {
  box-shadow: 0 5px 12px rgba(95, 212, 180, 0.3);
}

/* 토스트 알림 */
.contact-item a {
  color: inherit;
  text-decoration: none;
}
.contact-item a:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%) translateY(120%);
  width: calc(100% - 60px);
  max-width: 480px;
  background: linear-gradient(
    135deg,
    rgba(8, 32, 28, 0.96),
    rgba(6, 20, 18, 0.96)
  );
  color: #eaeaea;
  backdrop-filter: blur(8px);
  padding: 16px 20px;
  border-radius: 12px;
  border: 1px solid rgba(127, 255, 212, 0.35);
  box-shadow: 0 10px 30px rgba(64, 224, 208, 0.12), 0 6px 18px rgba(0, 0, 0, 0.4);
  z-index: 2000;
  transition: transform 0.35s ease, opacity 0.35s ease, box-shadow 0.35s ease;
  text-align: center;
  opacity: 0;
  overflow: hidden;
}

body.light-mode .toast {
  background: linear-gradient(135deg, #ffffff, #f6fffc);
  color: #333;
  border-color: rgba(95, 212, 180, 0.35);
  box-shadow: 0 8px 24px rgba(95, 212, 180, 0.2), 0 6px 18px rgba(0, 0, 0, 0.1);
}

.toast::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, #7fffd4, #40e0d0);
  opacity: 0.9;
}

.toast.show {
  transform: translateX(-50%) translateY(-30px);
  opacity: 1;
}

.toast-message {
  font-size: 18px;
  color: inherit;
  line-height: 1.5;
  font-weight: 600;
}

.contact-item span {
  position: relative;
  z-index: 1;
}

@media (max-width: 480px) {
  body::before {
    display: none;
  }

  .container {
    box-shadow: none;
  }
}

/* 스크롤 애니메이션 */
section {
  opacity: 0;
  animation: fadeInUp 0.8s ease-out forwards;
}

#greeting {
  animation-delay: 0s;
}
#about {
  animation-delay: 0.2s;
}
#portfolio {
  animation-delay: 0.4s;
}
#contact {
  animation-delay: 0.6s;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
