:root {
    --bg-gradient: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --text-color: #2d3436;
    --clock-bg: #ffffff;
    --clock-border: black;
    --hand-color: #111111;
    --marker-color: #dddddd;
    --small-marker-color: #eeeeee;
    --main-box-bg: rgba(255, 255, 255, 0.25);
    --main-box-border: rgba(255, 255, 255, 0.18);
    --button-bg: rgba(255, 255, 255, 0.7);
    --button-color: #2d3436;
    --slider-bg: #ccc;
    --slider-active: #00AF84;
}

[data-theme="dark"] {
    --bg-gradient: linear-gradient(135deg, #2d3436 0%, #000000 100%);
    --text-color: #f5f6fa;
    --clock-bg: #000000;
    --clock-border: #ffffff;
    --hand-color: #ffffff;
    --marker-color: #ffffff;
    --small-marker-color: rgba(255, 255, 255, 0.5);
    --main-box-bg: rgba(45, 52, 54, 0.25);
    --main-box-border: rgba(255, 255, 255, 0.1);
    --button-bg: rgba(45, 52, 54, 0.7);
    --button-color: #f5f6fa;
    --slider-bg: #4a4a4a;
    --slider-active: #00AF84;
}

html {
    text-align: center;
    font-size: 10px;
    background: var(--bg-gradient);
    min-height: 100vh;
}

body {
    background: transparent;
    font-family: 'Pretendard', 'Noto Sans CJK KR', 'Noto Sans KR', Arial, sans-serif;
    margin: 0;
    font-size: 2rem;
    display: flex;
    flex: 1;
    min-height: 100vh;
    align-items: center;
    color: var(--text-color);
}

button {
    font-family: 'Pretendard', 'Noto Sans CJK KR', 'Noto Sans KR', Arial, sans-serif;
    font-size: 15px;
}
::-webkit-scrollbar {
    display: none;
}
#main-box {
    margin: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--main-box-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    border: 1px solid var(--main-box-border);
    min-width: 600px;
    max-width: 800px;
    width: 90%;
}

#top-box {
    align-self: flex-start;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    border-left: 5px solid #2d3436;
    padding-left: 12px;
    padding-bottom: 10px;
    width: 100%;
}

#sub-box{
    text-align: left;
}

.clock {
    width: 30rem;
    height: 30rem;
    position: relative;
    padding: 2rem;
    border: 0.1em solid var(--clock-border);
    border-radius: 50%;
    margin: 40px auto;
    background: var(--clock-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: padding 0.3s ease, width 0.3s ease, height 0.3s ease;
}

/* 페이지 로드 시 transition 비활성화 */
.clock.loading {
    transition: none !important;
}

.inner-clock-face.loading {
    transition: none !important;
}

.clock-number.loading {
    transition: none !important;
}

@media (max-width: 850px) {
    .clock {
        width: 25rem;
        height: 25rem;
    }
    
    #main-box {
        min-width: auto;
        width: 95%;
        padding: 2rem;
    }
    
    .clock-number {
        font-size: 3+rem;
        width: 2rem;
        height: 2rem;
    }
}
.outer-clock-face {
    position: relative;
    background: var(--clock-bg);
    overflow: hidden;
    width: 100%;
    height: 100%;
    border-radius: 100%;
}
  
.outer-clock-face::after {
    -webkit-transform: rotate(90deg);
    -moz-transform: rotate(90deg);
    transform: rotate(90deg)
}
  
