body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Hiragino Kaku Gothic ProN', 'ヒラギノ角ゴ ProN W3', sans-serif;
}

/* 画面の切り替えを管理 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: transform 0.5s ease-in-out;
}
.screen.active {
    display: flex;
}
#start-screen {
    background-color: #f0f2f5;
}
#camera-screen {
    background-color: #000;
}
#preview-screen {
    background-color: #000;
}
#start-screen h1 {
    font-family: 'Zen Dots', sans-serif;
    font-size: 3em;
    font-weight: 400; /* Zen Dotsは通常このウェイトのみです */
    margin-bottom: 0.2em;
}

#start-screen p {
    text-align: center;
    padding: 0 1em; /* 左右に少し余白を追加 */
}

/* スタート画面のリンクスタイル */
#start-screen a {
    color: #007bff;
    text-decoration: underline;
}

#start-screen a:hover {
    color: #0056b3;
}

/* カメラ映像と全画面モード */
#video {
    width: 100%;
    height: auto;
    object-fit: contain;
    display: none;
    z-index: 1;
}

/* 全画面モードのスタイル */
#camera-screen.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99;
    background: #000;
}
#camera-screen.fullscreen #video {
    width: 100vw;
    height: 100vh;
    object-fit: cover;
}

#canvas {
    display: none;
}

/* コントロールボタン */
button {
    padding: 12px;
    border: none;
    border-radius: 5px;
    background-color: #007bff;
    color: white;
    font-size: 16px;
    cursor: pointer;
}
button.secondary {
    background-color: #6c757d; /* 破棄ボタン用のグレー */
    border-color: #6c757d;
}
#startButton {
    width: 200px;
    height: 60px;
    margin-bottom: 20px; /* フッターとの間隔を調整 */
}
#overlayButton {
    position: fixed;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.5);
    border: 4px solid #fff;
    color: transparent;
    cursor: pointer;
    z-index: 10;
    display: none;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}
#overlayButton::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: #fff;
    border-radius: 50%;
}

/* 停止ボタン */
#stopButton {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    color: #fff;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    display: none;
}
#stopButton .fas {
    color: #000;
}

/* カメラ切り替えボタン */
#switchCameraButton {
    position: fixed;
    top: 70px; /* 停止ボタンの下 */
    right: 20px;
    width: 40px;
    height: 40px;
    background-color: rgba(255, 255, 255, 0.5);
    border-radius: 5px;
    color: #fff;
    font-size: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    display: none;
}
#switchCameraButton .fas {
    color: #000;
}

/* ハンバーガーメニュー */
#menu-toggle {
    position: fixed;
    top: 20px;
    left: 20px;
    font-size: 30px;
    color: #fff;
    z-index: 10;
    cursor: pointer;
    display: none;
}
#menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
}
#menu-overlay.active {
    transform: translateX(0);
}
#menu-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 80%;
    max-width: 400px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    align-items: stretch;
}
#menu-container input, #menu-container select, #menu-container textarea {
    flex: 1;
    padding: 10px;
    box-sizing: border-box;
    border: 1px solid #ccc;
    border-radius: 4px;
}
#menu-container textarea {
    resize: vertical;
    min-height: 80px;
}
.checkbox-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%; /* コンテナを親要素の全幅に広げ、左寄せにする */
    align-items: flex-start; /* 中の要素を明確に左端に配置します */
}
.checkbox-container > div {
    display: flex;
    align-items: center;
    gap: 5px; /* チェックボックスとラベルの間隔を狭めます */
}
.checkbox-container label {
    font-size: 16px;
    color: #333;
    word-break: break-word;
}
#status {
    z-index: 30;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    position: fixed;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
}
#counter {
    z-index: 30;
    color: #fff;
    text-shadow: 1px 1px 2px #000;
    position: fixed;
    bottom: 130px; /* statusの上に表示 */
    left: 50%;
    transform: translateX(-50%);
}

/* ズームスライダー */
#zoom-slider {
    position: fixed;
    bottom: 160px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    max-width: 300px;
    z-index: 10;
    display: none; /* 初期状態では非表示 */
}

/* スマートフォンが横向き（ランドスケープ）のときのスタイル */
@media (orientation: landscape) {
    #overlayButton {
        bottom: auto;
        left: auto;
        transform: none;
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
    }
    #switchCameraButton {
        top: auto;
        bottom: 20px;
        right: 20px;
    }
    #preview-screen {
        flex-direction: row;
        gap: 10px;
    }
    #preview-image {
        max-width: 75vw;
        max-height: 90vh;
    }
    .preview-controls {
        flex-direction: column;
    }
}

/* プレビュー画面のスタイル */
#drawing-canvas {
    max-width: 95vw;
    max-height: 75vh;
    border: 2px solid #fff;
    border-radius: 5px;
    cursor: crosshair;
}

.preview-controls {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 20px;
    z-index: 10;
    align-items: center;
}

.drawing-tools, .action-buttons {
    display: flex;
    gap: 15px;
    align-items: center;
}

.drawing-tools label {
    color: #fff;
    font-size: 14px;
}

#penColor {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 40px;
    height: 30px;
    background-color: transparent;
    border: 1px solid #ccc;
    cursor: pointer;
}
#penColor::-webkit-color-swatch {
    border-radius: 4px;
    border: none;
}
#penColor::-moz-color-swatch {
    border-radius: 4px;
    border: none;
}

.pen-thickness-controls {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-left: 10px;
}

.pen-thickness-btn {
    padding: 8px;
    min-width: 30px;
    height: 30px;
    font-size: 12px;
    background-color: #f0f0f0;
    color: #333;
    border: 1px solid #ccc;
    line-height: 1;
}

.pen-thickness-btn.active {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}