/* ========================================
   Neon Block Puzzle - styles.css
   ======================================== */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Roboto:wght@400;700&display=swap');

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

body {
  overflow: hidden;
  background-color: #020617;
  font-family: 'Roboto', sans-serif;
  touch-action: none;
  color: #fff;
}

.font-orbitron {
  font-family: 'Orbitron', sans-serif;
}

/* ========== Layout ========== */
.game-container {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background-image:
    radial-gradient(circle at 50% 50%, rgba(30, 64, 175, 0.1) 0%, transparent 80%),
    linear-gradient(rgba(15, 23, 42, 0.95), rgba(15, 23, 42, 0.95));
  overflow: hidden;
}

/* Background grid overlay */
.bg-grid-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.1;
  pointer-events: none;
}
.bg-grid-inner {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  height: 100%;
  width: 100%;
}
.bg-grid-cell {
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ========== Header / Score ========== */
.header {
  width: 100%;
  max-width: 448px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  z-index: 10;
}
.score-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-family: 'Orbitron', sans-serif;
}
.score-label-best {
  color: #60a5fa;
}
.score-label-score {
  color: #22d3ee;
}
.score-value {
  font-size: 1.875rem;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}
.score-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Mute Button */
.mute-btn {
  background: none;
  border: none;
  padding: 8px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: color 0.2s;
}
.mute-btn:hover {
  color: #fff;
}
.mute-btn svg {
  display: block;
}

/* ========== Game Grid ========== */
.grid-wrapper {
  position: relative;
  width: 100%;
  max-width: 448px;
  aspect-ratio: 1 / 1;
  z-index: 10;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 2px;
  background-color: rgba(15, 23, 42, 0.5);
  padding: 4px;
  border: 2px solid rgba(30, 58, 138, 0.5);
  border-radius: 8px;
  box-shadow: 0 25px 50px -12px rgba(30, 58, 138, 0.2);
  height: 100%;
  width: 100%;
  position: relative;
  overflow: hidden;
}
.game-grid.grid-shake {
  animation: shake 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.grid-cell-wrapper {
  position: relative;
  aspect-ratio: 1 / 1;
}

/* ========== Block Cells ========== */
.block-cell {
  position: relative;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.3);
  background-color: rgba(15, 23, 42, 0.4);
  border-radius: 2px;
}

.block-filled {
  position: relative;
  width: 100%;
  height: 100%;
  border-width: 2px;
  border-style: solid;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275),
              top 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.block-filled::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px; right: 2px; bottom: 2px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%, 0% 0%, 50% 50%, 0% 0%);
}
.block-filled::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 50%, rgba(0,0,0,0.2) 100%);
}

/* Inner decorative lines */
.block-inner-decor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.block-inner-line1 {
  position: absolute;
  width: 141%;
  height: 1px;
  background: rgba(255,255,255,0.2);
  transform: rotate(45deg);
  top: 0;
  left: 0;
}
.block-inner-line2 {
  position: absolute;
  width: 141%;
  height: 1px;
  background: rgba(255,255,255,0.2);
  transform: rotate(-45deg);
  top: 100%;
  left: 0;
  transform-origin: bottom left;
}

