/* リセットとベーススタイル */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden; /* スクロール防止 */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #1a1a2e;
    color: #ffffff;
    user-select: none; /* テキスト選択防止 */
    -webkit-user-select: none;
    -webkit-touch-callout: none; /* iOS長押しメニュー防止 */
    -webkit-tap-highlight-color: transparent; /* タップハイライト削除 */
}

/* ゲームコンテナ */
.game-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    touch-action: none; /* タッチ操作の最適化 */
}

/* メインゲームエリア */
.game-area {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

/* ゲームタイトル */
.game-title {
    text-align: center;
    margin-bottom: 20px;
    z-index: 5;
}

.game-title h1 {
    font-size: 48px;
    font-weight: bold;
    color: #00d4ff;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.6);
    margin-bottom: 8px;
    letter-spacing: 2px;
}

.game-subtitle {
    font-size: 16px;
    color: #a0a0a0;
    margin: 0;
    font-weight: 300;
}

/* 描画キャンバス */
.drawing-canvas {
    background-color: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    cursor: crosshair;
    touch-action: none; /* タッチ操作の最適化 */
    max-width: 100%;
    max-height: calc(100vh - 160px);
}

/* 結果表示モーダル */
.result-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s ease;
}

.result-modal.show {
    opacity: 1;
    visibility: visible;
}

.result-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 25px;
    padding: 30px;
    text-align: center;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    border: 2px solid rgba(0, 212, 255, 0.3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.4s ease-out;
}

@keyframes modalSlideIn {
    0% {
        transform: scale(0.8) translateY(50px);
        opacity: 0;
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

/* 結果画面タイトル */
.result-title {
    text-align: center;
    margin-bottom: 15px;
}

.result-title h2 {
    font-size: 28px;
    font-weight: bold;
    color: #00d4ff;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.5);
    margin-bottom: 0;
}

.result-title p {
    font-size: 14px;
    color: #a0a0a0;
    margin: 0;
}

/* 円のプレビュー */
.circle-preview {
    margin-bottom: 15px;
}

.preview-canvas {
    background-color: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 15px;
    width: 200px;
    height: 200px;
    margin: 0 auto;
}

/* スコアセクション */
.score-section {
    margin-bottom: 20px;
}

.main-score {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 15px;
}

.score-value {
    font-size: 72px;
    font-weight: bold;
    color: #00ff88;
    text-shadow: 0 0 20px rgba(0, 255, 136, 0.6);
}

.score-label {
    font-size: 24px;
    color: #a0a0a0;
}

.score-details {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
}

.detail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.detail-label {
    font-size: 12px;
    color: #a0a0a0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.detail-value {
    font-size: 18px;
    font-weight: bold;
    color: #00d4ff;
}

.detail-sub {
    font-size: 11px;
    color: #888;
    font-weight: normal;
}



/* スコア内訳（10段階評価・コンパクト表示） */
.score-breakdown-compact {
    display: flex;
    justify-content: space-around;
    gap: 15px;
    margin: 0 auto 15px;
    padding: 10px 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    max-width: 320px;
}

.score-item-compact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.score-item-label {
    font-size: 11px;
    color: #a0a0a0;
    font-weight: 500;
    letter-spacing: 0.5px;
}

.score-item-value {
    font-size: 24px;
    font-weight: bold;
    color: #00d4ff;
    text-shadow: 0 0 10px rgba(0, 212, 255, 0.5);
}

.evaluation-message {
    font-size: 18px;
    color: #ffd700;
    font-weight: bold;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/* アクションボタン */
.action-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.share-direct-button, .next-button {
    padding: 12px 24px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    touch-action: manipulation;
}

.share-direct-button {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.share-direct-button:hover, .share-direct-button:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.share-direct-button {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.share-direct-button:hover, .share-direct-button:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(231, 76, 60, 0.4);
}

.next-button {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
}

.next-button:hover, .next-button:active {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.4);
}

/* 祝福エフェクト */
.celebration-effect {
    position: absolute;
    top: 30%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    visibility: hidden;
    z-index: 15;
    pointer-events: none;
}

.celebration-effect.show {
    opacity: 1;
    visibility: visible;
    animation: celebrationPulse 2s ease-out;
}

.celebration-text {
    font-size: 28px;
    font-weight: bold;
    color: #ffd700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    background: linear-gradient(45deg, #ffd700, #ffed4e);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

@keyframes celebrationPulse {
    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: 0;
    }
}

/* スコアアニメーション強化 */
.score-feedback.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1.05);
    animation: scorePopIn 0.3s ease-out;
}

@keyframes scorePopIn {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    100% {
        transform: translate(-50%, -50%) scale(1.05);
        opacity: 1;
    }
}

/* 数値変更アニメーション */
.score-animate {
    animation: numberPulse 0.4s ease-out;
}

@keyframes numberPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: #00ff88;
        text-shadow: 0 0 15px rgba(0, 255, 136, 0.8);
    }
    100% {
        transform: scale(1);
    }
}

/* 高品質円の特別エフェクト */
.celebration-effect.excellent {
    animation: excellentCelebration 3s ease-out;
}

