
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@700&display=swap');

body {
    font-family: 'Nunito', sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    background: linear-gradient(45deg, #ff9a9e 0%, #fecfef 99%, #fecfef 100%);
    flex-direction: column; /* 縦に並べる */
}

.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
}

.title-container {
    position: relative;
    margin-bottom: 20px;
}

h1 {
    font-size: clamp(32px, 10vw, 48px);
    color: white;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.5);
    margin: 0;
}

#score-container {
    display: flex;
    justify-content: space-between;
    width: 90vw;
    max-width: 416px;
    font-size: clamp(16px, 4vw, 24px);
    font-weight: bold;
    margin-bottom: 5px;
    padding: 10px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    box-sizing: border-box;
}

#objective-container, #timer-container {
    width: 90vw;
    max-width: 416px;
    font-size: clamp(14px, 3.5vw, 22px);
    font-weight: bold;
    margin-bottom: 10px;
    padding: 5px 10px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    box-sizing: border-box;
    text-align: center;
}

#game-board {
    position: relative;
    width: 90vw;
    height: 90vw;
    max-width: 416px;
    max-height: 416px;
    background-color: rgba(255, 255, 255, 0.5);
    border: 2px solid #fff;
    border-radius: 10px;
    aspect-ratio: 1 / 1;
    padding: 2px; /* Add padding for gap around the edge */
    box-sizing: border-box; /* Make sure padding is included in the size */
}

.tile {
    background-color: #fff;
    box-sizing: border-box;
    position: absolute; /* 親要素に対して絶対配置 */
    transition: transform 0.2s ease-in-out, top 0.3s ease-in-out, left 0.3s ease-in-out;
    border-radius: 5px;
}

.tile.selected {
    border: 3px solid #fff;
    transform: scale(1.1);
}

.tile.disappearing {
    animation: disappear 0.3s forwards;
}

@keyframes disappear {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0);
        opacity: 0;
    }
}

/* コンボポップアップのスタイル */
.combo-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(32px, 8vw, 48px);
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.8);
    animation: combo-animation 1s forwards;
    pointer-events: none;
    z-index: 100;
}

.level-up-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(48px, 12vw, 64px);
    font-weight: bold;
    color: #ffde59; /* Gold */
    text-shadow: 3px 3px 6px rgba(0,0,0,0.8);
    animation: level-up-animation 2.5s forwards;
    pointer-events: none;
    z-index: 101;
}

@keyframes level-up-animation {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

.screen-flash {
    animation: screen-flash-animation 0.5s forwards;
}

@keyframes screen-flash-animation {
    from {
        background-color: rgba(255, 255, 255, 0.5);
    }
    to {
        background-color: transparent;
    }
}

@keyframes combo-animation {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    50% {
        transform: translate(-50%, -50%) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0;
    }
}

/* ボードの揺れアニメーション */
.board-shaking {
    animation: board-shake 0.3s;
}

@keyframes board-shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* 特殊タイル用のスタイル */
.tile.rainbow-bomb {
    background: conic-gradient(red, yellow, lime, aqua, blue, magenta, red) !important;
    animation: rainbow-spin 2s linear infinite;
}

/* ゲームオーバー画面のスタイル */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

#game-over-box, #mode-selection-box {
    background-color: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}

#game-over-box h2, #mode-selection-box h2 {
    margin: 0 0 20px;
    font-size: 36px;
}

#play-again-btn, .mode-btn {
    padding: 10px 20px;
    font-size: 18px;
    cursor: pointer;
    border: none;
    background-color: #3498db;
    color: white;
    border-radius: 5px;
    margin: 0 10px;
}

.hidden {
    display: none !important;
}

#special-meter-container {
    width: 90vw;
    max-width: 416px;
    height: 20px;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    margin-bottom: 10px;
    border: 2px solid #fff;
}

#special-meter-bar {
    width: 0%;
    height: 100%;
    background-color: #ff9a9e;
    border-radius: 5px;
    transition: width 0.3s ease-in-out;
}

.particle {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 10;
    animation: particle-animation 0.8s forwards;
}

@keyframes particle-animation {
    from {
        transform: scale(1);
        opacity: 1;
    }
    to {
        transform: scale(0) translateY(50px);
        opacity: 0;
        top: var(--y);
        left: var(--x);
    }
}

.score-popup {
    position: absolute;
    font-size: 24px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
    pointer-events: none;
    z-index: 110;
    animation: score-popup-animation 1.5s forwards;
}

@keyframes score-popup-animation {
    0% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(-25px) scale(1.2);
        opacity: 1;
    }
    100% {
        transform: translateY(-50px) scale(1.5);
        opacity: 0;
    }
}

.shockwave {
    position: absolute;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: white;
    animation: shockwave-animation 0.5s forwards;
    z-index: 5;
    transform: translate(-50%, -50%);
}

@keyframes shockwave-animation {
    from {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }
    to {
        transform: translate(-50%, -50%) scale(4);
        opacity: 0;
    }
}

.score-text {
    color: #2980b9;
}

.level-text {
    color: #c0392b;
}

.high-score-text {
    color: #27ae60;
}

@media (orientation: landscape) and (max-height: 500px) {
    .container {
        flex-direction: row;
        align-items: flex-start;
    }

    #game-board {
        width: 80vh;
        height: 80vh;
    }

    .title-container {
        margin-bottom: 10px;
    }
}

.version-text {
    font-size: 20px;
    color: white;
    text-align: right;
    margin-top: -5px;
    margin-right: 10px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
}

@keyframes rainbow-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.special-tile.line-h::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    width: 70%;
    height: 10%;
}

.special-tile.line-v::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    width: 10%;
    height: 70%;
}

.special-tile.bomb::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    background-color: white;
    width: 50%;
    height: 50%;
    border-radius: 50%;
}

.tile.rainbow-bomb::before {
    content: '★';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    color: white;
    text-shadow: 0 0 5px black;
}

.special-tile.line-h, .special-tile.line-v, .special-tile.bomb {
    animation: special-tile-pulse 1.5s infinite;
}

@keyframes special-tile-pulse {
    0%, 100% {
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(255, 255, 255, 1);
    }
}

#badge-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 10px;
    gap: 5px;
}

.badge {
    width: 40px; /* Increased size */
    height: 40px; /* Increased size */
    background-color: transparent; /* Remove background */
    border: none; /* Remove border */
    border-radius: 0; /* Remove border-radius */
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 30px; /* Increase font size for the emoji */
    text-shadow: 0 0 5px rgba(0,0,0,0.3); /* Add shadow for better visibility */
}
