@import url('https://fonts.googleapis.com/css2?family=Jua&family=Nunito:wght@700;800;900&family=Noto+Sans+KR:wght@500;700&display=swap');

:root {
  --bg-gradient-top: #98dcff;
  --bg-gradient-bottom: #cbf1ff;
  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(255, 255, 255, 0.95);
  --panel-shadow: rgba(147, 197, 253, 0.35);
  --accent-pink: #ff6b9d;
  --accent-blue: #38bdf8;
  --accent-yellow: #fbbf24;
  --accent-purple: #c084fc;
  --text-main: #334155;
  --text-muted: #64748b;
  --canvas-bg: #eaf6ff;
  --grid-line: rgba(186, 230, 253, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

body {
  background: linear-gradient(180deg, var(--bg-gradient-top) 0%, var(--bg-gradient-bottom) 100%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: 'Jua', 'Nunito', 'Noto Sans KR', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  overflow-x: hidden;
  position: relative;
}

/* Floating background clouds */
.cloud {
  position: fixed;
  user-select: none;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.05));
  animation: floatCloud 24s linear infinite;
}

.cloud-1 {
  top: 8%;
  left: -10%;
  font-size: 5rem;
  animation-duration: 32s;
}

.cloud-2 {
  top: 65%;
  left: -15%;
  font-size: 6.5rem;
  animation-duration: 38s;
  animation-delay: -12s;
}

.cloud-3 {
  top: 25%;
  right: 6%;
  font-size: 2.2rem;
  animation: twinkle 3s ease-in-out infinite alternate;
}

.cloud-4 {
  top: 78%;
  right: 12%;
  font-size: 4rem;
  animation-duration: 45s;
  animation-delay: -20s;
}

@keyframes floatCloud {
  0% { transform: translateX(-10vw); }
  100% { transform: translateX(115vw); }
}

@keyframes twinkle {
  0% { opacity: 0.3; transform: scale(0.9) rotate(0deg); }
  100% { opacity: 0.9; transform: scale(1.15) rotate(15deg); }
}

.tetris-wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 900px;
  width: 100%;
}

/* Header */
.game-header {
  width: 100%;
  max-width: 620px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: var(--panel-bg);
  border: 3px solid #ffffff;
  border-radius: 24px;
  box-shadow: 0 8px 24px var(--panel-shadow);
  backdrop-filter: blur(12px);
}

.title-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon {
  font-size: 1.6rem;
  animation: bounce 2s infinite ease-in-out;
}

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

.game-title {
  font-size: 1.8rem;
  letter-spacing: 2px;
  font-weight: 900;
  color: #ff6097;
  text-shadow: 2px 2px 0 #ffffff, 0 4px 10px rgba(255, 107, 157, 0.3);
}

.header-controls {
  display: flex;
  gap: 8px;
}

.icon-btn {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  color: #475569;
  font-size: 1.25rem;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

.icon-btn:hover {
  background: #ffe4ef;
  border-color: var(--accent-pink);
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 6px 14px rgba(255, 107, 157, 0.25);
}

.icon-btn:active {
  transform: translateY(0) scale(0.96);
}

/* Game Main Layout */
.game-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
}

/* Side Panels */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 135px;
}

.panel-box {
  background: var(--panel-bg);
  border: 3px solid #ffffff;
  border-radius: 20px;
  padding: 14px 10px;
  text-align: center;
  box-shadow: 0 8px 20px var(--panel-shadow);
  backdrop-filter: blur(12px);
}

.panel-box h2 {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: #0284c7;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.key-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: block;
  margin-top: 6px;
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  background: #e0f2fe;
  padding: 2px 6px;
  border-radius: 8px;
}

/* Stats */
.stat-item {
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 6px 4px;
  border-radius: 12px;
  border: 1px solid rgba(226, 232, 240, 0.8);
}
.stat-item:last-child {
  margin-bottom: 0;
}

.stat-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: 900;
  color: #ff548e;
  font-family: 'Nunito', sans-serif;
}

/* Center Board */
.board-area {
  position: relative;
}

.canvas-container {
  position: relative;
  background: #ffffff;
  border: 4px solid #bae6fd;
  border-radius: 20px;
  padding: 6px;
  box-shadow: 0 12px 30px rgba(56, 189, 248, 0.25), inset 0 2px 10px rgba(0, 0, 0, 0.03);
}

