@import url('https://fonts.googleapis.com/css2?family=Dela+Gothic+One&family=Noto+Sans+JP:wght@400;700&display=swap');

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

body {
    font-family: 'Noto Sans JP', sans-serif;
    background-color: #2c1810;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    max-width: 100%;
    max-height: 100%;
    margin: 0 auto;
    overflow: hidden;
}

#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

/* 画面共通 */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 20px;
    z-index: 10;
    overflow-y: auto;
}

.hidden {
    display: none !important;
}

/* タイトル画面 */
#title-screen {
    background: transparent;
    padding: 10px 10px 80px 10px;
    justify-content: center;
}

.title-logo {
    position: relative;
    width: 90%;
    max-width: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.title-frame {
    width: 100%;
    height: auto;
}

.title-text {
    position: absolute;
    font-family: 'Dela Gothic One', cursive;
    font-size: clamp(2rem, 8vw, 4rem);
    color: #ffd700;
    text-shadow: 
        3px 3px 0 #8b0000,
        -1px -1px 0 #8b0000,
        1px -1px 0 #8b0000,
        -1px 1px 0 #8b0000,
        0 4px 8px rgba(0, 0, 0, 0.5);
    text-align: center;
    line-height: 1.2;
    letter-spacing: 0.05em;
}

.sushi-decoration {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0 20px;
}

.deco-sushi {
    width: clamp(60px, 15vw, 100px);
    height: auto;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.deco-1 {
    animation-delay: 0s;
}

.deco-2 {
    animation-delay: 0.5s;
}

.deco-3 {
    animation-delay: 1s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-15px);
    }
}

