/* レスポンシブデザイン強化 - FocusBuddy */

/* ベースフォントサイズを画面サイズに応じて動的調整 */
:root {
    --base-font-size: 16px;
    --base-padding: 16px;
    --base-margin: 16px;
    --base-border-radius: 20px;
    --content-max-width: 100%;
}

/* 超小型デバイス (iPhone SE等) - 320px-374px */
@media screen and (max-width: 374px) {
    :root {
        --base-font-size: 14px;
        --base-padding: 12px;
        --base-margin: 12px;
        --base-border-radius: 16px;
    }
    
    body {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .app-container {
        min-height: 100vh;
        min-height: -webkit-fill-available;
    }
    
    .header {
        padding: 16px 12px;
        border-radius: 0;
    }
    
    .app-title {
        font-size: 1.2rem !important;
    }
    
    .app-title i {
        font-size: 1.4rem !important;
        padding: 8px !important;
    }
    
    .header-info {
        gap: 6px !important;
    }
    
    .points, .character {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }
    
    .progress-dashboard {
        padding: 16px 12px !important;
        margin-bottom: 12px !important;
    }
    
    .dashboard-header h2 {
        font-size: 1rem !important;
    }
    
    .streak-counter {
        padding: 6px 10px !important;
        font-size: 0.8rem !important;
    }
    
    .progress-cards {
        gap: 6px !important;
    }
    
    .progress-card {
        padding: 10px 6px !important;
        border-radius: 16px !important;
    }
    
    .progress-circle {
        width: 70px !important;
        height: 70px !important;
    }
    
    .progress-number {
        font-size: 1.4rem !important;
    }
    
    .progress-label {
        font-size: 0.7rem !important;
    }
}

/* 小型デバイス (iPhone等) - 375px-479px */
@media screen and (min-width: 375px) and (max-width: 479px) {
    :root {
        --base-font-size: 15px;
        --base-padding: 14px;
        --base-margin: 14px;
        --base-border-radius: 18px;
    }
    
    body {
        font-size: 15px;
        line-height: 1.55;
    }
    
    .header {
        padding: 18px 14px;
    }
    
    .app-title {
        font-size: 1.3rem;
    }
    
    .app-title i {
        font-size: 1.6rem;
        padding: 9px;
    }
    
    .progress-dashboard {
        padding: 18px 14px;
        margin-bottom: 14px;
    }
    
    .dashboard-header h2 {
        font-size: 1.1rem;
    }
    
    .progress-cards {
        gap: 7px;
    }
    
    .progress-circle {
        width: 75px;
        height: 75px;
    }
    
    .progress-number {
        font-size: 1.5rem;
    }
}

/* 中型デバイス (大型スマートフォン) - 480px-767px */
@media screen and (min-width: 480px) and (max-width: 767px) {
    :root {
        --base-font-size: 16px;
        --base-padding: 16px;
        --base-margin: 16px;
        --base-border-radius: 20px;
    }
    
    body {
        font-size: 16px;
        line-height: 1.6;
    }
    
    .app-container {
        max-width: 100%;
    }
    
    .header {
        padding: 20px 16px;
    }
    
    .app-title {
        font-size: 1.4rem;
    }
    
    .progress-dashboard {
        padding: 20px 16px;
        margin-bottom: 16px;
    }
    
    .dashboard-header {
        flex-wrap: nowrap;
    }
    
    .progress-cards {
        gap: 10px;
        flex-wrap: nowrap;
    }
    
    .progress-circle {
        width: 85px;
        height: 85px;
    }
    
    .progress-number {
        font-size: 1.7rem;
    }
    
    .buddy-avatar.interactive .buddy-image {
        width: 95px;
        height: 95px;
    }
    
    .speech-bubble.enhanced {
        padding: 14px 18px;
        max-width: calc(100% - 105px);
    }
    
    .speech-bubble.enhanced p {
        font-size: 1.05rem;
    }
}

/* タブレット (iPad等) - 768px-1023px */
@media screen and (min-width: 768px) and (max-width: 1023px) {
    :root {
        --base-font-size: 17px;
        --base-padding: 20px;
        --base-margin: 20px;
        --base-border-radius: 24px;
        --content-max-width: 600px;
    }
    
    body {
        font-size: 17px;
        line-height: 1.65;
    }
    
    .app-container {
        max-width: 600px;
        margin: 0 auto;
        box-shadow: 0 0 50px rgba(252, 143, 175, 0.15);
        border-radius: 0 0 30px 30px;
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
    }
    
    .header {
        padding: 24px 20px;
        border-radius: 0;
    }
    
    .app-title {
        font-size: 1.6rem;
    }
    
    .app-title i {
        font-size: 1.9rem;
        padding: 12px;
        border-radius: 18px;
    }
    
    .header-info {
        gap: 12px;
    }
    
    .points, .character {
        padding: 10px 18px;
        font-size: 1rem;
    }
    
    .progress-dashboard {
        padding: 26px 20px;
        margin-bottom: 20px;
        border-radius: 0;
    }
    
    .dashboard-header h2 {
        font-size: 1.4rem;
    }
    
    .streak-counter {
        font-size: 1rem;
        padding: 10px 18px;
    }
    
    .progress-cards {
        gap: 14px;
        padding: 0 6px;
    }
    
    .progress-card {
        padding: 15px 11px;
        border-radius: 24px;
    }
    
    .progress-circle {
        width: 95px;
        height: 95px;
    }
    
    .progress-number {
        font-size: 1.9rem;
    }
    
    .progress-label {
        font-size: 0.9rem;
    }
    
    .character-greeting {
        padding: 20px;
        margin-bottom: 16px;
    }
    
    .buddy-avatar {
        flex-direction: row;
        align-items: flex-start;
        justify-content: center;
        gap: 20px;
    }
    
    .buddy-avatar.interactive .buddy-image {
        width: 115px;
        height: 115px;
        border-width: 6px;
    }
    
    .buddy-avatar.interactive::before {
        width: 135px;
        height: 135px;
        left: 57px;
    }
    
    .character-mood-indicator {
        right: 5px;
        bottom: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }
    
    .speech-bubble.enhanced {
        padding: 17px 22px;
        max-width: 280px;
        margin-left: 0;
        margin-top: 0;
        align-self: center;
        border-radius: 28px;
    }
    
    .speech-bubble.enhanced p {
        text-align: center;
        font-size: 1.15rem;
    }
    
    .speech-bubble.enhanced:after {
        top: 100%;
        left: 50%;
        margin-left: -12px;
        margin-top: 0;
        border-width: 0 12px 12px 12px;
        border-color: white transparent transparent transparent;
    }
    
    .speech-bubble.enhanced p::after {
        left: 50%;
        transform: translateX(-50%);
    }
}

/* 大型タブレット・小型デスクトップ - 1024px-1279px */
@media screen and (min-width: 1024px) and (max-width: 1279px) {
    :root {
        --base-font-size: 18px;
        --base-padding: 24px;
        --base-margin: 24px;
        --base-border-radius: 28px;
        --content-max-width: 700px;
    }
    
    body {
        font-size: 18px;
        line-height: 1.7;
    }
    
    .app-container {
        max-width: 700px;
    }
    
    .header {
        padding: 28px 24px;
    }
    
    .app-title {
        font-size: 1.8rem;
    }
    
    .app-title i {
        font-size: 2.1rem;
        padding: 14px;
        border-radius: 20px;
    }
    
    .progress-dashboard {
        padding: 30px 24px;
        margin-bottom: 24px;
    }
    
    .dashboard-header h2 {
        font-size: 1.6rem;
    }
    
    .progress-cards {
        gap: 18px;
        padding: 0 8px;
    }
    
    .progress-card {
        padding: 18px 14px;
        border-radius: 28px;
    }
    
    .progress-circle {
        width: 105px;
        height: 105px;
    }
    
    .progress-number {
        font-size: 2.1rem;
    }
    
    .buddy-avatar.interactive .buddy-image {
        width: 125px;
        height: 125px;
    }
    
    .speech-bubble.enhanced {
        padding: 20px 26px;
        max-width: 320px;
        border-radius: 32px;
    }
    
    .speech-bubble.enhanced p {
        font-size: 1.25rem;
    }
}

/* 大型デスクトップ - 1280px以上 */
@media screen and (min-width: 1280px) {
    :root {
        --base-font-size: 19px;
        --base-padding: 28px;
        --base-margin: 28px;
        --base-border-radius: 32px;
        --content-max-width: 800px;
    }
    
    body {
        font-size: 19px;
        line-height: 1.75;
    }
    
    .app-container {
        max-width: 800px;
        box-shadow: 0 0 60px rgba(252, 143, 175, 0.2);
    }
    
    .header {
        padding: 32px 28px;
    }
    
    .app-title {
        font-size: 2rem;
    }
    
    .app-title i {
        font-size: 2.3rem;
        padding: 16px;
        border-radius: 22px;
    }
    
    .header-info {
        gap: 16px;
    }
    
    .points, .character {
        padding: 12px 22px;
        font-size: 1.1rem;
    }
    
    .progress-dashboard {
        padding: 34px 28px;
        margin-bottom: 28px;
    }
    
    .dashboard-header h2 {
        font-size: 1.8rem;
    }
    
    .streak-counter {
        font-size: 1.1rem;
        padding: 12px 22px;
    }
    
    .progress-cards {
        gap: 22px;
        padding: 0 10px;
    }
    
    .progress-card {
        padding: 20px 16px;
        border-radius: 32px;
    }
    
    .progress-circle {
        width: 115px;
        height: 115px;
    }
    
    .progress-number {
        font-size: 2.3rem;
    }
    
    .progress-label {
        font-size: 1rem;
    }
    
    .character-greeting {
        padding: 28px;
        margin-bottom: 20px;
    }
    
    .buddy-avatar.interactive .buddy-image {
        width: 135px;
        height: 135px;
    }
    
    .character-mood-indicator {
        width: 45px;
        height: 45px;
        font-size: 1.4rem;
    }
    
    .speech-bubble.enhanced {
        padding: 22px 30px;
        max-width: 360px;
        border-radius: 36px;
    }
    
    .speech-bubble.enhanced p {
        font-size: 1.3rem;
    }
}

/* 横向き（ランドスケープ）対応 */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .progress-dashboard {
        padding: 12px 16px !important;
        margin-bottom: 8px !important;
    }
    
    .dashboard-header {
        margin-bottom: 8px !important;
    }
    
    .progress-cards {
        gap: 6px !important;
    }
    
    .progress-card {
        padding: 8px 6px !important;
    }
    
    .progress-circle {
        width: 60px !important;
        height: 60px !important;
    }
    
    .progress-number {
        font-size: 1.2rem !important;
    }
    
    .character-greeting {
        padding: 8px 16px !important;
        margin-bottom: 6px !important;
    }
    
    .buddy-avatar.interactive .buddy-image {
        width: 60px !important;
        height: 60px !important;
    }
    
    .speech-bubble.enhanced {
        padding: 8px 12px !important;
        max-width: 200px !important;
    }
    
    .speech-bubble.enhanced p {
        font-size: 0.85rem !important;
    }
    
    .current-task, .task-list {
        margin-bottom: 8px !important;
    }
    
    .screen-content {
        padding: 12px 16px !important;
    }
}