#game-canvas {
  display: block;
  background-color: var(--canvas-bg);
  border-radius: 14px;
}

#hold-canvas, #next-canvas {
  display: block;
  margin: 0 auto;
  background-color: #f0f9ff;
  border: 2px solid #e0f2fe;
  border-radius: 12px;
}

/* Help Box */
.help-box {
  font-family: 'Noto Sans KR', sans-serif;
  text-align: left;
}

.help-list {
  list-style: none;
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-main);
}

.help-list span {
  display: inline-block;
  color: #0284c7;
  font-weight: 700;
  background: #e0f2fe;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 0.72rem;
  margin-right: 4px;
}

/* Character Guide Footer */
.character-guide {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  max-width: 620px;
  width: 100%;
  padding: 8px 12px;
  background: var(--panel-bg);
  border: 2px solid #ffffff;
  border-radius: 16px;
  box-shadow: 0 4px 12px var(--panel-shadow);
}

.char-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  color: var(--text-main);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

.char-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.char-dot.kitty { background: #ff477e; }
.char-dot.cinna { background: #38bdf8; }
.char-dot.hangyo { background: #2dd4bf; }
.char-dot.purin { background: #fde047; }
.char-dot.melody { background: #f472b6; }
.char-dot.kuromi { background: #c084fc; }
.char-dot.pochacco { background: #34d399; }

/* Overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(230, 245, 255, 0.88);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  z-index: 10;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  text-align: center;
  padding: 26px 20px;
  background: #ffffff;
  border: 3px solid var(--accent-pink);
  border-radius: 24px;
  box-shadow: 0 10px 35px rgba(255, 107, 157, 0.35);
  max-width: 85%;
}

.overlay-badge {
  font-size: 2.2rem;
  margin-bottom: 6px;
}

.overlay-card h2 {
  font-size: 1.8rem;
  color: var(--accent-pink);
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.overlay-card p {
  font-size: 1rem;
  margin-bottom: 20px;
  color: var(--text-main);
  font-family: 'Noto Sans KR', sans-serif;
  font-weight: 600;
}

.primary-btn {
  background: linear-gradient(135deg, #ff75a0, #ff548e);
  border: none;
  color: #ffffff;
  font-weight: 800;
  font-size: 1.05rem;
  font-family: 'Jua', sans-serif;
  padding: 10px 26px;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: 0 6px 18px rgba(255, 84, 142, 0.4);
}

.primary-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(255, 84, 142, 0.55);
}

.primary-btn:active {
  transform: scale(0.96);
}

/* Touch Controls */
.touch-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 480px;
  margin-top: 4px;
}

.touch-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.touch-btn {
  flex: 1;
  background: #ffffff;
  border: 2px solid #bae6fd;
  color: #0369a1;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 14px 10px;
  border-radius: 16px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.2);
  transition: all 0.1s ease;
  font-family: 'Jua', 'Nunito', sans-serif;
}

.touch-btn:active {
  background: #e0f2fe;
  transform: scale(0.95);
  border-color: #38bdf8;
}

.drop-btn {
  background: linear-gradient(135deg, #ff85aa, #ff5992);
  border: 2px solid #ff477e;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(255, 89, 146, 0.35);
}

.drop-btn:active {
  background: #e11d48;
}

/* Responsive adjustments */
@media (max-width: 620px) {
  body {
    padding: 8px;
  }

  .game-container {
    gap: 8px;
  }

  .side-panel {
    width: 92px;
    gap: 8px;
  }

  .panel-box {
    padding: 8px 4px;
    border-radius: 14px;
  }

  .panel-box h2 {
    font-size: 0.78rem;
    margin-bottom: 4px;
  }

  #hold-canvas {
    width: 75px;
    height: 75px;
  }

  #next-canvas {
    width: 75px;
    height: 180px;
  }

  .canvas-container {
    padding: 3px;
    border-radius: 14px;
  }

  #game-canvas {
    width: 220px;
    height: 440px;
  }

  .stat-value {
    font-size: 1rem;
  }

  .help-box {
    display: none;
  }

  .character-guide {
    display: none;
  }
}
