:root {
    /* デフォルトテーマ（視認性重視） */
    --bg-color: #000000;
    --text-color: #ffffff;
    --accent-color: #ff3b30;
    --clock-bg: #111111;
    --clock-border: #333333;
    --mark-color: #555555;
    --mark-color-main: #dddddd;
    
    --hour-hand-w: 3%;
    --min-hand-w: 2%;
    --sec-hand-w: 1%;
    --clock-border-w: 4px;
    --shadow: 0 0 30px rgba(0, 0, 0, 0.8), inset 0 0 20px rgba(0,0,0,0.8);
    
    --mark-w: 1%;
    --mark-h: 3%;
    --mark-main-w: 2%;
    --mark-main-h: 8%;
    
    --digital-glow: 0 0 20px rgba(255, 255, 255, 0.15);
    
    /* ウィジェット関連 */
    --bbox-color: rgba(255, 255, 255, 0.3);
    --handle-color: #ffffff;
}

/* ミニマルテーマ（細線・スタイリッシュ） */
body.theme-minimal {
    --bg-color: #0a0a0a;
    --clock-bg: #0a0a0a;
    --clock-border: #222222;
    --mark-color: #333333;
    --mark-color-main: #777777;
    --accent-color: #ffffff;
    --text-color: #dddddd;
    
    --hour-hand-w: 1%;
    --min-hand-w: 0.5%;
    --sec-hand-w: 0.2%;
    --clock-border-w: 1px;
    --shadow: none;
    
    --mark-w: 0.2%;
    --mark-h: 2%;
    --mark-main-w: 0.5%;
    --mark-main-h: 5%;
    
    --digital-glow: none;
    --bbox-color: rgba(255, 255, 255, 0.2);
}

/* ネオンテーマ（サイバー調） */
body.theme-neon {
    --bg-color: #050510;
    --clock-bg: #050510;
    --clock-border: #00ffff;
    --mark-color: rgba(0, 255, 255, 0.3);
    --mark-color-main: #00ffff;
    --accent-color: #ff00ff;
    --text-color: #00ffff;
    
    --hour-hand-w: 2%;
    --min-hand-w: 1%;
    --sec-hand-w: 0.5%;
    --clock-border-w: 2px;
    --shadow: 0 0 20px rgba(0, 255, 255, 0.3), inset 0 0 20px rgba(0, 255, 255, 0.1);
    
    --mark-w: 0.5%;
    --mark-h: 3%;
    --mark-main-w: 1%;
    --mark-main-h: 8%;
    
    --digital-glow: 0 0 20px rgba(0, 255, 255, 0.5);
    --bbox-color: rgba(0, 255, 255, 0.4);
    --handle-color: #00ffff;
}

body {
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Helvetica Neue', Arial, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.controls {
    display: flex;
    gap: 20px;
    padding: 15px 30px;
    background: rgba(20, 20, 20, 0.9);
    align-items: center;
    justify-content: center; /* ユーザーの要望により中央揃え */
    border-bottom: 1px solid #333;
    z-index: 10;
    flex-wrap: wrap;
    transition: transform 0.3s ease, opacity 0.3s ease, margin-top 0.3s ease;
}

.controls.hidden {
    display: none !important;
}

/* トグルボタン（歯車アイコン） */
.toggle-controls-btn, .fullscreen-btn {
    position: fixed;
    background: rgba(30, 30, 30, 0.6);
    color: #fff;
    border: 1px solid #555;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100;
    transition: background 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
    opacity: 0.3;
}

.toggle-controls-btn {
    top: 15px;
    right: 15px;
}

.fullscreen-btn {
    top: 60px; /* 歯車ボタンの下に配置 */
    right: 15px;
    font-size: 20px;
    font-weight: bold;
}

.toggle-controls-btn:hover, .fullscreen-btn:hover {
    background: rgba(50, 50, 50, 0.9);
    opacity: 1;
    transform: scale(1.1);
}

.toggle-controls-btn:hover {
    transform: scale(1.1) rotate(90deg);
}

.controls label {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: #ccc;
}

