:root {
    --primary-color: #e74c3c;
    --secondary-color: #c0392b;
    --accent-color: #f39c12;
    --bg-start: #ff6b6b;
    --bg-end: #ee5a52;
}

[data-theme="red"] {
    --primary-color: #e74c3c;
    --secondary-color: #c0392b;
    --accent-color: #f39c12;
    --bg-start: #ff6b6b;
    --bg-end: #ee5a52;
}

[data-theme="blue"] {
    --primary-color: #3498db;
    --secondary-color: #2980b9;
    --accent-color: #9b59b6;
    --bg-start: #5a9fd4;
    --bg-end: #3498db;
}

[data-theme="green"] {
    --primary-color: #27ae60;
    --secondary-color: #229954;
    --accent-color: #f39c12;
    --bg-start: #3fc876;
    --bg-end: #27ae60;
}

[data-theme="purple"] {
    --primary-color: #9b59b6;
    --secondary-color: #8e44ad;
    --accent-color: #e74c3c;
    --bg-start: #bb73e0;
    --bg-end: #9b59b6;
}

[data-theme="orange"] {
    --primary-color: #e67e22;
    --secondary-color: #d35400;
    --accent-color: #3498db;
    --bg-start: #fd7f28;
    --bg-end: #e67e22;
}

[data-theme="gray"] {
    --primary-color: #34495e;
    --secondary-color: #2c3e50;
    --accent-color: #95a5a6;
    --bg-start: #5d6d7e;
    --bg-end: #34495e;
}

html, body {
    height: 100%;
    margin: 0;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

body {
    font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-start, #ff6b6b) 0%, var(--bg-end, #ee5a52) 100%);
    color: #333;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    transition: background 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.timer-app-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 20px;
    border-radius: 24px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.1);
    text-align: center;
    width: 95%;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    min-height: 900px;
    height: 95vh;
    overflow: hidden;
    box-sizing: border-box;
    margin: 2.5vh auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.2);
}


/* Branding Footer */
.branding-footer {
    margin-top: 5px;
    padding: 4px 0;
    width: 100%;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.footer-text {
    font-size: 0.8em;
    color: #95a5a6;
    font-weight: 500;
    letter-spacing: 0.5px;
    opacity: 0.8;
}

h1 {
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 8px 0;
    font-size: 2.4em;
    font-weight: 700;
    letter-spacing: -0.5px;
    text-shadow: none;
}

/* Settings Panel */
.settings-panel {
    margin-bottom: 10px;
    width: 100%;
}

/* Theme Selector Section */
.theme-selector-section {
    margin-bottom: 15px;
    width: 100%;
    display: flex;
    justify-content: center;
}

.theme-buttons-container {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 25px;
    padding: 12px 25px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    justify-content: center;
    max-width: 100%;
}

.settings-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: nowrap; /* 改行を防ぐ */
    align-items: flex-end;
    width: 100%;
    box-sizing: border-box;
}

.setting-card {
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    padding: 12px 16px;
    min-width: 140px;
    flex: 1;
    max-width: 200px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    position: relative;
}

.sound-card {
    flex: 0.8;
    min-width: 120px;
}

.setting-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.setting-label {
    font-size: 0.8em;
    font-weight: 600;
    color: #4a5568;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.custom-select {
    position: relative;
}

.custom-select select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
    color: white;
    appearance: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.custom-select select:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.custom-select select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

.custom-select::after {
    content: '▼';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.8);
    pointer-events: none;
    font-size: 0.7em;
}

.custom-time-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 8px;
}

.custom-time-input input[type="number"] {
    width: 45px;
    padding: 8px 6px;
    border: 2px solid transparent;
    border-radius: 8px;
    font-size: 0.85em;
    font-weight: 600;
    text-align: center;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
    color: #333;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.custom-time-input input[type="number"]:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.8) 100%);
    transform: scale(1.05);
}

.custom-time-input input[type="number"]:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.custom-time-input input[type="number"]::-webkit-inner-spin-button,
.custom-time-input input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.custom-time-input input[type="number"] {
    -moz-appearance: textfield;
}

