* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
    background-color: #2c3e50;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

#app-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    background-color: #ecf0f1;
    color: #333;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

#game-container,
#top-page {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* トップページ専用スタイル */
#top-page {
    justify-content: flex-start;
    align-items: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
}

.game-title {
    font-size: 32px;
    color: #2c3e50;
    text-align: center;
    margin-bottom: 30px;
    text-shadow: 1px 1px 0px #fff, 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.character-preview {
    width: 150px;
    height: 150px;
    margin-bottom: 30px;
    animation: floating 3s ease-in-out infinite;
}

.preview-svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 5px 5px rgba(0, 0, 0, 0.2));
}

@keyframes floating {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

/* ランキングエリア */
.ranking-panel {
    background: #fff;
    width: 100%;
    max-width: 400px;
    border-radius: 15px;
    padding: 20px;
    margin-top: 40px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
}

.ranking-panel h2 {
    font-size: 18px;
    text-align: center;
    color: #34495e;
    margin: 0;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
    padding-bottom: 10px;
}

.ranking-tabs {
    display: flex;
    gap: 8px;
}

.ranking-tab {
    background: transparent;
    color: #95a5a6;
    border: 1px solid #95a5a6;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.ranking-tab.active {
    color: #e74c3c;
    border-color: #e74c3c;
    background-color: rgba(231, 76, 60, 0.1);
}

#ranking-list {
    list-style: none;
    padding: 0;
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid #f1f2f6;
    font-size: 16px;
}

#ranking-list li:nth-child(1) {
    font-weight: bold;
    color: #f1c40f;
}

#ranking-list li:nth-child(2) {
    font-weight: bold;
    color: #95a5a6;
}

#ranking-list li:nth-child(3) {
    font-weight: bold;
    color: #cd7f32;
}

/* 共通ボタンクラス */
.primary-btn,
.secondary-btn {
    padding: 15px 30px;
    font-size: 20px;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.1s;
}

.primary-btn {
    background-color: #e74c3c;
    color: #fff;
    box-shadow: 0 5px 0 #c0392b;
}

.primary-btn:hover {
    background-color: #c0392b;
}

.primary-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #c0392b;
}

.secondary-btn {
    background-color: #3498db;
    color: #fff;
    box-shadow: 0 5px 0 #2980b9;
}

.secondary-btn:hover {
    background-color: #2980b9;
}

.secondary-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #2980b9;
}

/* ポータルに戻るボタン */
.back-to-portal {
    position: absolute;
    top: 15px;
    left: 15px;
    color: #34495e;
    font-size: 0.9rem;
    text-decoration: none;
    font-weight: bold;
    border: 2px solid #34495e;
    padding: 8px 15px;
    border-radius: 50px;
    z-index: 1000;
    transition: 0.3s;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(5px);
}

.back-to-portal:hover {
    background: #34495e;
    color: #fff;
}

.clear-buttons {
    display: flex;
    gap: 15px;
}

header {
    background-color: #34495e;
    color: #ecf0f1;
    padding: 15px;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

h1 {
    font-size: 24px;
    margin-bottom: 10px;
}

.stats {
    display: flex;
    justify-content: space-around;
    font-size: 20px;
    font-weight: bold;
}

#game-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: radial-gradient(circle, #fff 0%, #e0e0e0 100%);
    cursor: crosshair;
}

#ojisan {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 250px;
    text-align: center;
}

#ojisan svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 10px 10px rgba(0, 0, 0, 0.2));
}

#ojisan-message {
    position: absolute;
    top: -40px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 8px 15px;
    border-radius: 20px;
    border: 3px solid #333;
    font-size: 16px;
    font-weight: bold;
    white-space: nowrap;
    animation: bounce 2s infinite;
    z-index: 5;
}

#ojisan-message::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 12px 12px 0;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

#ojisan-message::before {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 9px 9px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
    z-index: 1;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateX(-50%) translateY(0);
    }

    50% {
        transform: translateX(-50%) translateY(-10px);
    }
}

#hairs-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through container */
}

.hair,
.fake-hair {
    position: absolute;
    width: 25px;
    height: 25px;
    cursor: pointer;
    pointer-events: auto;
    /* Re-enable clicks on hairs */
    /* クソゲーっぽい縮れ毛をCSSで表現 */
    border-bottom: 3px solid #111;
    border-right: 2px solid transparent;
    border-top: 1px solid transparent;
    border-left: 2px solid #111;
    border-radius: 60% 30% 70% 20%;
    transform-origin: center;
    transition: transform 0.1s;
    animation: wiggle 2s infinite alternate ease-in-out;
}

.hair:hover {
    transform: scale(1.5) !important;
    border-color: #e74c3c;
    border-bottom-width: 5px;
    border-left-width: 4px;
}

@keyframes wiggle {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(45deg) translate(2px, 2px);
    }
}

.hair.collected,
.fake-hair.collected {
    transform: scale(0) rotate(360deg) !important;
    opacity: 0;
    transition: all 0.3s;
}

.fake-hair {
    border-bottom-color: #555;
    border-left-color: #555;
    border-radius: 40% 60% 50% 30%;
}

.fake-hair:hover {
    transform: scale(1.5) !important;
    border-color: #e67e22;
    border-bottom-width: 5px;
    border-left-width: 4px;
}

/* 怒った時の顔用 */
#face-skin {
    transition: fill 0.2s ease-in-out;
}

.angry-face #face-skin {
    fill: #ff9999 !important;
    /* 肌が赤くなる */
}

#clear-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(44, 62, 80, 0.9);
    color: #f1c40f;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.clear-buttons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

#clear-screen.hidden {
    display: none;
}

#clear-screen h2 {
    font-size: 40px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#clear-screen p {
    font-size: 24px;
    margin-bottom: 30px;
    color: #fff;
}

#retry-btn {
    padding: 15px 30px;
    font-size: 20px;
    font-weight: bold;
    background-color: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 5px 0 #c0392b;
    transition: all 0.1s;
}

#retry-btn:hover {
    background-color: #c0392b;
}

#retry-btn:active {
    transform: translateY(5px);
    box-shadow: 0 0 0 #c0392b;
}

@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.grown-hair {
    animation: growIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: center bottom;
}

@keyframes growIn {
    0% {
        opacity: 0;
        transform: scale(0);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Ofuse Floating Button */
.ofuse-floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff4081, #ff79b0);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 4px 15px rgba(255, 64, 129, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    transition: all 0.3s ease;
    font-family: 'Hiragino Maru Gothic ProN', 'Meiryo', sans-serif;
}

.ofuse-floating-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 64, 129, 0.6);
    color: white;
}

.ofuse-icon {
    font-size: 1.2rem;
}

/* スマホ表示向けの調整（BACK TO PORTALボタンとの被り防止） */
@media (max-width: 600px) {
    #top-page {
        padding-top: 60px;
    }

    header {
        padding-top: 60px;
    }

    #clear-screen {
        padding-top: 60px;
    }

    .back-to-portal {
        font-size: 0.8rem;
        padding: 6px 10px;
        top: 10px;
        left: 10px;
    }
}