/* ============================================
   底辺テトリス - スタイルシート
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Hiragino Kaku Gothic ProN', 'メイリオ', sans-serif;
    background: url('resources/images/IMG_20260421_224455.jpg') center center / cover no-repeat fixed;
    color: #fff;
    touch-action: manipulation;
}

.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.hidden {
    display: none !important;
}

/* ============================================
   スタート画面
   ============================================ */

#start-screen {
    background: radial-gradient(ellipse at center, rgba(42,42,78,0.7) 0%, rgba(26,26,46,0.7) 100%);
}

.title-container {
    text-align: center;
    margin-bottom: 40px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.game-title {
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(45deg, #ff6b6b, #feca57, #48dbfb, #ff9ff3);
    background-size: 400% 400%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradient 3s ease infinite;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.3);
}

@keyframes gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.subtitle {
    font-size: 1.5rem;
    color: #feca57;
    margin-top: 10px;
    opacity: 0.9;
}

.version {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 6px;
    letter-spacing: 0.1em;
}

.maro-title-image {
    width: 90px;
    height: auto;
    border-radius: 12px;
    flex-shrink: 0;
}

.start-buttons {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.menu-btn {
    padding: 15px 50px;
    font-size: 1.2rem;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    background: linear-gradient(45deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    min-width: 200px;
}

.menu-btn:hover, .menu-btn:active {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7); }
    50% { box-shadow: 0 0 0 15px rgba(102, 126, 234, 0); }
}

.credits {
    margin-top: 40px;
    text-align: center;
    opacity: 0.7;
}

.credits p {
    margin: 5px 0;
}

/* ============================================
   遊び方画面
   ============================================ */

#how-to-screen h2 {
    font-size: 2rem;
    margin-bottom: 30px;
    color: #feca57;
}

.instructions {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 30px;
    max-width: 350px;
}

.instruction-item {
    display: flex;
    align-items: center;
    margin: 15px 0;
    padding: 10px;
}

.instruction-item .icon {
    font-size: 2rem;
    margin-right: 15px;
    min-width: 40px;
}

.instruction-item p {
    font-size: 1rem;
    line-height: 1.5;
}

/* ============================================
   ゲーム画面
   ============================================ */

#game-screen {
    justify-content: flex-start;
    padding: 4px 4px 2px;
    background: radial-gradient(ellipse at center, rgba(30,10,60,0.6) 0%, rgba(13,13,26,0.6) 60%, rgba(0,0,0,0.6) 100%);
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

/* 上部ステータスバー */
.game-top-bar {
    display: flex;
    width: 100%;
    max-width: 500px;
    justify-content: space-between;
    align-items: flex-start;
    gap: 6px;
    flex-shrink: 0;
}

.top-stats-left {
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: stretch;
}

.top-stats-right {
    display: flex;
    flex-direction: row;
    gap: 4px;
    align-items: flex-start;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 30, 60, 0.6);
    border: 1px solid rgba(0, 220, 255, 0.3);
    padding: 5px 6px;
    border-radius: 8px;
    min-width: 48px;
}

.stat-label {
    font-size: 0.55rem;
    color: #0cf;
    letter-spacing: 0.1em;
    font-weight: bold;
}

.stat-value {
    font-size: 1rem;
    font-weight: bold;
    color: #fff;
}

.game-board-wrapper {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    flex: 1;
    min-height: 0;
    width: 100%;
}

#game-canvas {
    border: 3px solid #00dcff;
    border-radius: 4px;
    box-shadow: 0 0 15px rgba(0, 220, 255, 0.6),
                0 0 40px rgba(0, 220, 255, 0.2),
                inset 0 0 30px rgba(0, 0, 0, 0.5);
    background: rgba(0, 0, 0, 0.9);
}

.next-piece-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 30, 60, 0.6);
    border: 1px solid rgba(0, 220, 255, 0.3);
    padding: 4px;
    border-radius: 8px;
}

.next-label {
    font-size: 0.55rem;
    color: #0cf;
    margin-bottom: 2px;
    font-weight: bold;
    letter-spacing: 0.1em;
}

#next-canvas {
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
}

/* ============================================
   エネミーパネル
   ============================================ */

.enemy-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(60, 0, 0, 0.6);
    border: 1px solid rgba(255, 80, 80, 0.4);
    padding: 4px;
    border-radius: 8px;
    min-width: 52px;
}

.enemy-label {
    font-size: 0.55rem;
    color: #f88;
    margin-bottom: 2px;
    font-weight: bold;
    letter-spacing: 0.05em;
}

.enemy-image-wrap {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
}

#enemy-image {
    width: 44px;
    height: 44px;
    object-fit: cover;
    border-radius: 4px;
    transition: filter 0.15s ease;
}

#enemy-image.damage-flash {
    filter: brightness(3) saturate(0) invert(1);
}

.enemy-hp-bar-wrap {
    width: 44px;
    height: 6px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 3px;
    margin-top: 4px;
    overflow: hidden;
    border: 1px solid rgba(255, 80, 80, 0.3);
}

.enemy-hp-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #ff4444, #ff9933);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* エネミーメインロー（吹き出し＋画像横並び） */
.enemy-main-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
}

.enemy-visual {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* エネミー吹き出し */
.enemy-speech-bubble {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 80, 80, 0.4);
    border-radius: 8px;
    padding: 4px 6px;
    font-size: 0.6rem;
    color: #fff;
    text-align: center;
    line-height: 1.3;
    word-break: break-all;
    max-width: 64px;
}