.time-separator {
    font-size: 1.1em;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    margin: 0 2px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.theme-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

/* Update theme button container styles */
.theme-buttons-container .theme-btn {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    font-size: 1.4em;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.theme-buttons-container .theme-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.theme-buttons-container .theme-btn.active {
    transform: scale(1.2);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.8);
}

.theme-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    font-size: 1.2em;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.theme-btn.active {
    transform: scale(1.15);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.6);
}

/* Sound toggle button */
.sound-toggle-btn {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 0.9em;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.sound-toggle-btn:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.sound-toggle-btn.active {
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
}

.sound-toggle-btn:not(.active) {
    background: linear-gradient(135deg, #95a5a6 0%, #7f8c8d 100%);
}

/* Audio permission modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 400px;
    width: 90%;
    animation: slideUp 0.3s ease;
}

.modal-content h2 {
    color: #333;
    font-size: 1.8em;
    margin-bottom: 20px;
}

.modal-content p {
    color: #666;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 30px;
}

.modal-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

.modal-btn {
    padding: 15px 30px;
    border-radius: 16px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    min-width: 140px;
}

.modal-btn.primary {
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
    color: white;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.modal-btn.primary:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

.modal-btn.secondary {
    background: #f0f0f0;
    color: #666;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.modal-btn.secondary:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

.timer-display-area {
    flex-grow: 1; /* Allow it to take available space */
    display: flex;
    flex-direction: column; /* Stack elements vertically */
    justify-content: center;
    align-items: center;
    margin-bottom: 5px; /* Further reduced margin */
    width: 100%;
}

.timer-display-area h2 {
    color: #666;
    font-size: 1.3em; /* Reduced font size */
    margin-bottom: 8px; /* Reduced margin */
}

.current-pitch-timer {
    position: relative;
    /* Dynamically size based on available space, maintaining aspect ratio */
    width: min(60vw, 45vh, 400px); /* Added max width to prevent too large */
    height: min(60vw, 45vh, 400px); /* Make it square based on the calculated width */
    min-width: 300px; /* Minimum size to ensure visibility */
    min-height: 300px; /* Minimum size to ensure visibility */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto; /* Center horizontally */
}

#timer-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

#interval-display {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    display: none; /* Hidden by default */
    text-align: center;
    /* Modern card-style design */
    background: linear-gradient(135deg, var(--bg-start) 0%, var(--bg-end) 100%);
    border-radius: 30px;
    padding: 40px 60px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 0 10px 20px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    animation: intervalPulse 2s ease-in-out infinite;
    min-width: 350px;
    white-space: nowrap;
}

#interval-display .interval-label {
    font-size: 1.4em;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

#interval-display .interval-content {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 5px;
}

#interval-display .interval-time {
    font-size: 4.5em;
    font-weight: 700;
    color: #ffffff;
    text-shadow: 0 3px 6px rgba(0, 0, 0, 0.3);
    line-height: 1;
}

#interval-display .interval-subtitle {
    font-size: 1.8em;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 600;
}

@keyframes intervalPulse {
    0%, 100% { 
        transform: translate(-50%, -50%) scale(1);
        box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.07);
    }
    50% { 
        transform: translate(-50%, -50%) scale(1.05);
        box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.1);
    }
}

.controls {
    margin-top: 8px; /* Further reduced margin */
    margin-bottom: 5px; /* Further reduced margin */
}

.controls button {
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
    color: #fff;
    border: none;
    padding: 14px 28px;
    margin: 0 6px;
    border-radius: 16px;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 110px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.controls button:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.2);
}

.controls button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.controls button:disabled {
    background: linear-gradient(135deg, #bdc3c7 0%, #95a5a6 100%);
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    opacity: 0.6;
}


/* Time up animation */
.time-up-animation {
    animation: blink 1s infinite;
}

@keyframes blink {
    0% { opacity: 1; }
    50% { opacity: 0.3; }
    100% { opacity: 1; }
}

/* Completion Message Overlay */
.completion-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.5s ease;
}

.completion-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    max-width: 400px;
    width: 90%;
    animation: slideUp 0.5s ease;
}

