body {
    font-family: 'Zen Maru Gothic', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    text-align: center;
    padding: 20px;
    background: #f0f2f5;
    color: #333;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    box-sizing: border-box;
}

header {
    margin-bottom: 30px;
    max-width: 900px;
    width: 100%;
}

h1 {
    font-family: 'Lobster', cursive;
    color: #1c1e21;
    margin-bottom: 10px;
    font-size: 2.5em;
    font-weight: 700;
}

header p {
    color: #606770;
    font-size: 1.1em;
    margin-top: 0;
}

h2 {
    color: #333;
    font-size: 1.5em;
    font-weight: 700;
    margin-top: 0;
    margin-bottom: 25px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 10px;
    text-align: left;
}

main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* 各セクションの共通ボックススタイル */
.section-box {
    background-color: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    padding: 30px;
    margin-bottom: 25px;
    width: 100%;
    max-width: 900px;
    box-sizing: border-box;
}

/* ファイル選択ボタンのスタイル */
#imageInput {
    width: 100%;
    padding: 12px;
    box-sizing: border-box;
    border-radius: 8px;
    border: 2px dashed #ccd0d5;
    font-size: 1em;
    background-color: #fff;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

/* ボタンの共通スタイル */
.section-box button {
    width: 100%;
    padding: 14px 28px;
    font-size: 1.2em;
    font-weight: 600;
    color: #fff;
    background-color: #007bff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.section-box button:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 7px rgba(0, 0, 0, 0.15);
}
.section-box button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* 画像表示とコントロールを横並びに配置するコンテナ */
#processingContent {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}
@media (min-width: 768px) {
    #processingContent {
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
    }
}

#canvas-wrapper {
    flex: 1; /* 利用可能なスペースを埋める */
    min-width: 0; /* flexアイテムがコンテンツサイズ以下に縮小できるようにする */
    display: flex;
    justify-content: center;
    align-items: center;
}

#canvas {
    border: 1px solid #ddd;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    cursor: crosshair;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    /* チェッカーボード背景 */
    background-image:
        linear-gradient(45deg, #ccc 25%, transparent 25%),
        linear-gradient(-45deg, #ccc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ccc 75%),
        linear-gradient(-45deg, transparent 75%, #ccc 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

/* コントロール（カラーピッカーとボタン）のコンテナ */
#controls {
    flex: none; /* コントロールの幅は固定 */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    width: 100%;
    max-width: 400px;
}

/* 複数カラーピッカーのラッパー */
#colorPickersWrapper {
    display: flex;
    justify-content: center;
    gap: 20px;
    width: 100%;
}

/* 個々のカラーピッカーボックス */
.color-picker-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease-in-out;
}

.color-picker-box.active-picker {
    border-color: #007bff;
}

.color-picker-box label {
    font-size: 1.1em;
    font-weight: 500;
    color: #333;
}

/* input[type=color] の共通スタイル */
.color-picker-box input[type="color"] {
    width: 70px;
    height: 70px;
    padding: 0;
    border-radius: 50%;
    cursor: pointer;
    border: 4px solid #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.color-picker-box input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 50%;
}

.color-picker-box input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

/* スポイト機能の説明文 */
.picker-instruction {
    font-size: 0.9em;
    color: #606770;
    margin-top: -15px;
    margin-bottom: 0;
}

/* 許容範囲スライダー */
#toleranceContainer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
}

#toleranceContainer label {
    font-size: 1.1em;
    font-weight: 500;
    color: #333;
}

#toleranceSlider {
    -webkit-appearance: none;
    appearance: none;
    width: 80%;
    height: 8px;
    background: #ddd;
    outline: none;
    border-radius: 5px;
    transition: opacity .2s;
}

#toleranceSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    background: #007bff;
    cursor: pointer;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

#toleranceSlider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: #007bff;
    cursor: pointer;
    border-radius: 50%;
}

