* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

body {
    font-family: 'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
    background: linear-gradient(135deg, #2d1b0e 0%, #4a2c17 100%);
    min-height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    max-width: 800px;
    max-height: 600px;
    background: #3d2414;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.hidden {
    display: none !important;
}

/* タイトル画面 */
#title-screen {
    z-index: 10;
    background: linear-gradient(180deg, #1a0f05 0%, #3d2414 50%, #1a0f05 100%);
    text-align: center;
}


.title {
    font-size: 2.5rem;
    color: #ffd700;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
    margin-bottom: 20px;
    line-height: 1.4;
}

.eho-info {
    font-size: 1.5rem;
    color: #ff6b6b;
    margin-bottom: 15px;
    padding: 10px 20px;
    background: rgba(255, 107, 107, 0.2);
    border-radius: 5px;
    border: 2px solid #ff6b6b;
}

.game-hint {
    font-size: 1.3rem;
    color: #fff;
    margin-bottom: 20px;
    padding: 8px 16px;
    background: rgba(255, 215, 0, 0.2);
    border-radius: 5px;
    border: 2px solid #ffd700;
}

.highscore-display {
    font-size: 1.2rem;
    color: #87ceeb;
    margin-bottom: 30px;
}

/* ボタン */
.btn {
    font-family: inherit;
    font-size: 1.2rem;
    padding: 15px 40px;
    margin: 10px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: scale(1.05);
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(180deg, #ff6b6b 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #ff8080 0%, #e74c3c 100%);
}

.btn-secondary {
    background: linear-gradient(180deg, #5dade2 0%, #2980b9 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(93, 173, 226, 0.4);
}

.btn-secondary:hover {
    background: linear-gradient(180deg, #7ec8e3 0%, #3498db 100%);
}

.btn-small {
    font-size: 0.9rem;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* モーダル */
.modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-content {
    background: #3d2414;
    padding: 30px;
    border-radius: 15px;
    max-width: 500px;
    text-align: center;
    border: 3px solid #ffd700;
}

.modal-content h2 {
    color: #ffd700;
    margin-bottom: 20px;
}

.howto-list {
    text-align: left;
    list-style: none;
    margin-bottom: 20px;
}

.howto-list li {
    padding: 8px 0;
    padding-left: 25px;
    position: relative;
}

.howto-list li::before {
    content: "◆";
    position: absolute;
    left: 0;
    color: #ff6b6b;
}

.controls-table {
    width: 100%;
    margin: 15px 0;
    border-collapse: collapse;
}

.controls-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.controls-table td:first-child {
    color: #87ceeb;
    text-align: right;
    padding-right: 20px;
}

/* ゲーム画面 */
#game-screen {
    z-index: 5;
    flex-direction: column;
    justify-content: flex-start;
    background: #2d5a27;
}

#game-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 8px 15px;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.3) 100%);
    z-index: 10;
    flex-shrink: 0;
}

#game-canvas {
    flex: 1;
    width: 100%;
    min-height: 0;
}

.ui-left, .ui-right {
    flex: 1;
}

.ui-right {
    text-align: right;
}

.ui-center {
    flex: 2;
}

.score-display {
    font-size: 1.3rem;
    color: #ffd700;
}

.combo-display {
    font-size: 1rem;
    color: #ff6b6b;
}

.ehomaki-gauge {
    text-align: center;
}

.gauge-label {
    margin-bottom: 5px;
}

.gauge-bar {
    width: 100%;
    height: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 10px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.gauge-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #27ae60 0%, #2ecc71 50%, #27ae60 100%);
    transition: width 0.1s ease;
}


/* ポーズ画面 */
#pause-screen {
    background: rgba(0, 0, 0, 0.85);
    z-index: 50;
}

.pause-content {
    text-align: center;
}

.pause-content h2 {
    font-size: 2.5rem;
    color: #ffd700;
    margin-bottom: 30px;
}

/* リザルト画面 */
#result-screen {
    background: linear-gradient(180deg, #1a0f05 0%, #3d2414 50%, #1a0f05 100%);
    text-align: center;
}

.result-title {
    font-size: 3rem;
    margin-bottom: 30px;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.8);
}

.result-title.clear {
    color: #2ecc71;
}

.result-title.gameover {
    color: #e74c3c;
}

.result-content {
    margin-bottom: 30px;
}

.final-score {
    font-size: 2rem;
    color: #ffd700;
    margin-bottom: 15px;
}

.new-record {
    font-size: 1.5rem;
    color: #ff6b6b;
    animation: pulse 0.5s ease infinite alternate;
    margin-bottom: 15px;
}

@keyframes pulse {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}

.stats {
    font-size: 1.1rem;
    color: #87ceeb;
    line-height: 1.8;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* チュートリアル表示 */
.tutorial-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    padding: 20px 30px;
    border-radius: 10px;
    border: 2px solid #ffd700;
    text-align: center;
    z-index: 20;
    animation: fadeInOut 3s ease forwards;
}

.tutorial-overlay h3 {
    color: #ffd700;
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.tutorial-overlay p {
    color: #fff;
    font-size: 1.1rem;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    10% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; pointer-events: none; }
}

/* レスポンシブ対応 */
@media (max-width: 850px), (max-height: 650px) {
    body {
        padding: 0;
    }

    #game-container {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-width: 100vw;
        max-height: 100vh;
        max-height: 100dvh;
        border-radius: 0;
    }

    .title {
        font-size: 1.5rem;
        padding: 0 10px;
    }

    .eho-info {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .highscore-display {
        font-size: 1rem;
        margin-bottom: 15px;
    }

    .btn {
        font-size: 1rem;
        padding: 12px 30px;
        margin: 5px;
    }

    #game-ui {
        padding: 5px 10px;
    }

    .score-display {
        font-size: 1rem;
    }

    .combo-display {
        font-size: 0.8rem;
    }

    .gauge-bar {
        height: 15px;
    }

    .gauge-label {
        font-size: 0.9rem;
    }

    .modal-content {
        padding: 20px;
        margin: 10px;
        max-height: 90vh;
        max-height: 90dvh;
        overflow-y: auto;
    }

    .howto-list li {
        font-size: 0.9rem;
        padding: 5px 0;
        padding-left: 20px;
    }

    .controls-table td {
        font-size: 0.85rem;
        padding: 5px;
    }

    .result-title {
        font-size: 2rem;
    }

    .final-score {
        font-size: 1.5rem;
    }

    .stats {
        font-size: 1rem;
    }
}
