/* テトリス — tetris-game.css (tg- プレフィックス) */

.tg-root {
  /* スマホ幅に収める: 盤面300px + サイド + ギャップ = 約430px */
  display: block;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  position: relative;
  box-sizing: border-box;
  /* タップ拡大防止 */
  touch-action: pan-y;
  -webkit-user-select: none;
  user-select: none;
}

.tg-wrap {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* メインキャンバス */
.tg-canvas {
  display: block;
  width: 300px;
  height: 600px;
  border: 1px solid #555;
  border-radius: 4px;
  background: #111;
  touch-action: none;
}

/* サイドパネル */
.tg-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.tg-panel {
  background: #f5f5f3;
  border-radius: 8px;
  padding: 7px 10px;
  text-align: center;
  border: 0.5px solid rgba(0,0,0,0.1);
}
@media (prefers-color-scheme: dark) {
  .tg-panel { background: #222; border-color: rgba(255,255,255,0.1); }
}

.tg-panel-label {
  font-size: 10px;
  letter-spacing: 0.08em;
  color: #888;
  margin-bottom: 3px;
  font-weight: 500;
}

.tg-val {
  font-size: 1.2rem;
  font-weight: 500;
  color: #111;
}
@media (prefers-color-scheme: dark) { .tg-val { color: #eee; } }

.tg-next {
  display: block;
  margin: 0 auto;
  background: #111;
  border-radius: 3px;
}

.tg-sound-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tg-mute-btn {
  font-size: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.tg-sel {
  width: 100%;
  font-size: 11px;
  border: 0.5px solid #ccc;
  border-radius: 4px;
  padding: 3px 4px;
  background: transparent;
  color: inherit;
  margin-top: 3px;
}

.tg-btn {
  width: 100%;
  padding: 8px 4px;
  font-size: 12px;
  border: 0.5px solid #ccc;
  border-radius: 6px;
  cursor: pointer;
  background: transparent;
  color: inherit;
}
.tg-btn:hover { background: rgba(0,0,0,0.05); }
@media (prefers-color-scheme: dark) { .tg-btn { border-color: #555; } }

.tg-keys {
  font-size: 10px;
  color: #aaa;
  line-height: 1.8;
}

/* キャンバスラッパー（オーバーレイの基準） */
.tg-board-wrap {
  position: relative;
  flex-shrink: 0;
  width: 300px;
  height: 600px;
}

/* オーバーレイ */
.tg-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.62);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  /* サイドパネルのボタンをブロックしない */
  pointer-events: none;
}
/* オーバーレイが表示中もボタンはクリック可能 */
.tg-overlay * { pointer-events: none; }
.tg-overlay-msg { font-size: 1.4rem; font-weight: 500; color: #fff; }
.tg-overlay-sub { font-size: 12px; color: rgba(255,255,255,0.7); margin-top: 6px; }

/* スマホ: 盤面をvw基準でスケールダウン */
@media (max-width: 440px) {
  .tg-root { overflow: hidden; }
  .tg-wrap { gap: 8px; }
  .tg-board-wrap {
    width: calc(100vw - 118px - 20px);
    height: calc((100vw - 118px - 20px) * 2);
  }
  .tg-canvas {
    width: 100%;
    height: 100%;
  }
  .tg-side { width: 110px; flex-shrink: 0; }
  .tg-val  { font-size: 1rem; }
  .tg-keys { display: none; }
}
