/**
 * Gen Generator - レトロスタイル
 * カラー: #043e80 (青) + #f5b500 (黄色)
 */

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

body {
    background: #000000;
    font-family: "MS UI Gothic", "MS Gothic", "Courier New", monospace;
    color: #f5b500;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.container {
    width: 100%;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* ==================== ヘッダー ==================== */
.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: #043e80;
    border: 4px solid #f5b500;
    box-shadow: 4px 4px 0 #000000;
}

.header h1 {
    font-size: 36px;
    color: #f5b500;
    text-shadow: 2px 2px 0 #000000;
    letter-spacing: 2px;
}

.subtitle {
    font-size: 16px;
    margin-top: 10px;
    color: #fff;
}

/* ==================== スタート画面 ==================== */
.start-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 600px;
}

.start-content {
    background: #043e80;
    border: 4px solid #f5b500;
    padding: 40px;
    box-shadow: 8px 8px 0 #000000;
    width: 100%;
}

.game-title {
    font-size: 48px;
    text-align: center;
    margin-bottom: 30px;
    color: #f5b500;
    text-shadow: 3px 3px 0 #000000;
    letter-spacing: 3px;
}

.instructions {
    background: #1a1a1a;
    border: 3px solid #f5b500;
    padding: 20px;
    margin-bottom: 30px;
}

.instructions h2 {
    color: #f5b500;
    margin-bottom: 15px;
    text-align: center;
    font-size: 20px;
}

.instructions ul {
    list-style: none;
}

.instructions li {
    margin-bottom: 10px;
    padding-left: 20px;
    position: relative;
    color: #fff;
}

.instructions li::before {
    content: "▶";
    position: absolute;
    left: 0;
    color: #f5b500;
}

.start-button {
    width: 100%;
    padding: 20px;
    font-size: 24px;
    font-weight: bold;
    background: #f5b500;
    color: #000000;
    border: 4px solid #000000;
    cursor: pointer;
    box-shadow: 4px 4px 0 #000000;
    transition: all 0.1s;
    text-transform: uppercase;
}

.start-button:hover {
    background: #ffcc33;
}

.start-button:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000000;
}

.link-container {
    text-align: center;
    margin-top: 20px;
}

.back-link {
    color: #f5b500;
    text-decoration: none;
    font-size: 14px;
    border-bottom: 2px solid #f5b500;
}

.back-link:hover {
    color: #ffcc33;
    border-bottom-color: #ffcc33;
}

/* ==================== ゲーム画面 ==================== */
.game-screen {
    width: 100%;
    max-width: 600px;
}

/* ステータスバー */
.status-bar {
    display: flex;
    justify-content: space-around;
    background: #000000;
    border: 3px solid #f5b500;
    padding: 15px;
    margin-bottom: 20px;
    box-shadow: 4px 4px 0 #043e80;
}

.status-item {
    text-align: center;
}

.status-item .label {
    display: block;
    font-size: 12px;
    color: #888;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.status-item .value {
    display: block;
    font-size: 28px;
    font-weight: bold;
    color: #f5b500;
    text-shadow: 2px 2px 0 #000000;
}

/* カウントダウン */
.countdown {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.countdown-number {
    font-size: 120px;
    font-weight: bold;
    color: #f5b500;
    text-shadow: 4px 4px 0 #000000;
    animation: countdownPulse 1s ease-out;
}

@keyframes countdownPulse {
    0% { transform: scale(0.5); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

/* ランダム拍数表示 */
.beat-target {
    text-align: center;
    margin-bottom: 20px;
    padding: 15px;
    background: #043e80;
    border: 3px solid #f5b500;
    box-shadow: 4px 4px 0 #000000;
}

.current-beat-display {
    margin-bottom: 10px;
}

.next-beat-display {
    opacity: 0.7;
}

.beat-target-label {
    font-size: 14px;
    color: #fff;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.beat-target-label-small {
    font-size: 11px;
    color: #ccc;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.beat-target-number {
    font-size: 48px;
    font-weight: bold;
    color: #f5b500;
    text-shadow: 3px 3px 0 #000000;
}

.beat-target-number-small {
    font-size: 24px;
    font-weight: bold;
    color: #f5b500;
    text-shadow: 2px 2px 0 #000000;
}

/* 円コンテナ */
.circle-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin: 0 auto 30px;
}

/* 中央の画像 */
.center-image-wrapper {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60%;
    height: 60%;
    z-index: 1;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid #f5b500;
}

.center-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gray-mask-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

svg {
    width: 100%;
    height: auto;
    display: block;
    position: relative;
    z-index: 2;
}

/* SVG円 */
.circle-bg {
    fill: none;
    stroke: #333;
    stroke-width: 12;
}

.circle-progress {
    fill: none;
    stroke: #f5b500;
    stroke-width: 12;
    stroke-dasharray: 502.65;
    stroke-dashoffset: 502.65;
    transform: rotate(-90deg);
    transform-origin: center;
    display: none;
}

/* 拍マーカー（0,3,6,9時） */
.beat-marker {
    fill: #666;
    stroke: #fff;
    stroke-width: 2;
    transition: all 0.2s;
}

.beat-marker.required {
    fill: #f5b500;
    stroke: #000000;
    stroke-width: 3;
    animation: requiredPulse 1s ease-in-out infinite;
}

@keyframes requiredPulse {
    0%, 100% {
        r: 12;
        opacity: 1;
    }
    50% {
        r: 16;
        opacity: 0.8;
    }
}

.beat-marker.active {
    fill: #ff0000;
    stroke: #000000;
    animation: markerPulse 0.3s ease-out;
}

@keyframes markerPulse {
    0% { r: 10; }
    50% { r: 14; }
    100% { r: 10; }
}

.beat-marker.clicked {
    fill: #f5b500;
    stroke: #fff;
}

/* 判定表示 */
.judgment {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 48px;
    font-weight: bold;
    text-shadow: 3px 3px 0 #000000;
    pointer-events: none;
    display: none;
    animation: judgmentPop 0.5s ease-out;
}

@keyframes judgmentPop {
    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: 1; }
}

/* タップエリア */
.tap-area {
    width: 100%;
    max-width: 600px;
    height: 80px;
    margin: 0 auto;
    background: #f5b500;
    border: 4px solid #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 4px 4px 0 #043e80;
}

.tap-area:hover {
    background: #ffcc33;
}

.tap-area:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #043e80;
}

