:root {
    --bg-color: #00050a;
    --star-white: rgba(255, 255, 255, 0.9);
    --line-color: rgba(200, 230, 255, 0.5);
    --accent-cyan: #00ffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-tap-highlight-color: transparent; /* タップ時のハイライトを消す */
}

body {
    background-color: var(--bg-color);
    background: radial-gradient(circle at center, #000c18 0%, #00050a 100%);
    color: white;
    font-family: "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    height: 100vh;
}

#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
}

/* --- Canvas (背景) --- */
#gameCanvas {
    display: block;
    touch-action: none;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10; /* game-screen(20)より下 */
}

#modalPreviewCanvas {
    width: 100%;
    height: 100%;
    display: block;
    /* z-indexはモーダル内のflowに従う。絶対値指定しない */
}

/* --- 共通スタイル --- */
button {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 12px 24px;
    border-radius: 24px;
    cursor: pointer;
    backdrop-filter: blur(5px);
    font-size: 1rem;
    letter-spacing: 0.1em;
    transition: all 0.3s ease;
}

button:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.2);
}

.hidden {
    display: none !important;
}

/* --- タイトル画面 --- */
#title-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 30; /* game-screen(20)より上 */
    background: rgba(0, 0, 0, 0.5);
}

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

.title-content h1 {
    font-weight: 100;
    letter-spacing: 0.5em;
    font-size: 4rem;
    text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.2em;
    margin-bottom: 60px;
}

.title-menu {
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

#start-btn {
    font-size: 1.2rem;
    padding: 15px 40px;
    background: rgba(0, 255, 255, 0.1);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.3);
}

/* --- ゲームプレイ画面 --- */
#game-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20; /* gameCanvas(10)より上 */
}

#ui-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 24px 24px 28px;
}

.top-bar {
    pointer-events: auto;
    text-align: center;
}

.bottom-bar {
    pointer-events: auto;
    display: flex;
    gap: 16px;
    justify-content: center;
    /* 背景をうっすらつけてボタンと星の境界を明確に */
    background: linear-gradient(to top, rgba(0, 5, 10, 0.7) 60%, transparent);
    padding: 20px 24px 8px;
    margin: 0 -24px -28px;
}

#next-btn {
    background: rgba(0, 255, 255, 0.15);
    border: 1px solid var(--accent-cyan);
    color: var(--accent-cyan);
    box-shadow: 0 0 12px rgba(0, 255, 255, 0.3);
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

h1#target-name {
    font-weight: 200;
    letter-spacing: 0.2em;
    font-size: 1.8rem;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

#target-story {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    max-width: 600px;
    margin: 15px auto;
    line-height: 1.6;
    background: rgba(0, 0, 0, 0.5);
    padding: 15px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

/* --- 星座図鑑画面 --- */
#collection-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 5, 10, 0.8);
    backdrop-filter: blur(10px);
    z-index: 40; /* title-screen(30)より上 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.collection-content {
    width: 90%;
    max-width: 400px;
    background: rgba(0, 10, 20, 0.9);
    padding: 30px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

#collection-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    margin: 30px 0;
    max-height: 50vh;
    overflow-y: auto;
}

.collection-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.4);
}

.collection-item.discovered {
    border: 1px solid rgba(0, 255, 255, 0.5);
    color: var(--accent-cyan);
    cursor: pointer;
    text-shadow: 0 0 5px var(--accent-cyan);
}

/* --- 星座詳細モーダル --- */
#constellation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 50; /* collection-screen(40)より上 */
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-body {
    width: 90%;
    max-width: 600px;
    background: #001020;
    border: 1px solid var(--accent-cyan);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.2);
}

.modal-layout {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    align-items: flex-start;
}

.preview-area {
    width: 200px;
    height: 200px;
    background: radial-gradient(circle at center, #001a33 0%, #00050a 100%);
    border: 1px solid var(--accent-cyan);
    border-radius: 15px;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: inset 0 0 20px rgba(0, 255, 255, 0.2);
    pointer-events: none; /* プレビュー自体は触れなくて良い */
}

.info-area {
    flex-grow: 1;
    font-size: 0.95rem;
    line-height: 1.7;
    color: rgba(255, 255, 255, 0.9);
    text-align: left;
}

#close-modal {
    margin-top: 10px;
    background: var(--accent-cyan);
    color: black;
    font-weight: bold;
}

/* スマホ用の縦並び対応 */
@media (max-width: 500px) {
    .modal-layout {
        flex-direction: column;
        align-items: center;
    }
    .preview-area {
        width: 150px;
        height: 150px;
    }
}
/* --- 図鑑カウンター --- */
.collection-counter {
    font-size: 0.85rem;
    letter-spacing: 0.15em;
    color: var(--accent-cyan);
    margin: -8px 0 16px;
    opacity: 0.8;
}

/* --- ヒント説明テキスト --- */
.hint-tip {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 8px;
    transition: opacity 0.5s;
}

/* 星座完成後はヒントテキストを非表示に */
.hint-tip.hidden {
    opacity: 0;
    pointer-events: none;
}

/* --- 観測情報テキスト --- */
.modal-observation {
    margin-top: 14px;
    padding: 10px 14px;
    border-left: 2px solid var(--accent-cyan);
    background: rgba(0, 255, 255, 0.05);
    border-radius: 0 8px 8px 0;
    font-size: 0.82rem;
    line-height: 1.8;
    color: rgba(255, 255, 255, 0.75);
    white-space: pre-line; /* \n で改行 */
    letter-spacing: 0.05em;
}