@keyframes excellentCelebration {
    0% {
        transform: translate(-50%, -50%) scale(0.3);
        opacity: 0;
    }
    20% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 1;
    }
    40% {
        transform: translate(-50%, -50%) scale(1.1);
    }
    60% {
        transform: translate(-50%, -50%) scale(1.2);
    }
    80% {
        transform: translate(-50%, -50%) scale(1.0);
    }
    100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
}

/* パーティクルエフェクト（CSS疑似要素使用） */
.celebration-effect.show::before,
.celebration-effect.show::after {
    content: '✨';
    position: absolute;
    font-size: 20px;
    animation: sparkle 2s ease-out infinite;
}

.celebration-effect.show::before {
    top: -20px;
    left: -30px;
    animation-delay: 0.2s;
}

.celebration-effect.show::after {
    top: -15px;
    right: -30px;
    animation-delay: 0.6s;
}

@keyframes sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0.5) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) rotate(180deg);
    }
}

/* ボタンのフィードバック強化 */
.game-button:active {
    transform: translateY(0) scale(0.95);
    box-shadow: 0 2px 10px rgba(0, 212, 255, 0.6);
}

/* スコア表示のパルスエフェクト */
.score-pulse {
    animation: scorePulse 0.6s ease-out;
}

@keyframes scorePulse {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.15);
        filter: brightness(1.3);
    }
    100% {
        transform: scale(1);
        filter: brightness(1);
    }
}



/* レスポンシブデザイン */
@media screen and (max-width: 480px) {
    .game-title h1 {
        font-size: 36px;
    }
    
    .game-subtitle {
        font-size: 14px;
    }
    
    .result-title {
        margin-bottom: 12px;
    }
    
    .result-title h2 {
        font-size: 22px;
        margin-bottom: 0;
    }
    
    .result-title p {
        font-size: 12px;
    }
    
    .result-content {
        padding: 15px;
        margin: 5px;
        max-height: 95vh;
        overflow-y: auto;
    }
    
    .circle-preview {
        margin-bottom: 12px;
    }
    
    .preview-canvas {
        width: 120px;
        height: 120px;
    }
    
    .score-section {
        margin-bottom: 12px;
    }
    
    .main-score {
        margin-bottom: 12px;
    }
    
    .score-value {
        font-size: 56px;
    }
    
    .score-label {
        font-size: 20px;
    }
    
    .score-details {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 15px;
        padding: 10px;
    }
    
    .detail-item {
        gap: 2px;
    }
    
    .detail-label {
        font-size: 10px;
    }
    
    .detail-value {
        font-size: 14px;
    }
    
    .detail-sub {
        font-size: 9px;
    }
    
    /* スコア内訳のモバイル最適化 */
    .score-breakdown-compact {
        max-width: 100%;
        padding: 8px 12px;
        margin-bottom: 12px;
        gap: 10px;
    }
    
    .score-item-label {
        font-size: 10px;
    }
    
    .score-item-value {
        font-size: 20px;
    }
    

    
    .evaluation-message {
        font-size: 14px;
        margin-bottom: 0;
    }
    
    .action-buttons {
        flex-direction: row;
        gap: 8px;
        justify-content: center;
    }
    
    .share-direct-button, .next-button {
        padding: 8px 16px;
        font-size: 13px;
        flex: 1;
        max-width: 140px;
    }
}

/* 横向き対応 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .game-title {
        margin-bottom: 10px;
    }
    
    .game-title h1 {
        font-size: 32px;
    }
    
    .game-subtitle {
        font-size: 12px;
    }
    
    .result-title {
        margin-bottom: 10px;
    }
    
    .result-title h2 {
        font-size: 20px;
    }
    
    .result-content {
        padding: 12px;
        max-height: 85vh;
        overflow-y: auto;
    }
    
    .circle-preview {
        margin-bottom: 10px;
    }
    
    .preview-canvas {
        width: 100px;
        height: 100px;
    }
    
    .score-value {
        font-size: 48px;
    }
    
    /* スコア内訳の横向き最適化 */
    .score-breakdown-compact {
        padding: 6px 10px;
        margin-bottom: 10px;
        gap: 8px;
    }
    
    .score-item-label {
        font-size: 9px;
    }
    
    .score-item-value {
        font-size: 18px;
    }
    

    
    .action-buttons {
        flex-direction: row;
        gap: 8px;
    }
    
    .share-button, .share-direct-button, .next-button {
        padding: 8px 16px;
        font-size: 12px;
    }
}

@media screen and (min-width: 1024px) and (min-aspect-ratio: 4/3) {
    .game-area {
        padding: 24px 32px;
    }

    .game-title {
        margin-bottom: 16px;
    }

    .game-title h1 {
        font-size: clamp(40px, 3vw, 56px);
    }

    .drawing-canvas {
        max-height: calc(100vh - 180px);
    }

    .result-content {
        width: min(720px, 90vw);
    }
}

/* 高解像度ディスプレイ対応 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .drawing-canvas {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* iOS Safari 特有の調整 */
@supports (-webkit-touch-callout: none) {
    body {
        -webkit-overflow-scrolling: touch;
    }
    
    .game-container {
        height: 100vh;
        height: -webkit-fill-available;
    }
}

/* Android Chrome 特有の調整 */
@media screen and (-webkit-min-device-pixel-ratio: 0) {
    .drawing-canvas {
        will-change: transform;
    }
}