/* 印刷用（プリント）対応 */
@media print {
    * {
        color: black !important;
        background: white !important;
        box-shadow: none !important;
    }
    
    .header, .bottom-nav, .timer-section {
        display: none !important;
    }
    
    .app-container {
        box-shadow: none !important;
        background: white !important;
    }
    
    .task-card, .progress-card {
        border: 1px solid #ccc !important;
        page-break-inside: avoid;
    }
}

/* アクセシビリティ強化 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .attention-grabber {
        animation: none !important;
    }
    
    .progress-animate {
        animation: none !important;
    }
}

/* 高コントラストモード対応 */
@media (prefers-contrast: high) {
    :root {
        --text-color: #000000;
        --text-light: #333333;
        --primary-color: #0066cc;
        --success-color: #008800;
        --warning-color: #cc6600;
        --danger-color: #cc0000;
    }
    
    .task-card, .progress-card {
        border: 2px solid #000000 !important;
    }
    
    .btn, .task-button {
        border: 2px solid #000000 !important;
    }
}

/* フォーカス表示の強化 */
button:focus,
input:focus,
select:focus,
[tabindex]:focus {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

/* タッチデバイス用のタップターゲット最適化 */
@media (pointer: coarse) {
    .nav-btn,
    .task-button,
    .start-btn,
    .icon-btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .buddy-avatar.interactive {
        min-height: 44px;
        min-width: 44px;
    }
}