/* 各セクションの初期表示設定 */
#processingSection, #downloadSection {
    display: none;
}

/* リサイズコントロール */
#resizeControls {
    margin-bottom: 30px;
    padding: 20px;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.resize-title {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.2em;
    text-align: center;
    color: #495057;
    font-weight: 600;
}

.resize-percentage-group {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.resize-percentage-group label {
    font-weight: 500;
    color: #495057;
}

.resize-percentage-group input[type="range"] {
    width: 150px;
}

.resize-percentage-group input[type="number"] {
    width: 80px;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 1em;
    text-align: center;
}

.download-btn {
    background-color: #28a745;
}
.download-btn:hover {
    background-color: #218838;
}

/* ローディングスピナー */
.loader {
    border: 5px solid #f3f3f3; /* Light grey */
    border-top: 5px solid #007bff; /* Blue */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
    display: none; /* 初期状態では非表示 */
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Hamburger Menu */
.hamburger-menu {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 50px;
    height: 50px;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    border: none;
    padding: 0; /* Reset padding */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.hamburger-menu:hover {
    /* 他のボタンスタイルからの影響を防ぎ、背景色を白に固定 */
    background-color: #fff;
}

.hamburger-menu span {
    display: block;
    width: 24px;
    height: 3px;
    background-color: #333;
    border-radius: 3px;
    transition: all 0.3s ease-in-out;
}

/* Hamburger animation to 'X' */
.hamburger-menu.is-active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}
.hamburger-menu.is-active span:nth-child(2) {
    opacity: 0;
}
.hamburger-menu.is-active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}
/* Navigation Menu (Sidebar) */
.global-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100%;
    background-color: #fff;
    z-index: 999;
    padding-top: 80px;
    box-shadow: -5px 0 15px rgba(0,0,0,0.1);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.4s ease-in-out, visibility 0.4s ease-in-out;
}

.global-nav.is-visible {
    transform: translateX(0);
    visibility: visible;
}

.global-nav ul { list-style: none; padding: 0; margin: 0; text-align: center; }
.global-nav li { margin-bottom: 30px; }
.global-nav a {
    color: #333;
    text-decoration: none;
    font-family: 'Raleway', sans-serif;
    font-size: 2em;
    font-weight: 700;
    transition: color 0.2s;
}
.global-nav a:hover { color: #007bff; }

/* Navigation Overlay */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
}
.nav-overlay.is-visible {
    opacity: 1;
    visibility: visible;
}

/* Prevent body scroll when menu is open */
body.menu-open { overflow: hidden; }

/* Styles for fast_resizer.html */
.resize-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

#download-actions {
    margin-top: 25px;
    display: flex;
    justify-content: center;
}

#output {
    margin-top: 20px;
    width: 100%;
}
#downloadLink {
    margin-top: 20px;
    padding: 14px 28px;
    font-size: 1.2em;
    font-weight: 600;
    color: #fff;
    background-color: #28a745;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s ease-in-out, transform 0.1s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    display: none; /* Initial state */
}
#downloadLink:hover {
    background-color: #218838;
    transform: translateY(-2px);
}

/* Styles for google_font_test.html */
#font-test-page {
    /* 共通のbodyスタイルを上書き */
    background-color: #f4f4f9;
    font-family: 'Zen Maru Gothic', sans-serif;
}

#font-test-page .container {
    max-width: 600px;
    width: 100%;
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}

#font-test-page h1 {
    /* 共通のh1スタイルを上書き */
    color: #5a5a5a;
    margin-bottom: 10px;
    font-weight: normal; /* 共通スタイルを上書き */
}

#font-test-page .controls {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

#font-test-page textarea {
    width: 100%;
    height: 80px; /* Adjust height for 100 characters */
    padding: 10px;
    font-size: 18px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-family: 'Zen Maru Gothic', sans-serif;
    resize: none;
}

#font-test-page select {
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Zen Maru Gothic', sans-serif;
    width: 100%;
}