.slider-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.controls select {
    background: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

.clock-area {
    flex: 1;
    position: relative;
    overflow: hidden;
    width: 100%;
}

/* ウィジェット（ドラッグ＆リサイズ可能なコンテナ） */
.clock-widget {
    position: absolute;
    /* プレースホルダーの初期位置（JSで上書きされる） */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    
    padding: 10px;
    cursor: move;
    user-select: none;
    touch-action: none; /* スマホでのスクロール防止 */
    
    border: 1px solid transparent; /* 通常時は見えない */
}

/* 選択（アクティブ）時のバウンディングボックス */
.clock-widget.active {
    border: 1px dashed var(--bbox-color);
    background-color: rgba(255, 255, 255, 0.02);
}

/* リサイズハンドル */
.resize-handle {
    position: absolute;
    right: -5px;
    bottom: -5px;
    width: 10px;
    height: 10px;
    background-color: var(--handle-color);
    border: 1px solid #000;
    cursor: nwse-resize;
    display: none; /* デフォルトは非表示 */
    z-index: 20;
}

/* アクティブ時のみハンドルを表示 */
.clock-widget.active .resize-handle {
    display: block;
}

/* アナログ時計 */
.analog-clock {
    border: var(--clock-border-w) solid var(--clock-border);
    border-radius: 50%;
    background-color: var(--clock-bg);
    position: relative;
    box-shadow: var(--shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
    
    /* ウィジェットのサイズに100%追従させる */
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

.hand {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform-origin: bottom center;
    background-color: var(--text-color);
    border-radius: 4px;
}

.hour-hand {
    width: var(--hour-hand-w);
    height: 28%;
    margin-left: calc(var(--hour-hand-w) / -2);
    background-color: var(--text-color);
    opacity: 0.8;
    z-index: 2;
}

.minute-hand {
    width: var(--min-hand-w);
    height: 40%;
    margin-left: calc(var(--min-hand-w) / -2);
    z-index: 3;
}

.second-hand {
    width: var(--sec-hand-w);
    height: 45%;
    margin-left: calc(var(--sec-hand-w) / -2);
    background-color: var(--accent-color);
    z-index: 4;
}

.center-dot {
    position: absolute;
    top: 50%;
    left: 50%;
    width: max(4px, 2%);
    height: max(4px, 2%);
    border-radius: 50%;
    background-color: var(--accent-color);
    transform: translate(-50%, -50%);
    z-index: 5;
}

.clock-mark {
    position: absolute;
    background-color: var(--mark-color);
    top: 0;
    left: 50%;
    width: var(--mark-w);
    height: var(--mark-h);
    margin-left: calc(var(--mark-w) / -2);
    transition: background-color 0.3s ease;
}

.clock-mark.is-hour {
    background-color: var(--mark-color-main);
    width: var(--mark-main-w);
    height: var(--mark-main-h);
    margin-left: calc(var(--mark-main-w) / -2);
}

.clock-number {
    position: absolute;
    color: var(--text-color);
    font-weight: bold;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s ease, font-size 0.3s ease;
    z-index: 1;
    /* デジタル時計と同じフォントを適用するため、フォントファミリーはJSで設定 */
}

/* デジタル時計 */
.digital-clock {
    font-family: 'Roboto Mono', monospace; /* Default */
    font-size: 150px;
    font-weight: bold;
    color: var(--text-color);
    text-shadow: 0 0 20px rgba(0,0,0,0.5);
    white-space: nowrap;
    user-select: none;
    line-height: 1;
}

/* 日付表示 */
.date-display {
    font-family: 'Roboto Mono', monospace; /* Default, will be updated by JS */
    font-size: 50px;
    font-weight: bold;
    color: var(--text-color);
    text-shadow: 0 0 10px rgba(0,0,0,0.5);
    white-space: nowrap;
    user-select: none;
    line-height: 1;
    transition: color 0.3s ease;
}

/* 曜日・祝日用のカラークラス */
.date-display.color-red {
    color: #ff3b30;
}
.date-display.color-blue {
    color: #0a84ff;
}

/* 祝日名のスパン用 */
.holiday-name {
    margin-left: 0.5em;
    font-size: 0.7em;
    opacity: 0.9;
}

@media (max-width: 768px) {
    .controls {
        gap: 15px;
    }
}
