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

body {
  background: #0a0a0f;
  color: #fff;
  font-family: 'Courier New', monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(120,40,200,0.08) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(0,200,255,0.06) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Layout ── */
#app {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  padding: 20px;
}

/* ── Panel ── */
.panel {
  width: 140px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.box {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 14px;
}

.box-title {
  font-size: 10px;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  margin-bottom: 10px;
}

.box-value {
  font-size: 22px;
  font-weight: bold;
}

.score-val { color: #00e5ff; text-shadow: 0 0 12px #00e5ff; }
.level-val { color: #b967ff; text-shadow: 0 0 12px #b967ff; }
.lines-val { color: #05ffa1; text-shadow: 0 0 12px #05ffa1; }
.best-val  { color: #ffd700; text-shadow: 0 0 10px #ffd700; }

/* ── Key guide ── */
.key-guide {
  font-size: 10px;
  color: rgba(255,255,255,0.25);
  line-height: 1.9;
}

.key {
  color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.08);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 9px;
}

/* ── Game canvas ── */
#game-wrap {
  position: relative;
}

#canvas {
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 0 40px rgba(0,229,255,0.08), 0 0 80px rgba(0,0,0,0.6);
}

/* ── Level-up message ── */
#levelup-msg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  font-weight: bold;
  color: #b967ff;
  text-shadow: 0 0 20px #b967ff;
  letter-spacing: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

/* ── Overlay ── */
#overlay {
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: rgba(0,0,0,0.82);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
  backdrop-filter: blur(4px);
}

#overlay h1 {
  font-size: 42px;
  letter-spacing: 8px;
  background: linear-gradient(135deg, #00e5ff, #b967ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 20px rgba(0,229,255,0.5));
}

#overlay .sub {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 3px;
}

#overlay .gameover-score {
  font-size: 14px;
  color: rgba(255,255,255,0.6);
  text-align: center;
  line-height: 1.8;
}

/* ── Button ── */
.btn {
  padding: 12px 36px;
  border-radius: 8px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
  background: linear-gradient(135deg, rgba(0,229,255,0.13), rgba(185,103,255,0.13));
  border: 1px solid rgba(0,229,255,0.4);
  color: #fff;
}

.btn:hover {
  background: linear-gradient(135deg, rgba(0,229,255,0.27), rgba(185,103,255,0.27));
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(0,229,255,0.3);
}

/* ── Next piece canvas ── */
#next-canvas {
  display: block;
  margin: 4px auto 0;
}

/* ── Mobile controls ── */
#mobile-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

#mobile-controls .ctrl-row {
  display: flex;
  gap: 10px;
}

.ctrl-btn {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.ctrl-btn:active {
  background: rgba(0,229,255,0.2);
  transform: scale(0.9);
}

/* 회전 — 보라 */
#btn-rotate {
  width: 80px;
  height: 80px;
  font-size: 28px;
  background: rgba(185,103,255,0.12);
  border-color: rgba(185,103,255,0.4);
  color: #b967ff;
  border-radius: 50%;
}
#btn-rotate:active { background: rgba(185,103,255,0.3); }

/* 이동 — 기본 */
#btn-left, #btn-right { background: rgba(255,255,255,0.06); }

/* 내리기 — 초록 */
#btn-down {
  background: rgba(5,255,161,0.08);
  border-color: rgba(5,255,161,0.3);
  color: #05ffa1;
}
#btn-down:active { background: rgba(5,255,161,0.25); }

/* 하드드롭 — 하늘 */
.ctrl-btn.drop {
  width: 160px;
  height: 52px;
  border-radius: 12px;
  font-size: 13px;
  letter-spacing: 2px;
  font-family: 'Courier New', monospace;
  background: rgba(0,229,255,0.1);
  border-color: rgba(0,229,255,0.4);
  color: #00e5ff;
  text-shadow: 0 0 8px #00e5ff;
}
.ctrl-btn.drop:active { background: rgba(0,229,255,0.3); }

/* ── Mobile responsive (터치 기기만) ── */
@media (hover: none) and (pointer: coarse) {
  #app {
    flex-direction: column;
    align-items: center;
    padding: 12px;
    gap: 12px;
  }

  .panel-left {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .panel-left .box {
    flex: 1;
    min-width: 70px;
    padding: 10px;
  }

  .panel-left .box-value { font-size: 16px; }
  .panel-left .box-title { font-size: 9px; margin-bottom: 4px; }
  .panel-left .key-guide { display: none; }

  .panel-right { display: none; }

  #canvas {
    width: 240px !important;
    height: 480px !important;
  }

  #mobile-controls { display: flex; }
}