.outer-clock-face::after,
.outer-clock-face::before,
.outer-clock-face .marking,
.outer-clock-face .small-marking{
    content: '';
    position: absolute;
    width: 5px;
    height: 100%;
    background: hwb(0 0% 100%);
    z-index: 0;
    left: 49%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.outer-clock-face .marking {
    background: var(--marker-color);
    width: 3px;
}
  
.outer-clock-face .small-marking {
    background: var(--small-marker-color);
    width: 1px;
}

.outer-clock-face .marking.marking-one {
    -webkit-transform: rotate(30deg);
    -moz-transform: rotate(30deg);
    transform: rotate(30deg)
}
  
.outer-clock-face .marking.marking-two {
    -webkit-transform: rotate(60deg);
    -moz-transform: rotate(60deg);
    transform: rotate(60deg)
}
  
.outer-clock-face .marking.marking-three {
    -webkit-transform: rotate(120deg);
    -moz-transform: rotate(120deg);
    transform: rotate(120deg)
}
  
.outer-clock-face .marking.marking-four {
    -webkit-transform: rotate(150deg);
    -moz-transform: rotate(150deg);
    transform: rotate(150deg)
}

.inner-clock-face {
    position: absolute;
    top: 3%;
    left: 3%;
    width: 94%;
    height: 94%;
    background: var(--clock-bg);
    -webkit-border-radius: 100%;
    -moz-border-radius: 100%;
    border-radius: 100%;
    z-index: 1;
    transition: all 0.3s ease;
    /* 처음부터 존재하도록 설정 */
    opacity: 1;
    visibility: visible;
}

/* 시계 숫자 스타일 */
.clock-number {
    position: absolute;
    font-size: 3.5rem;
    font-weight: 500;
    color: var(--text-color);
    z-index: 2;
    transform-origin: center;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 1;
}

.number-12 { top: 2%; left: 50%; transform: translateX(-50%); }
.number-1 { top: 7.4%; right: 24%; }
.number-2 { top: 22%; right: 7.5%; }
.number-3 { top: 50%; right: 1%; transform: translateY(-50%); }
.number-4 { bottom: 23.9%; right: 7.9%; }
.number-5 { bottom: 8%; right: 24%; }
.number-6 { bottom: 2%; left: 50%; transform: translateX(-50%); }
.number-7 { bottom: 9%; left: 24.5%; }
.number-8 { bottom: 24%; left: 7.8%; }
.number-9 { top: 50%; left: 2%; transform: translateY(-50%); }
.number-10 { top: 23.2%; left: 10.5%; }
.number-11 { top: 7.7%; left: 25.4%; }

/* 시계 숫자 숨김/표시 클래스 */
.clock-number.hidden {
    opacity: 0;
    pointer-events: none;
}

/* inner clock face 크기 조절 클래스 */
.inner-clock-face.compact {
    top: 10%;
    left: 10%;
    width: 80%;
    height: 80%;
}

/* 시계 숫자 토글 버튼 활성화 상태 */
#numbers-toggle-btn.active {
    background: var(--slider-active) !important;
    color: white !important;
}

/* 숫자가 보일 때 clock padding 줄이기 */
.clock.numbers-visible {
    padding: 1rem;
    width: 32rem;
    height: 32rem;
}
/* 숫자가 보일 때 marking 색상 변경 */
.clock.numbers-visible .outer-clock-face .marking {
    background: #d2d2d2;
}

.clock.numbers-visible .outer-clock-face .small-marking {
    background: #d2d2d2;
}

.inner-clock-face::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    border-radius: 18px;
    margin-left: -9px;
    margin-top: -6px;
    background: #4d4b63;
    z-index: 4;
}

.hand {
    width: 50%;
    right: 50%;
    height: 6px;
    background: var(--hand-color);
    position: absolute;
    top: 50%;
    border-radius: 6px;
    transform-origin: 100%;
    transform: rotate(90deg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
  
.hand.hour-hand {
    width: 30%;
    z-index: 2;
}
  
.hand.min-hand {
    height: 3px;
    z-index: 3;
    width: 40%;
}
  
.hand.second-hand {
    background: red;
    width: 45%;
    height: 2px;
    z-index: 3;
}

.index-btns {
    margin-top: 10px;
    cursor: pointer;
    outline: 0;
    display: inline-block;
    line-height: 1.5;
    text-align: center;
    background-color: var(--button-bg);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 16px 24px;
    border-radius: 12px;
    color: #2d3436;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 5px 5px;
    font-size: 1.1em;
    font-weight: 500;
}
@media ( max-width: 415px ) {
    .index-btns {
        padding: 12px 16px;
    }
}

#yebi, #junbi, #bon, #broad, #broadend, #yebi-han, #junbi-han, #bon-han, #yebi-1, #junbi-1, #bon-1, #yebi-2, #junbi-2, #bon-2, #stop-1 {
    font-size: 0.8em;
}

.index-btns:hover {
    background-color: rgba(45, 52, 54, 0.9);
    color: #ffffff;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}

#korean:hover {
    background-color: rgba(0, 175, 132, 0.9);
    border-color: rgba(0, 175, 132, 0.9);
    color: #fff;
}

.korean-btns {
    color: #00AF84;
    border-color: rgba(0, 175, 132, 0.3);
    background-color: rgba(255, 255, 255, 0.7);
}

.korean-btns:hover {
    background-color: rgba(0, 175, 132, 0.9);
    border-color: rgba(0, 175, 132, 0.9);
    color: #fff;
}

#math:hover {
    background-color: rgba(229, 0, 127, 0.9);
    border-color: rgba(229, 0, 127, 0.9);
    color: #fff;
}

.math-btns {
    color: #e5007f;
    border-color: rgba(229, 0, 127, 0.3);
    background-color: rgba(255, 255, 255, 0.7);
}

.math-btns:hover {
    background-color: rgba(229, 0, 127, 0.9);
    border-color: rgba(229, 0, 127, 0.9);
    color: #fff;
}

#english:hover {
    background-color: #00A0E8;
    border-color: #00A0E8;
    color: #fff;
}

#research:hover {
    background-color: #004A95;
    border-color: #004A95;
    color: #fff;
}

#theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

#broadcast-toggle {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 100;
}

#numbers-toggle {
    position: fixed;
    top: 120px;
    right: 20px;
    z-index: 100;
}

