/* リセットCSS */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    color: #ffffff;
    overflow: hidden;
    height: 100vh;
}

/* 基本レイアウト */
#app {
    width: 100vw;
    height: 100vh;
    position: relative;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease;
}

.hidden {
    opacity: 0;
    pointer-events: none;
}

/* ローディング画面 */
#loading-screen {
    background: #1a1a2e;
}

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

.loading-content h1 {
    font-size: 3rem;
    margin-bottom: 2rem;
    color: #ffcc00;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #333;
    border-top: 4px solid #ffcc00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* メイン画面 */
.main-content {
    text-align: center;
    max-width: 600px;
    padding: 2rem;
}

.game-title {
    font-size: 4rem;
    margin-bottom: 3rem;
    color: #ffcc00;
    text-shadow: 3px 3px 6px rgba(0,0,0,0.7);
    letter-spacing: 3px;
}

.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
}

.menu-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.primary-btn {
    background: #ffcc00;
    color: #1a1a2e;
    font-weight: bold;
}

.primary-btn:hover {
    background: #ffdd00;
}

/* ユーザー情報表示 */
.user-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    margin-top: 1rem;
}

.logout-btn {
    padding: 0.5rem 1rem;
    background: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.logout-btn:hover {
    background: #cc3333;
}

/* ゲーム画面 */
#game-screen {
    background: #1a1a2e;
    align-items: stretch;
}

.game-ui {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.top-ui {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10;
}

.score-display, .distance-display {
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffcc00;
}

.pause-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.5rem;
}

#game-canvas {
    flex: 1;
    width: 100%;
    background: #2a4858;
    display: block;
}

/* モバイルコントロール */
.mobile-controls {
    display: none;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.8);
    justify-content: space-between;
    align-items: center;
}

.control-btn {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.5rem;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    transition: background 0.3s ease;
    min-width: 80px;
    min-height: 60px;
}

.control-btn:active {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0.95);
}

.center-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* モーダル */
.modal {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    padding: 2rem;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 2rem;
    color: #ffcc00;
    font-size: 2rem;
}

/* 設定画面 */
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.setting-group {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
}

.setting-group label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem;
    color: #ffcc00;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0.5rem 0;
}

.setting-item label {
    font-weight: normal;
    color: white;
    margin-bottom: 0;
    flex: 1;
}

.setting-item input[type="range"] {
    width: 150px;
    margin: 0 1rem;
}

.setting-item select {
    padding: 0.5rem;
    border-radius: 4px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* フォーム */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: bold;
    color: #ffcc00;
}

.form-group input {
    padding: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: #ffcc00;
    background: rgba(255, 255, 255, 0.15);
}

.form-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* ランキング */
.ranking-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.ranking-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    margin: 0.5rem 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.ranking-rank {
    font-weight: bold;
    color: #ffcc00;
    min-width: 3rem;
}

.ranking-name {
    flex: 1;
    text-align: center;
}

.ranking-score {
    font-weight: bold;
    min-width: 5rem;
    text-align: right;
}

/* ゲームオーバー画面 */
.final-scores {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
}

.score-item {
    display: flex;
    justify-content: space-between;
    font-size: 1.1rem;
}

.score-item span:last-child {
    color: #ffcc00;
    font-weight: bold;
}

/* トースト通知 */
.toast {
    position: fixed;
    top: 2rem;
    right: 2rem;
    background: #ff4444;
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    max-width: 300px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.success {
    background: #44aa44;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(100%);
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 1rem;
}

/* ユーティリティクラス */
.mobile-only {
    display: none;
}

/* アニメーション */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in {
    animation: fadeIn 0.5s ease forwards;
}