/* ルート変数定義 */
.rcsim-main-container {
    --rcsim-piece-size: 60px;
    width: 100%; 
    max-width: 500px; 
    margin: 20px auto; 
    background: #1a1a1a; 
    border-radius: 12px; 
    padding: 10px 0 20px 0; 
    color: white; 
    box-sizing: border-box; 
    border: 1px solid transparent;
    position: relative; 
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    touch-action: none !important;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* タッチスクロール防止対策の子要素伝播 */
.rcsim-main-container * {
    touch-action: none !important;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.rcsim-main-container.rcsim-is-solved-glow { 
    box-shadow: 0 0 0 2px #00ff00, 0 0 40px #00ff00 !important; 
    transition: all 0.5s; 
}

.rcsim-confetti-canvas {
    position: absolute; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    pointer-events: none; 
    z-index: 100;
}

.rcsim-status-msg { 
    text-align: center; 
    height: 36px; 
    line-height: 36px; 
    font-weight: bold; 
    font-size: 20px; 
    position: relative; 
    z-index: 101; 
    opacity: 0; 
    transition: all 0.3s ease;
}

.rcsim-status-msg.rcsim-has-text { 
    opacity: 1; 
}

.rcsim-status-msg .rcsim-status-content {
    display: inline-block; 
    position: relative; 
    background-clip: text; 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent;
    background-image: linear-gradient(135deg, #00ff00 0%, #00b300 100%);
    filter: drop-shadow(0 0 10px rgba(0, 255, 0, 0.6));
}

.rcsim-viewport { 
    width: 100%; 
    height: 340px; 
    position: relative; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    perspective: 1200px; 
    transform-style: preserve-3d;
    cursor: grab; 
    z-index: 1; 
}

.rcsim-viewport:active { 
    cursor: grabbing; 
}

.rcsim-reset-btn {
    position: absolute; 
    top: 10px; 
    left: 10px; 
    z-index: 110;
    background: #ee0000; 
    border: none;
    color: white; 
    width: 40px; 
    height: 40px; 
    border-radius: 50%; 
    font-size: 26px; 
    display: flex; 
    align-items: center; 
    justify-content: center;
    cursor: pointer; 
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    line-height: 1; 
    padding: 0; 
    padding-bottom: 4px; 
    padding-right: 1px;
}

.rcsim-reset-btn:hover { background: #ff3333; transform: scale(1.1); }
.rcsim-reset-btn:active { background: #aa0000; transform: scale(0.9); }

/* 3D Scene Elements */
.rcsim-scene { 
    width: calc(var(--rcsim-piece-size) * 3); 
    height: calc(var(--rcsim-piece-size) * 3); 
    position: relative; 
    transform-style: preserve-3d; 
}

/* アニメーション用実体オブジェクト */
.rcsim-cube-obj { 
    width: 100%; 
    height: 100%; 
    position: absolute; 
    transform-style: preserve-3d; 
    pointer-events: none !important; 
}

/* 当たり判定専用の透明キューブオブジェクト */
.rcsim-hitbox-obj { 
    width: 100%; 
    height: 100%; 
    position: absolute; 
    transform-style: preserve-3d; 
    pointer-events: auto; 
}

.rcsim-hitbox-piece { 
    width: var(--rcsim-piece-size); 
    height: var(--rcsim-piece-size); 
    position: absolute; 
    transform-style: preserve-3d; 
    left: var(--rcsim-piece-size); 
    top: var(--rcsim-piece-size); 
    pointer-events: auto; 
}

.rcsim-hitbox-face { 
    position: absolute; 
    width: var(--rcsim-piece-size); 
    height: var(--rcsim-piece-size); 
    opacity: 0; 
    transform-style: preserve-3d;
    pointer-events: auto; 
    cursor: pointer; 
}

/* 描画専用ピース・面 */
.rcsim-piece { 
    width: var(--rcsim-piece-size); 
    height: var(--rcsim-piece-size); 
    position: absolute; 
    transform-style: preserve-3d; 
    left: var(--rcsim-piece-size); 
    top: var(--rcsim-piece-size); 
    backface-visibility: hidden; 
    pointer-events: none !important; 
}

.rcsim-face { 
    position: absolute; 
    width: var(--rcsim-piece-size); 
    height: var(--rcsim-piece-size); 
    border: 2px solid #000; 
    box-sizing: border-box !important; 
    border-radius: 5px; 
    background: #222; 
    backface-visibility: hidden; 
    transform-style: preserve-3d;
    pointer-events: none !important; 
    transition: filter 0.15s ease; 
}

/* タッチ/スワイプ時にパネルを暗く表示するアクティブスタイル */
.rcsim-face.rcsim-is-touch-active {
    filter: brightness(0.45) !important;
}

/* 色設定 */
.rcsim-face-white { background: #ffffff; } 
.rcsim-face-yellow { background: #ffff00; } 
.rcsim-face-green { background: #009b48; } 
.rcsim-face-blue { background: #0046ad; } 
.rcsim-face-red { background: #ee0000; } 
.rcsim-face-orange { background: #ff5800; } 
.rcsim-face-dark { background: #444444; }

.rcsim-face.up, .rcsim-hitbox-face.up       { transform: rotateX(90deg)  translateZ(calc(var(--rcsim-piece-size) / 2)); } 
.rcsim-face.down, .rcsim-hitbox-face.down   { transform: rotateX(-90deg) translateZ(calc(var(--rcsim-piece-size) / 2)); }
.rcsim-face.front, .rcsim-hitbox-face.front { transform: rotateY(0deg)   translateZ(calc(var(--rcsim-piece-size) / 2)); } 
.rcsim-face.right, .rcsim-hitbox-face.right { transform: rotateY(90deg)  translateZ(calc(var(--rcsim-piece-size) / 2)); }
.rcsim-face.back, .rcsim-hitbox-face.back   { transform: rotateY(180deg) translateZ(calc(var(--rcsim-piece-size) / 2)); } 
.rcsim-face.left, .rcsim-hitbox-face.left   { transform: rotateY(-90deg) translateZ(calc(var(--rcsim-piece-size) / 2)); }

.rcsim-layer-group { 
    position: absolute; 
    width: 100%; 
    height: 100%; 
    transform-style: preserve-3d; 
    left: 0; 
    top: 0; 
    pointer-events: none !important; 
}

.rcsim-usage-guide {
    text-align: center;
    margin-top: 10px;
}

.rcsim-usage-guide p {
    display: inline-block;
    position: relative;
    padding: 6px 16px;
    margin: 0;
    font-size: 0.9rem;
    color: #ccc;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
}