#font-test-page .action-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Override generic button styles for this page */
#font-test-page .container button {
    width: auto;
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    border: none;
    font-family: 'Zen Maru Gothic', sans-serif;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transform: translateY(0);
    border-radius: 8px;
    background-image: linear-gradient(to right, #a8e6cf 0%, #87d3b7 100%); /* Pastel green gradient */
}

#font-test-page .container button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    background-image: linear-gradient(to right, #b9f1de 0%, #98e0c8 100%);
}

#font-test-page #clearButton {
    background-image: linear-gradient(to right, #ffb3a7 0%, #ff8a7a 100%); /* Pastel coral gradient */
}

#font-test-page #clearButton:hover {
    background-image: linear-gradient(to right, #ffc4bb 0%, #ff9b8d 100%);
}

#font-test-page .delete-button {
    background-image: linear-gradient(to right, #a7d7c5 0%, #74b49b 100%); /* Pastel mint gradient */
    padding: 5px 10px;
    font-size: 14px;
    border-radius: 6px;
}

#font-test-page .delete-button:hover {
    background-image: linear-gradient(to right, #b8e2d4 0%, #85c2ab 100%);
}

#font-test-page .preview {
    border-top: 1px solid #eee;
    padding-top: 20px;
    margin-top: 20px;
}

#font-test-page .preview-text {
    font-size: 32px;
    font-weight: bold;
    line-height: 1.5;
    min-height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    word-wrap: break-word;
}

#font-test-page #history {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
    text-align: left;
}

#font-test-page .history-item {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fafafa;
}

#font-test-page .history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

#font-test-page .history-font-name {
    font-weight: bold;
}

#font-test-page .history-text {
    font-size: 24px;
    word-wrap: break-word;
}

/* Override generic h2 for this page */
#font-test-page h2 {
    font-size: 1.2em;
    font-weight: bold;
    margin-bottom: 10px;
    border-bottom: none;
    padding-bottom: 0;
    text-align: center;
}

/* Styles for Fast Resizer Previews */
.preview-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.preview-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #fdfdfd;
    border-bottom: 1px solid #e0e0e0;
}

.preview-list-item:last-child {
    border-bottom: none;
}

.preview-list-item .file-info-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.preview-list-item .file-name {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-right: 15px;
    margin-bottom: 4px;
}

.preview-list-item .size-info {
    font-size: 0.9em;
    color: #666;
    white-space: nowrap;
    background-color: #f0f2f5;
    padding: 4px 8px;
    border-radius: 4px;
}

.download-individual-link {
    padding: 6px 12px;
    font-size: 0.9em;
    font-weight: 600;
    color: #007bff;
    background-color: transparent;
    border: 1px solid #007bff;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.2s, color 0.2s;
}
.download-individual-link:hover {
    background-color: #007bff;
    color: #fff;
}

/* --- Media Queries for Responsive Design --- */

@media (max-width: 767px) {
    body {
        padding: 15px;
    }

    header {
        margin-bottom: 20px;
    }

    h1 {
        font-size: 2em;
    }

    header p {
        font-size: 1em;
    }

    .section-box {
        padding: 20px;
    }

    h2 {
        font-size: 1.3em;
        margin-bottom: 20px;
    }

    /* Transparency Tool Specifics */
    #controls {
        gap: 20px;
    }

    .color-picker-box input[type="color"] {
        width: 60px;
        height: 60px;
    }

    /* Common resize controls for both tools */
    .resize-percentage-group {
        flex-direction: column;
        gap: 15px;
    }

    .resize-percentage-group input[type="range"] {
        width: 100%;
    }

    /* Fast Resizer Specifics */
    .preview-list-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .preview-list-item .file-name {
        white-space: normal; /* Allow file names to wrap */
    }

    .download-individual-link {
        align-self: flex-end; /* Move button to the right */
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }

    .section-box button {
        padding: 12px 20px;
        font-size: 1.1em;
    }
}
