* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: #0a0a1a;
  color: #fff;
  font-family: 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 8px;
  width: 100%;
  max-width: 520px;
}

h1 {
  font-size: 2rem;
  letter-spacing: 0.2em;
  color: #00e5ff;
  text-shadow: 0 0 20px #00e5ff88;
  margin-bottom: 12px;
  text-transform: uppercase;
}

#game-area {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

#tetris {
  border: 2px solid #00e5ff44;
  box-shadow: 0 0 30px #00e5ff22;
  background: #050510;
  display: block;
}

#side-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 90px;
}

.left-panel,
.right-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 90px;
}

.panel-box {
  background: #0d0d2a;
  border: 1px solid #00e5ff33;
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.panel-label {
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: #00e5ffaa;
  text-transform: uppercase;
  margin-bottom: 4px;
}

#score, #level, #lines {
  font-size: 1.4rem;
  font-weight: bold;
  color: #fff;
}

#next-piece, #hold-piece {
  display: block;
  margin: 0 auto;
}

/* オーバーレイ */
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(5, 5, 20, 0.85);
  z-index: 10;
  border-radius: 4px;
}

#overlay.hidden {
  display: none;
}

#overlay-content {
  text-align: center;
  padding: 24px;
}

#overlay-title {
  font-size: 2rem;
  font-weight: bold;
  color: #00e5ff;
  text-shadow: 0 0 20px #00e5ff;
  margin-bottom: 12px;
}

#overlay-score {
  font-size: 1rem;
  color: #aaa;
  margin-bottom: 20px;
  min-height: 1.5em;
}

#overlay-btn {
  background: #00e5ff;
  color: #050510;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 0.1em;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 0 20px #00e5ff66;
}

#overlay-btn:active {
  transform: scale(0.95);
}

/* モバイルコントロール */
#mobile-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  width: 100%;
  max-width: 360px;
}

.control-row {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.ctrl-btn {
  background: #0d0d2a;
  border: 2px solid #00e5ff44;
  border-radius: 10px;
  color: #00e5ff;
  font-size: 1.1rem;
  font-weight: bold;
  width: 72px;
  height: 56px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.1s, transform 0.1s;
  touch-action: manipulation;
}

.ctrl-btn.large {
  font-size: 1.5rem;
}

.ctrl-btn:active {
  background: #00e5ff22;
  transform: scale(0.93);
  border-color: #00e5ffaa;
}

/* レスポンシブ調整 */
@media (max-width: 420px) {
  #tetris {
    width: 240px;
    height: 480px;
  }
  #next-piece, #hold-piece {
    width: 80px;
    height: 80px;
  }
  .left-panel, .right-panel {
    min-width: 70px;
  }
  .panel-box {
    padding: 6px;
  }
  #score, #level, #lines {
    font-size: 1.1rem;
  }
  .ctrl-btn {
    width: 64px;
    height: 52px;
    font-size: 1rem;
  }
  .ctrl-btn.large {
    font-size: 1.4rem;
  }
  h1 {
    font-size: 1.5rem;
  }
}

@media (max-width: 340px) {
  #tetris {
    width: 200px;
    height: 400px;
  }
  #next-piece, #hold-piece {
    width: 64px;
    height: 64px;
  }
  .left-panel, .right-panel {
    min-width: 56px;
  }
}