.tap-instruction {
    font-size: 24px;
    font-weight: bold;
    color: #000000;
    text-shadow: none;
    text-transform: uppercase;
}

/* フラッシュエフェクト */
.flash-effect {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
    z-index: 9999;
}

/* ==================== ゲームオーバー画面 ==================== */
.gameover-screen {
    display: none;
    width: 100%;
    max-width: 600px;
    flex-direction: column;
    align-items: center;
}

.gameover-content {
    background: #043e80;
    border: 4px solid #f5b500;
    padding: 40px;
    width: 100%;
    box-shadow: 8px 8px 0 #000000;
}

.gameover-title {
    font-size: 48px;
    text-align: center;
    color: #f5b500;
    text-shadow: 3px 3px 0 #000000;
    margin-bottom: 30px;
    letter-spacing: 3px;
}

.final-score {
    text-align: center;
    margin-bottom: 30px;
}

.score-label {
    font-size: 18px;
    color: #fff;
    margin-bottom: 10px;
    text-transform: uppercase;
}

.score-value {
    font-size: 64px;
    font-weight: bold;
    color: #f5b500;
    text-shadow: 4px 4px 0 #000000;
}

.final-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    padding: 20px;
    background: #000000;
    border: 3px solid #f5b500;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 14px;
    color: #888;
    margin-bottom: 5px;
    text-transform: uppercase;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: #f5b500;
    text-shadow: 2px 2px 0 #000000;
}

/* スコア登録 */
.score-registration {
    margin-bottom: 20px;
}

.score-registration h3 {
    text-align: center;
    color: #f5b500;
    margin-bottom: 20px;
    text-transform: uppercase;
}

.score-registration input {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    background: #000000;
    border: 3px solid #f5b500;
    color: #f5b500;
    margin-bottom: 15px;
    font-family: "MS UI Gothic", "MS Gothic", "Courier New", monospace;
}

.score-registration input:focus {
    outline: none;
    border-color: #ffcc33;
}

.submit-button {
    width: 100%;
    padding: 15px;
    font-size: 20px;
    font-weight: bold;
    background: #f5b500;
    color: #000000;
    border: 4px solid #000000;
    cursor: pointer;
    margin-bottom: 10px;
    box-shadow: 4px 4px 0 #000000;
    text-transform: uppercase;
}

.submit-button:hover {
    background: #ffcc33;
}

.submit-button:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000000;
}

.skip-button {
    width: 100%;
    padding: 10px;
    font-size: 16px;
    background: #333;
    color: #fff;
    border: 3px solid #666;
    cursor: pointer;
    box-shadow: 2px 2px 0 #000000;
}

.skip-button:hover {
    background: #444;
}

.skip-button:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 #000000;
}

.error-message {
    background: #ff0000;
    color: #fff;
    padding: 10px;
    margin-bottom: 15px;
    text-align: center;
    border: 3px solid #000000;
}

/* アクションボタン */
.action-buttons {
    display: none;
    flex-direction: column;
    gap: 15px;
}

.action-button {
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    background: #f5b500;
    color: #000000;
    border: 4px solid #000000;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    box-shadow: 4px 4px 0 #000000;
    text-transform: uppercase;
}

.action-button:hover {
    background: #ffcc33;
}

.action-button:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000000;
}

/* ==================== ランキングモーダル ==================== */
.ranking-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}

.ranking-content {
    background: #043e80;
    border: 4px solid #f5b500;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 8px 8px 0 #000000;
}

.ranking-content h2 {
    text-align: center;
    color: #f5b500;
    margin-bottom: 20px;
    text-shadow: 2px 2px 0 #000000;
    text-transform: uppercase;
    letter-spacing: 2px;
}