/* タイトル画面ランキング */
.title-rankings {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.title-ranking-section {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 10px;
    padding: 10px 15px;
    min-width: 150px;
}

.title-ranking-section h3 {
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    color: #ffd700;
    margin-bottom: 8px;
    text-align: center;
}

.title-ranking-list {
    font-size: clamp(0.65rem, 2vw, 0.8rem);
    color: #fff;
}

.title-ranking-item {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.title-ranking-item:last-child {
    border-bottom: none;
}

.title-ranking-item .rank {
    color: #ffd700;
    width: 20px;
}

.title-ranking-item .name {
    flex: 1;
    margin: 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.title-ranking-item .score {
    color: #ff6b6b;
    font-weight: bold;
}

/* ボタン */
.game-btn {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: clamp(1rem, 4vw, 1.5rem);
    font-weight: 700;
    padding: 15px 50px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(180deg, #ff6b6b 0%, #c0392b 100%);
    color: white;
    cursor: pointer;
    box-shadow: 
        0 6px 0 #8b0000,
        0 8px 15px rgba(0, 0, 0, 0.3);
    transition: all 0.1s ease;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    margin-bottom: 10px;
}

.game-btn:hover {
    transform: translateY(2px);
    box-shadow: 
        0 4px 0 #8b0000,
        0 6px 10px rgba(0, 0, 0, 0.3);
}

.game-btn:active {
    transform: translateY(4px);
    box-shadow: 
        0 2px 0 #8b0000,
        0 4px 5px rgba(0, 0, 0, 0.3);
}

.game-btn.secondary {
    background: linear-gradient(180deg, #95a5a6 0%, #7f8c8d 100%);
    box-shadow: 
        0 6px 0 #5d6d7e,
        0 8px 15px rgba(0, 0, 0, 0.3);
}

.game-btn.secondary:hover {
    box-shadow: 
        0 4px 0 #5d6d7e,
        0 6px 10px rgba(0, 0, 0, 0.3);
}

.game-btn.secondary:active {
    box-shadow: 
        0 2px 0 #5d6d7e,
        0 4px 5px rgba(0, 0, 0, 0.3);
}

.game-btn.small {
    font-size: clamp(0.8rem, 3vw, 1rem);
    padding: 10px 25px;
}

/* クレジット表記 */
.credits {
    margin-top: 20px;
    text-align: center;
}

.credits p {
    font-size: clamp(0.6rem, 2vw, 0.8rem);
    color: rgba(255, 255, 255, 0.7);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8);
    margin: 3px 0;
}

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

.modal-content {
    background: linear-gradient(180deg, #fff8dc 0%, #f5deb3 100%);
    border-radius: 20px;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    text-align: center;
    box-shadow: 
        0 0 0 5px #8b4513,
        0 10px 30px rgba(0, 0, 0, 0.5);
}

.modal-title {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: clamp(1rem, 4vw, 1.4rem);
    color: #8b4513;
    margin-bottom: 15px;
}

.character-select {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.character-option {
    cursor: pointer;
    padding: 12px;
    border-radius: 15px;
    background: #fff;
    border: 4px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.character-option img {
    width: clamp(50px, 15vw, 80px);
    height: auto;
}

.character-option span {
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    font-weight: 700;
    color: #5d4037;
}

.character-option:hover {
    transform: scale(1.05);
    border-color: #ffd700;
}

.character-option.selected {
    border-color: #ff6b6b;
    background: #fff5f5;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.5);
}

/* 難易度選択 */
.difficulty-select {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.difficulty-option {
    cursor: pointer;
    padding: 15px 20px;
    border-radius: 15px;
    background: #fff;
    border: 4px solid transparent;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 130px;
}

.difficulty-option:hover {
    transform: scale(1.05);
    border-color: #ffd700;
}

.difficulty-option.selected {
    border-color: #ff6b6b;
    background: #fff5f5;
    box-shadow: 0 0 15px rgba(255, 107, 107, 0.5);
}

.difficulty-name {
    font-size: clamp(1rem, 4vw, 1.2rem);
    font-weight: 700;
    color: #5d4037;
}

.difficulty-option[data-difficulty="hard"] .difficulty-name {
    color: #c0392b;
}

.difficulty-desc {
    font-size: clamp(0.6rem, 2vw, 0.8rem);
    color: #888;
}

/* ゲームオーバー画面 */
#gameover-screen {
    background: rgba(0, 0, 0, 0.8);
}

.gameover-content {
    text-align: center;
    max-height: 90vh;
    overflow-y: auto;
    padding: 10px;
}

.gameover-title {
    font-family: 'Dela Gothic One', cursive;
    font-size: clamp(1.8rem, 7vw, 3rem);
    color: #ff6b6b;
    text-shadow: 
        3px 3px 0 #8b0000,
        0 4px 10px rgba(0, 0, 0, 0.5);
    margin-bottom: 20px;
}

.gameover-animation {
    position: relative;
    width: 180px;
    height: 130px;
    margin: 0 auto 20px;
}

.fallen-sushi {
    position: absolute;
    width: 70px;
    height: auto;
    left: 50%;
    transform: translateX(-50%);
    animation: fall-into-soy 1s ease-in forwards;
    z-index: 2;
}

@keyframes fall-into-soy {
    0% {
        top: -50px;
        opacity: 1;
    }
    70% {
        top: 35px;
        opacity: 1;
    }
    100% {
        top: 45px;
        opacity: 0.7;
    }
}

.soy-sauce-dish {
    position: absolute;
    width: 160px;
    height: auto;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 15px;
}

.score-display span:first-child {
    font-size: clamp(0.9rem, 3.5vw, 1.3rem);
    color: #ffd700;
}

.final-score {
    font-family: 'Dela Gothic One', cursive;
    font-size: clamp(2.5rem, 10vw, 4rem);
    color: #fff;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.new-record {
    margin-bottom: 15px;
    font-size: clamp(1.2rem, 5vw, 1.8rem);
    color: #ffd700;
    animation: blink 0.5s ease-in-out infinite alternate;
}

@keyframes blink {
    from { opacity: 1; }
    to { opacity: 0.5; }
}

/* スコア登録 */
.score-register {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.score-register input {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: clamp(0.9rem, 3.5vw, 1.1rem);
    padding: 12px 20px;
    border: 3px solid #8b4513;
    border-radius: 10px;
    width: 80%;
    max-width: 250px;
    text-align: center;
}

.score-register input:focus {
    outline: none;
    border-color: #ff6b6b;
}

.register-result {
    margin-bottom: 15px;
    font-size: clamp(1rem, 4vw, 1.3rem);
    color: #7fff00;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
}

.gameover-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

/* ランキング画面 */
#ranking-screen {
    background: rgba(0, 0, 0, 0.9);
}

.ranking-content {
    background: linear-gradient(180deg, #fff8dc 0%, #f5deb3 100%);
    border-radius: 20px;
    padding: 25px;
    width: 90%;
    max-width: 450px;
    max-height: 85vh;
    text-align: center;
    box-shadow: 
        0 0 0 5px #8b4513,
        0 10px 30px rgba(0, 0, 0, 0.5);
}

.ranking-title {
    font-family: 'Dela Gothic One', cursive;
    font-size: clamp(1.5rem, 6vw, 2.2rem);
    color: #8b4513;
    margin-bottom: 15px;
}

.ranking-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 15px;
}

.ranking-tab {
    font-family: 'Noto Sans JP', sans-serif;
    font-size: clamp(0.8rem, 3vw, 1rem);
    font-weight: 700;
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background: #ddd;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
}

.ranking-tab.active {
    background: linear-gradient(180deg, #ff6b6b 0%, #c0392b 100%);
    color: white;
}

.ranking-tab:hover:not(.active) {
    background: #ccc;
}

.ranking-list {
    background: #fff;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 5px;
    border-bottom: 1px solid #eee;
}

.ranking-item:last-child {
    border-bottom: none;
}

.ranking-rank {
    font-weight: 700;
    font-size: clamp(1rem, 4vw, 1.2rem);
    color: #8b4513;
    width: 35px;
    text-align: center;
}

.ranking-rank.gold {
    color: #ffd700;
}

.ranking-rank.silver {
    color: #c0c0c0;
}

.ranking-rank.bronze {
    color: #cd7f32;
}

.ranking-name {
    flex: 1;
    text-align: left;
    margin-left: 10px;
    font-size: clamp(0.85rem, 3.5vw, 1rem);
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-score {
    font-weight: 700;
    font-size: clamp(1rem, 4vw, 1.2rem);
    color: #c0392b;
    margin-left: 10px;
}

.ranking-empty {
    color: #888;
    padding: 20px;
}

/* スコアHUD */
#score-hud {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: center;
}

#current-score {
    font-family: 'Dela Gothic One', cursive;
    font-size: clamp(2.5rem, 10vw, 4rem);
    color: #fff;
    text-shadow: 
        3px 3px 0 #333,
        0 4px 10px rgba(0, 0, 0, 0.5);
}

/* プレイ中トップ3 */
.game-top3 {
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    padding: 8px 12px;
    margin-top: 5px;
}

.game-top3-item {
    display: flex;
    align-items: center;
    font-size: clamp(0.6rem, 2vw, 0.75rem);
    color: #fff;
    padding: 2px 0;
}

.top3-rank {
    color: #ffd700;
    width: 18px;
}

.top3-name {
    flex: 1;
    margin: 0 5px;
    max-width: 80px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.top3-score {
    color: #ff6b6b;
    font-weight: bold;
    min-width: 30px;
    text-align: right;
}

/* 操作説明 */
#instruction {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 5;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

#instruction p {
    font-size: clamp(1rem, 4vw, 1.5rem);
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.5);
    padding: 20px 30px;
    border-radius: 15px;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* レスポンシブ対応 */
@media (max-width: 480px) {
    .modal-content {
        padding: 15px;
        max-height: 85vh;
    }
    
    .modal-title {
        font-size: 0.95rem;
        margin-bottom: 12px;
    }
    
    .character-select {
        gap: 8px;
        margin-bottom: 20px;
    }
    
    .character-option {
        padding: 8px;
    }
    
    .character-option img {
        width: 55px;
    }
    
    .difficulty-select {
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .difficulty-option {
        padding: 10px 15px;
        min-width: 120px;
    }
    
    .difficulty-name {
        font-size: 1rem;
    }
    
    .difficulty-desc {
        font-size: 0.65rem;
    }
    
    .game-btn {
        padding: 12px 40px;
        font-size: 1rem;
    }
    
    .gameover-animation {
        width: 150px;
        height: 110px;
    }
    
    .fallen-sushi {
        width: 55px;
    }
    
    .soy-sauce-dish {
        width: 130px;
    }
    
    /* タイトル画面ランキング */
    .title-rankings {
        gap: 10px;
        margin-bottom: 15px;
    }
    
    .title-ranking-section {
        padding: 8px 10px;
        min-width: 140px;
    }
    
    .title-ranking-section h3 {
        font-size: 0.7rem;
        margin-bottom: 5px;
    }
    
    .title-ranking-list {
        font-size: 0.6rem;
    }
    
    .title-ranking-item .rank {
        width: 16px;
    }
    
    .sushi-decoration {
        margin: 10px 0 10px;
    }
    
    .deco-sushi {
        width: 55px;
    }
}

@media (max-height: 700px) {
    .title-logo {
        max-width: 280px;
        margin-bottom: 10px;
    }
    
    .sushi-decoration {
        margin: 5px 0 8px;
    }
    
    .deco-sushi {
        width: 50px;
    }
    
    .title-rankings {
        margin-bottom: 10px;
    }
    
    .title-ranking-section {
        padding: 6px 8px;
    }
    
    .game-btn {
        padding: 10px 35px;
        margin-bottom: 8px;
    }
}

@media (orientation: landscape) and (max-height: 500px) {
    .title-logo {
        max-width: 250px;
        margin-bottom: 5px;
    }
    
    .sushi-decoration {
        margin: 5px 0 5px;
    }
    
    .deco-sushi {
        width: 40px;
    }
    
    .title-rankings {
        gap: 8px;
        margin-bottom: 8px;
    }
    
    .title-ranking-section {
        padding: 5px 8px;
        min-width: 120px;
    }
    
    .title-ranking-section h3 {
        font-size: 0.6rem;
        margin-bottom: 3px;
    }
    
    .title-ranking-list {
        font-size: 0.55rem;
    }
    
    .game-btn {
        padding: 8px 30px;
        font-size: 0.85rem;
        margin-bottom: 5px;
    }
    
    .modal-content {
        padding: 10px;
        max-height: 95vh;
    }
    
    .modal-title {
        margin-bottom: 8px;
        font-size: 0.9rem;
    }
    
    .character-select {
        margin-bottom: 10px;
        gap: 5px;
    }
    
    .character-option {
        padding: 5px;
    }
    
    .character-option img {
        width: 40px;
    }
    
    .character-option span {
        font-size: 0.6rem;
    }
    
    .difficulty-select {
        margin-bottom: 10px;
        gap: 8px;
    }
    
    .difficulty-option {
        padding: 8px 12px;
        min-width: 100px;
    }
    
    .difficulty-name {
        font-size: 0.85rem;
    }
    
    .difficulty-desc {
        font-size: 0.55rem;
    }
    
    .gameover-content {
        padding: 5px;
    }
    
    .gameover-title {
        margin-bottom: 10px;
        font-size: 1.5rem;
    }
    
    .gameover-animation {
        width: 120px;
        height: 90px;
        margin-bottom: 10px;
    }
    
    .fallen-sushi {
        width: 45px;
    }
    
    .soy-sauce-dish {
        width: 100px;
    }
}
