html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: black;
    color: white;
    font-family: sans-serif;
    overflow: hidden;

    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;  /* ← これを追加 */
}

#viewport {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);

    display: flex;
    justify-content: center;
    align-items: center;

    width: max-content;
    height: max-content;
}

#content-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: max-content;
}

/* =========================
   左右の画像（完全背景化）
   ========================= */
.side-image {
    width: 200px;
    height: 615px;
    padding: 10px;
    background: linear-gradient(145deg, #222, #111);
    border: 4px solid #00c8ff;
    border-radius: 25px;
    box-shadow: 
        0 10px 20px rgba(0,200,255,0.4),
        inset 0 0 20px rgba(255,255,255,0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;

    pointer-events: none;
}

.side-image::before {
    content: "";
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        120deg,
        rgba(255,255,255,0.2),
        rgba(0,200,255,0.5),
        rgba(255,255,255,0.2)
    );
    transform: rotate(45deg);
    animation: shine 3s linear infinite;
    pointer-events: none;
}

@keyframes shine {
    0%   { transform: rotate(45deg) translate(-200%, 0); }
    100% { transform: rotate(45deg) translate(200%, 0); }
}

.side-image img {
    width: 85%;
    height: 85%;
    object-fit: cover;
    border-radius: 20px;
    border: 3px solid rgba(255,255,255,0.2);

    pointer-events: none;
}

/* =========================
   ゲーム全体
   ========================= */
#wrap {
    display: flex;
    padding: 14px;
    border: 3px solid #666;
    background: #111;
    position: relative;

    /* ★追加 */
    width: max-content;
}

#side a {
    pointer-events: auto;
}

#side button {
    pointer-events: auto;
}

canvas#game {
    background: #000;
    border: 4px solid #fff;
    box-shadow:
        inset 0 0 0 2px #444,
        0 0 20px rgba(0,200,255,.6);

    pointer-events: auto;
    touch-action: none;
}

#side {
    margin-left: 14px;
    width: 140px;
    text-align: center;

    pointer-events: none;
}

#next {
    background: #000;
    border: 2px solid #888;

    pointer-events: none;
}

/* =========================
   オーバーレイ
   ========================= */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.9);
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;

    /* ★ ボタン操作のため許可 */
    pointer-events: auto;
}

.hidden {
    display: none;
}

button {
    font-size: 24px;
    padding: 14px 32px;
}

#controls {
  display: flex;
  flex-direction: column; /* 上下に並べる */
  align-items: center;
  gap: 20px; /* 上下の間隔 */
}

.control-row {
  display: flex;
  gap: 20px; /* 左右の間隔 */
}

.control-column {
    display: flex;
    flex-direction: column;
    gap: 10px; /* ボタン間 */
}

.control-column button {
    width: 100px;   /* ある程度固定幅 */
    height: 100px;  /* 高さも大きめ */
    font-size: 32px;
    border-radius: 12px;
}

#leftBtn,
#rotateBtn,
#rightBtn,
#downBtn {
    display: block;
    width: 100%;
    padding: 10px;
    margin-top: 10px;
    font-size: 18px;
    font-weight: bold;
    background-color: #ff69b4;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    touch-action: manipulation;
}

#leftBtn:active,
#rotateBtn:active,
#rightBtn:active,
#downBtn:active {
    background-color: #ff1493;
}


/* =========================
   「てとりす！！！」演出
   ========================= */
#tetris-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);

    font-family: '創英角ポップ体', 'Arial', sans-serif;
    font-size: 90px;
    font-weight: 900;
    color: #ff69b4;

    text-shadow:
        4px 4px 0 #ff1493,
        8px 8px 0 #c71585,
        0 0 20px #ff69b4,
        0 0 40px #ff1493,
        0 0 60px #ff69b4;

    letter-spacing: 4px;
    pointer-events: none;
    z-index: 20;
    opacity: 0;

    white-space: nowrap;      /* 折り返し禁止 */
    text-align: center;       /* 文字中央揃え */
}

#bg-snow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;   /* 親のゲーム画面サイズに合わせる */
    height: 100%;
    pointer-events: none; /* 雪にマウスイベントを通さない */
    z-index: 10;    /* ゲームキャンバスの上に表示 */
}
#wrap {
    position: relative;
    z-index: 1;
}

#tetris-text.show {
    animation: pop 0.6s cubic-bezier(.2,1.6,.4,1) forwards;
}

@keyframes pop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    60% {
        transform: translate(-50%, -50%) scale(1.7);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}