.enemy-speech-bubble::before {
    content: '';
    position: absolute;
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 5px 0 5px 7px;
    border-style: solid;
    border-color: transparent transparent transparent rgba(255, 80, 80, 0.4);
}

/* ============================================
   タッチヒント
   ============================================ */

.touch-hint {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    padding: 2px 0;
    letter-spacing: 0.05em;
}

/* ============================================
   オーバーレイ画面
   ============================================ */

.overlay {
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
}

.overlay-content {
    text-align: center;
    padding: 30px;
    background: linear-gradient(145deg, #2a2a4e, #1a1a2e);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    max-width: 350px;
}

.overlay-content h2 {
    font-size: 2rem;
    margin-bottom: 20px;
    color: #feca57;
}

.overlay-content .menu-btn {
    margin: 10px 0;
    width: 100%;
}

.gameover-title {
    color: #ff6b6b !important;
}

.final-stats {
    margin: 20px 0;
    font-size: 1.2rem;
}

.final-stats p {
    margin: 10px 0;
}

.final-quote {
    font-size: 1rem;
    padding: 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    margin-bottom: 20px;
    font-style: italic;
}

.maro-speech-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
}

.maro-image {
    width: 72px;
    height: auto;
    border-radius: 8px;
    flex-shrink: 0;
}

.speech-bubble {
    position: relative;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 12px 15px;
    font-size: 1rem;
    font-style: italic;
    color: #fff;
    text-align: center;
    max-width: 200px;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 8px 10px 8px 0;
    border-style: solid;
    border-color: transparent rgba(255, 255, 255, 0.15) transparent transparent;
}

/* ============================================
   クリア画面
   ============================================ */

.celebration {
    animation: celebrationZoom 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes celebrationZoom {
    0% { transform: scale(0.3); opacity: 0; }
    60% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); }
}

.clear-title {
    font-size: 2.5rem !important;
    color: #feca57 !important;
    animation: rainbow 1.5s linear infinite, titleBounce 0.8s ease-out;
}

@keyframes rainbow {
    0% { color: #ff6b6b; text-shadow: 0 0 20px #ff6b6b; }
    25% { color: #feca57; text-shadow: 0 0 20px #feca57; }
    50% { color: #48dbfb; text-shadow: 0 0 20px #48dbfb; }
    75% { color: #ff9ff3; text-shadow: 0 0 20px #ff9ff3; }
    100% { color: #ff6b6b; text-shadow: 0 0 20px #ff6b6b; }
}

@keyframes titleBounce {
    0% { transform: scale(0.5) translateY(-20px); }
    70% { transform: scale(1.15) translateY(0); }
    100% { transform: scale(1); }
}

.clear-message {
    font-size: 1.3rem;
    margin: 20px 0;
}

.clear-message p {
    margin: 5px 0;
}

/* カウントダウン */
.clear-countdown {
    font-size: 4rem;
    font-weight: bold;
    color: #feca57;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-shadow: 0 0 20px rgba(254, 202, 87, 0.8);
}

@keyframes countdownPop {
    0% { transform: scale(1.8); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

.countdown-tick {
    animation: countdownPop 0.3s ease-out;
}

/* ボタン無効状態 */
.btn-disabled {
    opacity: 0.25;
    pointer-events: none;
    cursor: default;
}

/* ボタン出現アニメーション */
@keyframes btnAppear {
    0% { transform: scale(0.7); opacity: 0.2; }
    65% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.btn-appear {
    animation: btnAppear 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

/* 画面フラッシュ */
@keyframes screenFlash {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

#screen-flash {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    z-index: 9999;
    pointer-events: none;
    animation: screenFlash 0.7s ease-out forwards;
}

/* ============================================
   パーティクルキャンバス
   ============================================ */

#particle-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* ============================================
   レスポンシブ調整
   ============================================ */

@media (max-height: 700px) {
    .stat-box {
        padding: 4px 5px;
    }
    
    .stat-value {
        font-size: 0.9rem;
    }

    .enemy-image-wrap,
    #enemy-image {
        width: 38px;
        height: 38px;
    }

    .enemy-hp-bar-wrap {
        width: 38px;
    }
}

@media (max-height: 600px) {
    .touch-hint {
        display: none;
    }
}

@media (min-width: 768px) {
    .game-title {
        font-size: 4rem;
    }
    
    .stat-label {
        font-size: 0.7rem;
    }
    
    .stat-value {
        font-size: 1.3rem;
    }

    .enemy-image-wrap,
    #enemy-image {
        width: 56px;
        height: 56px;
    }

    .enemy-hp-bar-wrap {
        width: 56px;
    }
}

/* ============================================
   ブロックフラッシュエフェクト
   ============================================ */

.line-clear-flash {
    animation: lineFlash 0.3s ease-out;
}

@keyframes lineFlash {
    0% { filter: brightness(1); }
    50% { filter: brightness(3); }
    100% { filter: brightness(1); }
}

/* ============================================
   ハードドロップ シェイクエフェクト
   ============================================ */

@keyframes hardDropShake {
    0%   { transform: translate(0, 0); }
    20%  { transform: translate(-4px, 3px); }
    40%  { transform: translate(4px, -3px); }
    60%  { transform: translate(-3px, 2px); }
    80%  { transform: translate(3px, -2px); }
    100% { transform: translate(0, 0); }
}

#game-canvas.hard-drop-shake {
    animation: hardDropShake 0.28s ease-out;
}

/* ============================================
   スクロール防止
   ============================================ */

body {
    overscroll-behavior: none;
    position: fixed;
    width: 100%;
    height: 100%;
}