.ranking-content h3 {
    text-align: center;
    color: #f5b500;
    margin-bottom: 15px;
    font-size: 20px;
    text-transform: uppercase;
}

.ranking-period-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.ranking-period-selector button {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: bold;
    background: #1a1a1a;
    color: #f5b500;
    border: 3px solid #f5b500;
    cursor: pointer;
    transition: all 0.1s;
    box-shadow: 2px 2px 0 #000000;
    text-transform: uppercase;
}

.ranking-period-selector button:hover {
    background: #333;
}

.ranking-period-selector button:active {
    transform: translate(2px, 2px);
    box-shadow: 0 0 0 #000000;
}

.ranking-period-selector button.active {
    background: #f5b500;
    color: #000000;
    border-color: #000000;
}

.ranking-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
    border: 3px solid #000000;
}

.ranking-table th {
    background: #000000;
    color: #f5b500;
    padding: 10px;
    border: 2px solid #f5b500;
    text-transform: uppercase;
    font-size: 14px;
}

.ranking-table td {
    padding: 10px;
    border: 2px solid #333;
    text-align: center;
    background: #0a0a0a;
    color: #fff;
}

.ranking-table tr:nth-child(odd) td {
    background: #0a0a0a;
}

.ranking-table tr:nth-child(even) td {
    background: #000000;
}

.ranking-table .rank-1 td {
    color: #f5b500;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000000;
}

.ranking-table .rank-2 td {
    color: #c0c0c0;
    font-weight: bold;
}

.ranking-table .rank-3 td {
    color: #cd7f32;
    font-weight: bold;
}

.close-button {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    background: #333;
    color: #fff;
    border: 3px solid #666;
    cursor: pointer;
    box-shadow: 4px 4px 0 #000000;
    text-transform: uppercase;
}

.close-button:hover {
    background: #444;
}

.close-button:active {
    transform: translate(4px, 4px);
    box-shadow: 0 0 0 #000000;
}

.loading, .error, .empty {
    text-align: center;
    padding: 40px;
    color: #f5b500;
}

/* ==================== レスポンシブ ==================== */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 5px;
        min-height: 100vh;
        justify-content: flex-start;
    }

    .header {
        padding: 8px;
        margin-bottom: 8px;
        border-width: 2px;
        box-shadow: 2px 2px 0 #000000;
    }

    .header h1 {
        font-size: 18px;
    }

    .subtitle {
        font-size: 10px;
    }

    .game-title {
        font-size: 28px;
    }

    .instructions {
        padding: 15px;
        font-size: 14px;
        max-height: 40vh;
        overflow-y: auto;
    }

    .instructions h2 {
        font-size: 18px;
    }

    .instructions li {
        font-size: 13px;
        margin-bottom: 8px;
    }

    .start-content {
        padding: 20px 15px;
        box-shadow: 6px 6px 0 #000000;
    }

    .start-button {
        padding: 15px;
        font-size: 20px;
        box-shadow: 3px 3px 0 #000000;
    }

    .status-bar {
        padding: 5px;
        margin-bottom: 8px;
        box-shadow: 2px 2px 0 #043e80;
        border-width: 2px;
    }

    .status-item .label {
        font-size: 9px;
    }

    .status-item .value {
        font-size: 16px;
    }

    .countdown-number {
        font-size: 80px;
    }

    .beat-target {
        padding: 6px;
        margin-bottom: 8px;
        box-shadow: 2px 2px 0 #000000;
        border-width: 2px;
    }

    .beat-target-label {
        font-size: 10px;
    }

    .beat-target-number {
        font-size: 28px;
    }

    .circle-container {
        max-width: 250px;
        margin-bottom: 10px;
    }

    .judgment {
        font-size: 24px;
    }

    .tap-area {
        height: 50px;
        margin-bottom: 8px;
        box-shadow: 2px 2px 0 #043e80;
        border-width: 2px;
    }

    .tap-instruction {
        font-size: 14px;
    }

    .gameover-content {
        padding: 20px 15px;
        box-shadow: 6px 6px 0 #000000;
    }

    .gameover-title {
        font-size: 32px;
        margin-bottom: 20px;
    }

    .score-value {
        font-size: 40px;
    }

    .final-stats {
        padding: 15px;
        margin-bottom: 20px;
    }

    .stat-value {
        font-size: 20px;
    }

    .score-registration input {
        padding: 12px;
        font-size: 16px;
    }

    .ranking-content {
        padding: 20px 15px;
        box-shadow: 6px 6px 0 #000000;
    }

    .ranking-content h2 {
        font-size: 20px;
    }

    .ranking-table {
        font-size: 14px;
    }

    .ranking-table th,
    .ranking-table td {
        padding: 8px 5px;
    }

    .submit-button,
    .action-button,
    .close-button {
        box-shadow: 3px 3px 0 #000000;
    }

    .submit-button:active,
    .action-button:active,
    .close-button:active {
        transform: translate(3px, 3px);
    }
}
