@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --secondary: #059669;
    --secondary-hover: #047857;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --warning: #d97706;

    --bg-primary: #f8fafc;
    --bg-secondary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-input: #f1f5f9;

    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --border: #cbd5e1;
    --border-focus: #4f46e5;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-primary);
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 0.5rem;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

.container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 1.5rem;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.header {
    text-align: center;
    margin-bottom: 1.5rem;
    flex-shrink: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.footer {
    margin-top: 1.5rem;
    text-align: center;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.btn-text {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.2s ease;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-text:hover {
    color: var(--primary);
    text-decoration: underline;
}



.title {
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.form-group {
    margin-bottom: 1.25rem;
    flex-shrink: 0;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.button-group {
    display: grid;
    gap: 0.5rem;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
}

.option-btn {
    padding: 0.75rem 0.5rem;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    white-space: nowrap;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.option-btn:hover {
    background: var(--bg-card);
    border-color: var(--border-focus);
    color: var(--text-primary);
}

.option-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 2px solid var(--border);
    transition: all 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.checkbox-group:hover {
    border-color: var(--border-focus);
    background: var(--bg-card);
}

.checkbox {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--primary);
}

.checkbox-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.password-section {
    margin: 1.5rem 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.password-container {
    position: relative;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all 0.2s ease;
    min-height: 65px;
    max-height: 65px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.password-container:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgb(79 70 229 / 0.1);
    background: var(--bg-card);
}

.password-field {
    width: 100%;
    height: 100%;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    font-family: 'Fira Code', 'Monaco', 'Consolas', monospace;
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
    letter-spacing: 0.05em;
    outline: none;
    resize: none;
    word-break: break-all;
    overflow: hidden;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    box-sizing: border-box;
}

.password-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.icon {
    width: 1.25em;
    height: 1.25em;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    flex-shrink: 0;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
    flex: 1;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
    flex: 1;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--secondary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: var(--bg-input);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    flex: 1;
}

.btn-outline:hover:not(:disabled) {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-focus);
}

.generate-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.generate-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.generate-btn:active {
    transform: translateY(0);
}

.strength-indicator {
    display: flex;
    gap: 0.25rem;
    margin-top: 0.75rem;
    align-items: center;
}

.strength-bar {
    height: 4px;
    flex: 1;
    background: var(--bg-input);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.strength-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 80px;
    text-align: right;
}

.toast {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--secondary);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    opacity: 0;
    transform: translateX(-50%) translateY(-100%);
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: calc(100vw - 2rem);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* 超小型デバイス対応 (320px以下) */
@media (max-width: 320px) {
    .container {
        padding: 1rem;
        border-radius: var(--radius-md);
    }

    .header {
        gap: 0.5rem;
        margin-bottom: 0.75rem;
    }



    .title {
        font-size: 1.25rem;
        margin-bottom: 0.25rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }



    .button-group {
        grid-template-columns: repeat(3, 1fr);
        gap: 0.375rem;
    }

    .option-btn {
        padding: 0.625rem 0.25rem;
        font-size: 0.75rem;
    }

    .password-container {
        min-height: 55px;
        max-height: 55px;
        padding: 0.375rem;
    }

    .password-field {
        font-size: 0.9rem;
    }

    .btn {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }

    .form-label {
        font-size: 0.8rem;
    }

    .checkbox-label {
        font-size: 0.8rem;
    }
}

/* 小型デバイス対応 (321px - 375px) */
@media (min-width: 321px) and (max-width: 375px) {
    .header {
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .title {
        margin-bottom: 0.25rem;
    }

    .button-group {
        grid-template-columns: repeat(5, 1fr);
    }

    .password-container {
        min-height: 60px;
        max-height: 60px;
    }

    .password-field {
        font-size: 1.1rem;
    }
}

/* 中型デバイス対応 (376px - 414px) */
@media (min-width: 376px) and (max-width: 414px) {
    .container {
        padding: 1.75rem;
    }

    .header {
        margin-bottom: 1rem;
    }

    .button-group {
        grid-template-columns: repeat(5, 1fr);
    }

    .password-container {
        min-height: 65px;
        max-height: 65px;
    }

    .password-field {
        font-size: 1.25rem;
    }

    .title {
        font-size: 1.625rem;
    }
}

/* 大型デバイス対応 (415px以上) */
@media (min-width: 415px) {
    .container {
        padding: 2rem;
        max-width: 480px;
    }

    .button-group {
        grid-template-columns: repeat(5, 1fr);
    }

    .password-container {
        min-height: 70px;
        max-height: 70px;
        padding: 0.75rem;
    }

    .password-field {
        font-size: 1.5rem;
    }

    .title {
        font-size: 1.875rem;
    }

    .subtitle {
        font-size: 0.875rem;
    }
}

/* 横向き対応 */
@media (orientation: landscape) and (max-height: 500px) {
    .container {
        padding: 1rem;
    }

    .header {
        margin-bottom: 1rem;
        gap: 0.5rem;
    }





    .form-group {
        margin-bottom: 1rem;
    }

    .password-section {
        margin: 1rem 0;
    }

    .password-container {
        min-height: 50px;
        max-height: 50px;
        padding: 0.375rem;
    }

    .password-field {
        font-size: 1rem;
    }

    .title {
        font-size: 1.25rem;
    }

    .generate-btn {
        padding: 0.875rem;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #0f172a;
        --bg-secondary: #1e293b;
        --bg-card: #1e293b;
        --bg-input: #334155;

        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;

        --border: #475569;
    }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* 高コントラスト対応 */
@media (prefers-contrast: high) {
    :root {
        --border: #000000;
        --text-primary: #000000;
        --bg-card: #ffffff;
    }
}

/* タッチ操作の改善 */
@media (hover: none) and (pointer: coarse) {

    .option-btn:hover,
    .btn:hover,
    .generate-btn:hover,
    .checkbox-group:hover {
        transform: none;
    }

    .option-btn:active,
    .btn:active,
    .generate-btn:active {
        transform: scale(0.98);
    }
}