.completion-icon {
    font-size: 4em;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.completion-title {
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 2.2em;
    font-weight: 700;
    margin-bottom: 15px;
    letter-spacing: -0.5px;
}

.completion-text {
    color: #4a5568;
    font-size: 1.1em;
    line-height: 1.6;
    margin-bottom: 30px;
    font-weight: 500;
}

.completion-btn {
    background: linear-gradient(135deg, var(--primary-color, #e74c3c) 0%, var(--secondary-color, #c0392b) 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 16px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

.completion-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Responsive adjustments */
@media (max-width: 1024px) and (min-height: 900px) {
    .timer-app-container {
        min-height: 850px;
    }
    
    h1 {
        font-size: 2.2em;
    }
    .settings {
        gap: 25px;
    }
    .setting-group label {
        font-size: 1.1em;
    }
    .setting-group select {
        padding: 10px 18px;
        font-size: 1em;
    }
    .controls button {
        padding: 10px 20px;
        font-size: 0.95em;
        min-width: 110px;
    }
    .current-pitch-timer {
        width: min(70vw, 50vh, 380px);
        height: min(70vw, 50vh, 380px);
        min-width: 280px;
        min-height: 280px;
    }
    .timer-display-area h2 {
        font-size: 1.2em;
    }
    #interval-display {
        padding: 30px 50px;
        min-width: 300px;
    }
    
    #interval-display .interval-label {
        font-size: 1.2em;
    }
    
    #interval-display .interval-time {
        font-size: 3.5em;
    }
    
    #interval-display .interval-subtitle {
        font-size: 1.5em;
    }
}

/* Special handling for height less than 900px */
@media (max-height: 900px) {
    .timer-app-container {
        min-height: auto;
        height: 95vh;
        padding: 15px;
    }
    
    .current-pitch-timer {
        width: min(50vw, 35vh, 350px);
        height: min(50vw, 35vh, 350px);
        min-width: 250px;
        min-height: 250px;
    }
    
    h1 {
        font-size: 2em;
        margin: 5px 0;
    }
    
    .settings-panel {
        margin-bottom: 8px;
    }
    
    .setting-card {
        padding: 8px 12px;
        min-width: 120px;
    }
    
    .theme-card {
        min-width: 100px;
    }
    
    .setting-label {
        font-size: 0.75em;
        margin-bottom: 4px;
    }
    
    .custom-select select {
        padding: 8px 10px;
        font-size: 0.85em;
    }
    
    .theme-btn {
        width: 28px;
        height: 28px;
        font-size: 1em;
    }
    
    .controls {
        margin-top: 5px;
        margin-bottom: 3px;
    }
    
    .branding-footer {
        margin-top: 3px;
        padding: 3px 0;
    }
}

@media (max-width: 768px) {
    .timer-app-container {
        padding: 10px;
        margin: 0.5vh auto;
    }
    
    .settings-row {
        gap: 6px;
        justify-content: space-between;
    }
    
    .setting-card {
        min-width: 105px;
        max-width: 120px;
        padding: 8px 6px;
        flex: 1;
    }
    
    .sound-card {
        min-width: 90px;
        max-width: 105px;
        flex: 0.85;
    }
    
    .theme-buttons-container {
        padding: 10px 18px;
        gap: 10px;
        max-width: 90%;
    }
    
    .theme-buttons-container .theme-btn {
        width: 36px;
        height: 36px;
        font-size: 1.2em;
    }
    
    .sound-toggle-btn {
        padding: 6px 8px;
        font-size: 0.8em;
    }
    
    .setting-label {
        font-size: 0.7em;
        margin-bottom: 4px;
    }
    
    .custom-select select {
        padding: 6px 8px;
        font-size: 0.8em;
    }
    
    .theme-btn {
        width: 24px;
        height: 24px;
        font-size: 0.9em;
    }
    
    .theme-buttons {
        gap: 4px;
    }
    
    .footer-text {
        font-size: 0.7em;
    }
    h1 {
        font-size: 1.8em;
    }
    .setting-group label {
        font-size: 0.9em;
    }
    .setting-group select {
        padding: 8px 15px;
        font-size: 0.9em;
    }
    .controls {
        display: flex;
        justify-content: center;
        gap: 4px;
        flex-wrap: nowrap;
    }
    
    .controls button {
        padding: 8px 12px;
        font-size: 0.75em;
        margin: 0;
        min-width: 70px;
        flex: 1;
        max-width: 90px;
    }
    .current-pitch-timer {
        width: min(80vw, 40vh); /* Further adjusted for smaller screens */
        height: min(80vw, 40vh);
    }
    .timer-display-area h2 {
        font-size: 1em;
    }
    #interval-display {
        padding: 20px 40px;
        min-width: 250px;
    }
    
    #interval-display .interval-label {
        font-size: 1em;
    }
    
    #interval-display .interval-time {
        font-size: 3em;
    }
    
    #interval-display .interval-subtitle {
        font-size: 1.3em;
    }
}

