:root {
    --bg-color: #fafafa;
    --game-bg: #fff8e1;
    --frame-color: #8d6e63;
    --text-color: #5d4037;
    --font-main: 'M PLUS Rounded 1c', sans-serif;
    --warning-color: #ff5252;
}

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    font-family: var(--font-main);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

#app-wrapper {
    /* Scale down if screen is smaller than game */
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center;
}

/* Compact Size: 360x600 */
#game-container {
    position: relative;
    width: 360px;
    height: 600px;
    background-color: var(--game-bg);
    border: 6px solid var(--frame-color);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    box-sizing: content-box;
}

/* Responsiveness for very small screens */
@media (max-height: 650px) {
    #game-container {
        transform: scale(0.9);
    }
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* UI Layer */
#ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

/* Header */
#header-ui {
    position: absolute;
    top: 12px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.score-container {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--frame-color);
    border-radius: 12px;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
}

.label {
    font-size: 10px;
    font-weight: bold;
    color: var(--frame-color);
}

#current-score {
    font-size: 24px;
    font-weight: bold;
    color: var(--text-color);
    line-height: 1;
}

.next-container {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--frame-color);
    border-radius: 12px;
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.next-slots {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.slot {
    width: 36px;
    height: 36px;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.05);
    /* Placeholder */
}

.slot.small {
    width: 24px;
    height: 24px;
    opacity: 0.7;
}

/* Button position */
#bgm-toggle {
    position: absolute;
    top: 12px;
    right: 120px;
    /* Left of next container */
    pointer-events: auto;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid #ddd;
    background: #fff;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

/* Danger Line */
#warning-line {
    position: absolute;
    top: 100px;
    /* JS controlled */
    left: 0;
    width: 100%;
    height: 2px;
    border-top: 3px dashed var(--warning-color);
    pointer-events: none;
    opacity: 0.5;
    /* Always visible based on request "はっきりと描画" */
    z-index: 5;
}

#warning-line span {
    position: absolute;
    right: 5px;
    top: -20px;
    color: var(--warning-color);
    font-weight: bold;
    font-size: 12px;
    display: none;
    /* Only show text when imminent danger? Or always? */
}

/* Start Screen */
#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
}

.content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 80%;
}

h1 {
    color: #4CAF50;
    font-size: 32px;
    margin-bottom: 20px;
}

.best {
    color: var(--text-color);
    font-weight: bold;
    margin-bottom: 30px;
}

#result-area {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 20px;
    color: var(--text-color);
}

.btn {
    border: none;
    padding: 14px 0;
    width: 220px;
    border-radius: 30px;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 12px;
    pointer-events: auto;
    font-family: var(--font-main);
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.1);
    transition: transform 0.1s;
}

.btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1);
}

.play-btn {
    background: #FF9800;
    color: white;
}

.share-btn {
    background: #03A9F4;
    color: white;
}

.credits {
    margin-top: 20px;
    font-size: 10px;
    color: #999;
}

.hidden {
    display: none !important;
}

/* Video Layer */
#video-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Must be higher than UI (10) and Start Screen (100) intentionally for Full Screen effects */
    /* Wait, start screen is 100. Video should be top priority as requested "最前面" */
    z-index: 9999;
    pointer-events: none;
    /* Let clicks pass through usually */
    display: flex;
    justify-content: center;
    align-items: center;
}

#video-layer video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    /* Fullscreen fit */
    /* Note: If video is gameover/opaque, it covers game. If overlay, it covers too. */
}

/* Special class to make video semi-transparent if needed, 
   but user asked for "Full Screen Play", usually implies seeing the video clearly.
   For Danger, we might want it to be an overlay. */
#loop-video {
    z-index: 1;
    opacity: 0.6;
    /* Slight transparency for Loop/Warning so we don't blind the player? 
                     User said "最前面" (Foremost). Leaving opaque might make game unplayable. 
                     I will set a light opacity/blend for warning, or assume the video source handles it.
                     SAFE BET: Opacity 0.5 for warning. */
    opacity: 0.5;
    mix-blend-mode: screen;
    /* Nice effect for warnings */
}

#trigger-video {
    z-index: 2;
    /* On top of loop */
}

/* When blocking input is needed (Game Over), we can add a class to container */
#video-layer.blocking {
    pointer-events: auto;
    background: rgba(0, 0, 0, 0.8);
}

#skip-video-btn {
    position: absolute;
    bottom: 30px;
    z-index: 10;
    padding: 8px 24px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid white;
    color: white;
    border-radius: 20px;
    cursor: pointer;
    pointer-events: auto;
}