:root {
    --bg-color: #ffffff;
    --glass-bg: rgba(255, 255, 255, 0.6);
    --glass-border: rgba(0, 0, 0, 0.1);
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --accent-color: #3b82f6;
    --accent-hover: #2563eb;
    --danger-color: #ef4444;
    --danger-hover: #dc2626;
    --danger-alert: rgb(255, 0, 0);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: background-color 0.3s ease;
    position: relative;
}

/* Background animated blobs for modern look */
.background-blobs {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    filter: blur(80px);
}

.blob {
    position: absolute;
    border-radius: 50%;
    opacity: 0.6;
    animation: float 20s infinite alternate;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #e0f2fe;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: #fce7f3;
    bottom: -150px;
    right: -100px;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 50px) scale(1.2); }
}

.container {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 2rem;
    width: 95vw;
    max-width: 1200px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.5rem;
    border-radius: 16px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
}

.tab-btn.active {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.content {
    display: grid;
}

.panel {
    grid-area: 1 / 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 250px;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
}

.panel.active {
    opacity: 1;
    visibility: visible;
    animation: fadeIn 0.4s ease forwards;
    z-index: 1;
}

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

/* Time Display */
.time-display {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(4rem, 12vw, 12rem);
    font-weight: 700;
    letter-spacing: -2px;
    background: linear-gradient(135deg, #0f172a, #475569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 4px 20px rgba(0,0,0,0.05);
    margin-bottom: 0.5rem;
    line-height: 1;
    text-align: center;
}

.date-display {
    color: var(--text-secondary);
    font-size: clamp(1rem, 3vw, 2rem);
    font-weight: 400;
    letter-spacing: 2px;
}

.ms {
    font-size: clamp(2rem, 5vw, 5rem);
    color: var(--text-secondary);
    -webkit-text-fill-color: var(--text-secondary);
}

.timer-content-wrapper {
    display: grid;
    place-items: center;
    width: 100%;
    margin-bottom: 2rem;
}

.timer-content-wrapper > * {
    grid-area: 1 / 1;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.timer-layout {
    display: flex;
    align-items: center;
    gap: 4rem;
}

.timer-setup {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.timer-presets {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.preset-btn {
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.preset-btn:hover {
    background: var(--accent-color);
    color: white;
}

.input-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.input-group input {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(4rem, 10vw, 10rem);
    width: clamp(120px, 15vw, 200px);
    text-align: center;
    border-radius: 12px;
    padding: 0.5rem;
    outline: none;
    transition: border-color 0.3s ease;
    cursor: ns-resize;
    touch-action: none; /* スワイプ時のブラウザネイティブのスクロールを無効化 */
}

/* スピンボタン（上下の矢印）を非表示にする */
.input-group input::-webkit-inner-spin-button,
.input-group input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.input-group input[type="number"] {
    -moz-appearance: textfield;
}

.input-group input:focus {
    border-color: var(--accent-color);
}

.input-group label {
    color: var(--text-secondary);
    font-size: clamp(1rem, 2vw, 1.5rem);
}

.colon {
    font-size: clamp(4rem, 10vw, 10rem);
    font-weight: bold;
    padding-bottom: 1.5rem;
    color: var(--text-primary);
}

/* Buttons */
.controls {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.btn {
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 9999px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.btn:active {
    transform: scale(0.95);
}

.btn-primary {
    background-color: var(--accent-color);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    background-color: var(--accent-hover);
}

.btn-secondary {
    background-color: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}

.btn-secondary:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background-color: transparent;
    color: var(--danger-color);
    border: 1px solid var(--danger-color);
}

.btn-danger:hover {
    background-color: var(--danger-color);
    color: white;
}

.btn-light {
    background-color: white;
    color: var(--danger-alert);
    font-size: 1.2rem;
    padding: 1rem 3rem;
}

.btn-light:hover {
    background-color: #f1f5f9;
}

.hidden {
    display: none !important;
}

.hidden-keep-size {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Alert State */
body.alert-active {
    animation: flashRed 0.5s infinite alternate !important;
}

@keyframes flashRed {
    0% { background-color: rgb(255, 0, 0); }
    100% { background-color: #ffffff; }
}

@media (max-width: 768px) {
    .timer-layout {
        flex-direction: column;
        gap: 2rem;
    }
    .timer-presets {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 480px) {
    .btn { min-width: 90px; padding: 0.6rem 1.2rem; }
    .timer-presets {
        grid-template-columns: repeat(3, 1fr);
    }
}