/* iPhone15 Pro Max向け (430px) */
@media (max-width: 430px) and (min-width: 394px) {
    .timer-app-container {
        padding: 8px;
        margin: 0.5vh auto;
    }
    
    .settings-row {
        gap: 5px;
        justify-content: space-between;
    }
    
    .setting-card {
        min-width: 110px;
        max-width: 125px;
        padding: 7px 5px;
        flex: 1;
    }
    
    .sound-card {
        min-width: 100px;
        max-width: 115px;
        flex: 0.85;
    }
    
    .setting-label {
        font-size: 0.65em;
        margin-bottom: 3px;
    }
    
    .custom-select select {
        padding: 7px 5px;
        font-size: 0.8em;
    }
    
    .sound-toggle-btn {
        padding: 7px 5px;
        font-size: 0.8em;
    }
}

/* iPhone15 Standard向け (393px) */
@media (max-width: 393px) {
    .timer-app-container {
        padding: 8px;
        margin: 0.5vh auto;
    }
    
    .settings-row {
        gap: 3px;
        justify-content: space-between;
        flex-wrap: nowrap; /* 強制的に1行 */
    }
    
    .setting-card {
        min-width: 90px;
        max-width: 105px;
        padding: 6px 3px;
        flex: 1 1 auto;
        overflow: hidden;
    }
    
    .sound-card {
        min-width: 80px;
        max-width: 95px;
        flex: 0.9 1 auto;
    }
    
    .setting-label {
        font-size: 0.6em;
        margin-bottom: 3px;
    }
    
    .custom-select select {
        padding: 6px 4px;
        font-size: 0.75em;
    }
    
    .sound-toggle-btn {
        padding: 6px 4px;
        font-size: 0.75em;
    }
}

@media (max-width: 480px) {
    .timer-app-container {
        padding: 8px;
        margin: 0.5vh auto;
    }
    
    .settings-row {
        gap: 5px;
    }
    
    .setting-card {
        min-width: 100px;
        max-width: 125px;
        padding: 6px 6px;
    }
    
    .sound-card {
        min-width: 90px;
        max-width: 110px;
    }
    
    .theme-buttons-container {
        padding: 8px 15px;
        gap: 8px;
        max-width: 95%;
    }
    
    .theme-buttons-container .theme-btn {
        width: 32px;
        height: 32px;
        font-size: 1em;
    }
    
    .setting-label {
        font-size: 0.65em;
    }
    
    .custom-select select {
        padding: 4px 6px;
        font-size: 0.75em;
    }
    
    .theme-btn {
        width: 20px;
        height: 20px;
        font-size: 0.8em;
    }
    
    .controls {
        gap: 3px;
    }
    
    .controls button {
        padding: 6px 8px;
        font-size: 0.7em;
        min-width: 60px;
        max-width: 75px;
    }
    
    .footer-text {
        font-size: 0.65em;
    }
    h1 {
        font-size: 1.5em;
    }
    .current-pitch-timer {
        width: min(85vw, 35vh); /* Adjusted for very small screens */
        height: min(85vw, 35vh);
    }
    #interval-display {
        padding: 15px 30px;
        min-width: 200px;
    }
    
    #interval-display .interval-label {
        font-size: 0.9em;
    }
    
    #interval-display .interval-time {
        font-size: 2.5em;
    }
    
    #interval-display .interval-subtitle {
        font-size: 1.1em;
    }
}