/* Ghost piece */
.block-ghost {
  opacity: 0.4;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Clearing animation */
.block-clearing {
  animation: block-shatter 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  z-index: 20;
  transform: scale(1.25);
  filter: brightness(1.5);
}

/* ========== Color Classes ========== */
.color-blue     { background-color: #2563eb; border-color: #60a5fa; }
.color-purple   { background-color: #9333ea; border-color: #c084fc; }
.color-orange   { background-color: #f97316; border-color: #fdba74; }
.color-green    { background-color: #22c55e; border-color: #86efac; }
.color-red      { background-color: #dc2626; border-color: #f87171; }
.color-cyan     { background-color: #22d3ee; border-color: #a5f3fc; }
.color-yellow   { background-color: #facc15; border-color: #fef08a; }

/* ========== Game Over Overlay ========== */
.game-over-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(2, 6, 23, 0.8);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  z-index: 50;
  border: 2px solid rgba(239, 68, 68, 0.3);
}
.game-over-title {
  font-size: 2rem;
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  color: #ef4444;
  margin-bottom: 8px;
  letter-spacing: 0.15em;
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.game-over-score {
  font-size: 1.25rem;
  font-family: 'Orbitron', sans-serif;
  color: rgba(255,255,255,0.8);
  margin-bottom: 32px;
}
.play-again-btn {
  padding: 12px 32px;
  background-color: #2563eb;
  color: #fff;
  font-family: 'Orbitron', sans-serif;
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.4);
  transition: all 0.2s;
  font-size: 1rem;
}
.play-again-btn:hover {
  background-color: #3b82f6;
}
.play-again-btn:active {
  transform: scale(0.95);
}

/* ========== Piece Tray ========== */
.piece-tray {
  width: 100%;
  max-width: 448px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 192px;
  padding: 16px 0;
  z-index: 10;
}
.piece-container {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  transition: all 0.2s;
}
.piece-container:hover {
  transform: scale(1.1);
}
.piece-container:active {
  cursor: grabbing;
  transform: scale(0.95);
}
.piece-container.dragging {
  opacity: 0;
  transform: scale(0.5);
  pointer-events: none;
}
.piece-container.disabled {
  filter: grayscale(1);
  opacity: 0.5;
  pointer-events: none;
}

.piece-grid {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.piece-row {
  display: flex;
  gap: 2px;
}
.piece-cell {
  width: 20px;
  height: 20px;
}

/* ========== Dragging Piece (Floating) ========== */
.drag-piece-float {
  position: fixed;
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%) scale(1.3);
  opacity: 0.9;
  filter: drop-shadow(0 0 20px rgba(255,255,255,0.5));
}
.drag-piece-float .piece-cell {
  width: 32px;
  height: 32px;
}

/* ========== Combo Text ========== */
.combo-container {
  position: absolute;
  top: -40px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 60;
}
.combo-text {
  font-size: 2.25rem;
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  color: #22d3ee;
  animation: combo-popup 1.2s ease-out forwards;
  text-shadow: 0 0 15px rgba(34, 211, 238, 0.8);
}

/* ========== Reset Button ========== */
.reset-bar {
  width: 100%;
  max-width: 448px;
  display: flex;
  justify-content: center;
  padding-bottom: 16px;
  z-index: 10;
}
.reset-btn {
  background: none;
  border: none;
  padding: 12px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.reset-btn:hover {
  color: #fff;
}
.reset-btn span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-family: 'Orbitron', sans-serif;
}

/* ========== Animations ========== */
@keyframes block-shatter {
  0% { transform: scale(1); opacity: 1; filter: brightness(2); }
  50% { transform: scale(1.3); opacity: 0.8; filter: brightness(4); }
  100% { transform: scale(0); opacity: 0; filter: brightness(1); }
}

@keyframes combo-popup {
  0% { transform: scale(0.5) translateY(20px); opacity: 0; }
  20% { transform: scale(1.2) translateY(-10px); opacity: 1; }
  80% { transform: scale(1) translateY(-15px); opacity: 1; }
  100% { transform: scale(0.8) translateY(-30px); opacity: 0; }
}

@keyframes shake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== Responsive ========== */
@media (min-width: 768px) {
  .piece-cell {
    width: 24px;
    height: 24px;
  }
}

/* 닉네임 입력창 스타일 */
.leaderboard-input-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
  width: 80%;
  max-width: 250px;
}

#nickname-input {
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid #22d3ee;
  border-radius: 4px;
  color: #fff;
  padding: 10px;
  text-align: center;
  font-size: 1rem;
  outline: none;
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.3);
}

#nickname-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.submit-score-btn {
  padding: 10px;
  background-color: #059669; /* 녹색 계열 */
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: 'Orbitron', sans-serif;
  transition: all 0.2s;
}

.submit-score-btn:hover {
  background-color: #10b981;
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.5);
}

.submit-score-btn:disabled {
  background-color: #4b5563;
  cursor: not-allowed;
  box-shadow: none;
}

/* 리더보드 팝업 전체 배경 */
.leaderboard-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.3s ease-out;
}

/* 팝업 박스 */
.leaderboard-content {
  width: 85%;
  max-width: 320px;
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid #22d3ee;
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  box-shadow: 0 0 20px rgba(34, 211, 238, 0.4);
}

.leaderboard-title {
  font-family: 'Orbitron', sans-serif;
  color: #22d3ee;
  font-size: 1.5rem;
  margin-bottom: 20px;
  text-shadow: 0 0 10px rgba(34, 211, 238, 0.6);
}

/* 리더보드 리스트 아이템 */
.rank-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 5px;
  border-bottom: 1px solid rgba(34, 211, 238, 0.2);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
}

.rank-item:last-child { border-bottom: none; }
.rank-number { color: #60a5fa; width: 30px; text-align: left; }
.rank-name { flex-grow: 1; text-align: left; color: #fff; }
.rank-score { color: #facc15; font-weight: bold; }

/* 닫기 버튼 */
.close-modal-btn {
  margin-top: 25px;
  padding: 10px 30px;
  background: transparent;
  border: 1px solid #60a5fa;
  color: #60a5fa;
  font-family: 'Orbitron', sans-serif;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}
.close-modal-btn:hover {
  background: #60a5fa;
  color: #fff;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}