#faq-toggle {
    position: fixed;
    top: 170px;
    right: 20px;
    z-index: 100;
}

#theme-toggle-btn, #broadcast-toggle-btn, #numbers-toggle-btn, #faq-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    color: #2d3436;
}

#theme-toggle-btn:hover, #broadcast-toggle-btn:hover, #numbers-toggle-btn:hover, #faq-btn:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] #theme-toggle-btn, 
[data-theme="dark"] #broadcast-toggle-btn, 
[data-theme="dark"] #numbers-toggle-btn, 
[data-theme="dark"] #faq-btn {
    background: rgba(45, 52, 54, 0.9);
    color: #f5f6fa;
}

#broadcast-toggle-btn.active {
    opacity: 1;
}

#broadcast-toggle-btn:not(.active) {
    opacity: 0.5;
}

[data-theme="dark"] #broadcast-toggle-btn.active {
    opacity: 1;
}

[data-theme="dark"] #broadcast-toggle-btn:not(.active) {
    opacity: 0.5;
}

#faq-toggle a {
    text-decoration: none;
    color: inherit;
}

[data-theme="dark"] #faq-toggle a {
    color: #f5f6fa;
}

@media ( min-width: 850px ) {
    ins, iframe {
        position: absolute;
    }
}

h1, h2 {
    margin: 0;
}
h1 {
    font-size: 2.2em;
}
#now-time-h2 {
    margin-top: 10px;
    font-size: 1.2em;
    margin-bottom: 10px;
    font-weight: 300;
}

@media ( min-width: 900px ) {
    #now-time-h2 {
        font-weight: 400;
    }
}

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

.controls p {
    margin: 0;
    font-size: 15px;
    color: #2d3436;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
}

input:checked + .slider {
    background-color: #00AF84;
}

input:focus + .slider {
    box-shadow: 0 0 1px #00AF84;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

[data-theme="dark"] .controls p {
    color: #f5f6fa;
}

[data-theme="dark"] .slider {
    background-color: #4a4a4a;
}

[data-theme="dark"] input:checked + .slider {
    background-color: #00AF84;
}

[data-theme="dark"] .slider:before {
    background-color: #f5f6fa;
}

#top-description {
    margin: 0;
    font-size: 1.3em;
}

#toss-btn {
    margin-top: 10px;
    cursor: pointer;
    outline: 0;
    display: inline-block;
    line-height: 1.5;
    text-align: center;
    background-color: transparent;
    border: 1px solid transparent;
    padding: 10px 20px;
    border-radius: 7px;
    color: white;
    background-color: #3182f6;
    box-shadow: 2px 2px 5px #153869;
    margin: 5px 5px;
    font-size: 1.0em;
}

#toss-btn:hover {
    background-color: white;
    color: black;
    box-shadow: 2px 2px 5px gray;
}

p {
    margin-block-start: 0.8em;
    margin-block-end: 0.8em;
}

[data-theme="dark"] {
    html {
        background: linear-gradient(135deg, #2d3436 0%, #000000 100%);
    }
    
    body {
        color: #f5f6fa;
    }
    
    #main-box {
        background: rgba(45, 52, 54, 0.25);
        border: 1px solid rgba(255, 255, 255, 0.1);
    }
    
    .clock {
        background: #000000;
        border: 0.1em solid #ffffff;
    }
    
    .outer-clock-face {
        background: #000000;
    }
    
    .outer-clock-face::after,
    .outer-clock-face::before,
    .outer-clock-face .marking,
    .outer-clock-face .small-marking {
        background: #ffffff;
    }
    
    .outer-clock-face .marking {
        background: #ffffff;
        width: 3px;
    }
    
    .outer-clock-face .small-marking {
        background: rgba(255, 255, 255, 0.5);
        width: 1px;
    }
    
    .hand {
        background: #ffffff;
        box-shadow: 0 0 1px rgba(255, 255, 255, 0.3);
    }
    
    .inner-clock-face {
        background: #000000;
    }
    
    .inner-clock-face::before {
        background: #ffffff;
    }
    
    .clock-number {
        color: #f5f6fa;
    }
    
    .index-btns {
        background-color: rgba(45, 52, 54, 0.7);
        color: #f5f6fa;
    }
    
    .index-btns:hover {
        background-color: rgba(245, 246, 250, 0.9);
        color: #2d3436;
    }
    
    #top-box {
        border-left: 5px solid #f5f6fa;
    }
    
    .controls p {
        color: #f5f6fa;
    }
    
    .slider {
        background-color: #4a4a4a;
    }
    
    input:checked + .slider {
        background-color: #00AF84;
    }
    
    .slider:before {
        background-color: #f5f6fa;
    }
}

[data-theme="dark"] .second-hand {
    background: #ff0000;
    box-shadow: 0 0 1px rgba(255, 0, 0, 0.3);
}