/* style.css - Refactored and commented */

/* --- Root Variables --- */
:root {

  /* Theme Colors */
  --primary-bg-dark: #0f0f0f;
  --primary-text-dark: #fff;
  --primary-bg-light: #ffffff;
  --primary-text-light: #000000;

  /* UI Component Colors */
  --control-panel-bg: rgba(0, 0, 0, 0.3);
  --control-panel-border: #A6A6A6;
  --clock-color: #00e676;
  --message-color: #cccccc;
  
  /* Button Colors */
  --button-color-dark: white;
  --button-bg-dark: #0f0f0f;
  --button-color-light: #595959;
  --button-bg-light: #ffffff;
  --control-button-bg: #FF4D4D;
  --control-button-hover-bg: #FF1A1A;

  /* Chalkboard Specific */
  --chalkboard-bg: #163A1B; /* Chalkboard background color */

  /* Modal Colors */
  --modal-bg: rgba(255, 255, 255, 0.15);
  --modal-border: #A6A6A6;
  --close-btn-bg: #e74c3c;
  --close-btn-hover-bg: #ff1a1a;

  /* Input Field Colors */
  --input-border-dark: #A6A6A6;
  --input-bg-dark: rgba(0, 0, 0, 0.35);
  --input-text-dark: #fff;
  --input-border-light: #888;
  --input-bg-light: rgba(255, 255, 255, 0.35);
  --input-text-light: #000;

  /* Menu Icon */
  --menu-icon-size: 20px;
  --menu-icon-width: 40px;
  --menu-icon-height: 40px;  
  --menu-icon-move: 12px;
  --menu-icon-left: 10px;
}

/* --- Global Resets & Base Styles --- */
* {
  box-sizing: border-box;
}



html, body {
  margin: 0;
  padding: 0;
  overflow: hidden; /* 스크롤바 방지 */
  width: 100%;
  height: 100%;
  background-color: var(--primary-bg-dark);
  color: var(--primary-text-dark);
  font-family: 'Noto Sans', sans-serif;
}

/* 시계 모드에서 배경 이미지가 있을 때만 body 배경을 투명하게 */
body.clock-mode.has-background-image {
  background: transparent !important;
}

/* 칠판 모드에서는 시계 배경 이미지 클래스가 있어도 배경색 유지 */
body.chalkboard-mode.has-background-image {
  background-color: var(--primary-bg-dark) !important;
}



button:focus {
    outline: none;
}

.hidden {
  display: none;
}

#chalkTray {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 130px;
  background-color: var(--chalkboard-bg); /* 배경색도 유지 */
  background-image: url('assets/bottom_tray.png');
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: 100% 100%; /* 좌우 + 상하 꽉 채움 */
  z-index: 1000;
  display: none;
  pointer-events: auto;
  cursor: default !important;
}

/* 이미지 진행률 바 스타일 */
#imageProgressBar {
    position: fixed;
    right: 30px;
    bottom: 30px;
}

/* 페이지 번호 표시 스타일 (프로그레스 바 위) */
.page-number-display {
    position: fixed !important;
    right: 30px !important;
    top: calc(100vh - 100px) !important;
    z-index: 2020;
    pointer-events: none;
    display: none;
}

#pageNumberText {
    color: rgba(255, 255, 255, 0.2);
    font-size: 50px;
    font-weight: 900;
    text-shadow: 2px 2px 4px rgba(22, 58, 27, 0.2);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

#imageProgressBar {
    width: 150px;
    height: 10px;
    background-color: rgba(22, 58, 27, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.4) !important; 
    border-radius: 5px;
    overflow: hidden;
    display: none;
    z-index: 2010;
}

#progressBarFill {
    height: 100%;
    width: 0%;
    background-color: rgba(255, 255, 255, 0.4); /* 더 투명하게 */
 /*   border: 1px solid rgba(0, 0, 0, 0.3) !important;*/
    border-radius: 5px;
    transition: width 0.2s ease-in-out;
}

#pageNumberDisplay {
    position: fixed;
    right: 30px;
    bottom: 50px;
    color: white;
    font-size: 14px;
    white-space: nowrap;
    display: none;
    z-index: 2010;
}

#languageSelector {
  background-color: rgba(17, 42, 20, 0.3) !important;
  padding: 8px 20px; 
  color: #fff; 
  border-radius: 12px; 
}

.chalk-title {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 36px;
  font-weight: bold;
  color: white;
  z-index: 2100;
  user-select: none;
  cursor: pointer;
  pointer-events: auto;
  display: none; 
  text-align: center;
}

/* 밑줄을 위한 가상 요소 */
.chalk-title::after {
  content: "";
  display: block;
  margin: 4px auto 0 auto;
  height: 2px;
  background-color: var(--underline-color, white);
  width: 100%;
}

#newTitle { 
  font-size: 16px !important;
  padding: 8px;
  width: 100%;
  max-width: 500px;
  box-sizing: border-box;
}

#titleModal input[type="number"] {
  font-size: 16px !important;
  padding: 8px;
  width: 100px;
  max-width: 400px;
  box-sizing: border-box;
}


#titleModal > div {
  max-width: 600px;
  width: 90%;
}

.top-clock {
  font-family: 'DS-Digital', sans-serif; /* 디지털 폰트 */
  font-size: 20px;
  color: white;
  letter-spacing: 2px;
  white-space: nowrap;
  display: block;
}

.top-clock {
  color: white;
}
/* --- Main Display (Clock & Message) --- */
#container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  transition: transform 0.1s ease;
  
  /* ✨ 추가: 시계 모드에서 투명한 검은색 배경과 둥근 모서리 */
  padding: 20px 30px;
  background-color: rgba(0, 0, 0, 0.15); /* 기본값, JavaScript에서 동적으로 변경됨 */
  border-radius: 20px;
  /*border: 1px solid rgba(255, 255, 255, 0.3) !important; */
  backdrop-filter: blur(5px);
}

#container:active {
  cursor: grabbing;
}

#container.dragging {
  opacity: 0.8;
  transform: translate(-50%, -50%) scale(1.02);
}

#clock {
  font-size: 200px;
  font-family: 'DS-Digital', sans-serif; /* Specific digital font */
  color: var(--clock-color);
  line-height: 1.0;
  padding-bottom: 0;
  white-space: nowrap; /* Prevent line breaks */
}

#message {
  text-align: center;
  width: 100%;
  display: block;
  font-size: 60px;
  color: var(--message-color);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis; /* Add ellipsis for overflow */
  max-width: 90vw; /* Limit message width */
}

/* --- Control Panel (Settings) --- */
.settings-panel {
  display: none; /* Hidden by default, toggled by JS */
  flex-direction: column;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 16px;
  margin-top: 8px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  background-color: rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(6px); /* Frosted glass effect */
  border: 1px solid var(--modal-border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.settings-panel .row {
  display: flex;
  flex-wrap: wrap; /* Allow wrapping for responsiveness */
  align-items: center;
  gap: 8px; /* Spacing between elements */
  margin: 2px 0;
  width: 100%; /* Take full width of parent */
}

.settings-panel .timer-mode-row {
  flex-wrap: wrap;
  gap: 10px 15px; /* Vertical and horizontal gap */
  justify-content: flex-start;
}

.settings-panel .timer-inputs,
.settings-panel .timerControls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-panel .font-settings-row {
  flex-wrap: wrap;
  gap: 10px 15px;
  justify-content: flex-start;
}

.settings-panel label {
  min-width: 10px;
  text-align: left; 
  font-weight: 500;
  margin-right: 0px;
  flex-shrink: 0; 
}

.settings-panel select,
.settings-panel input[type="text"],
.settings-panel input[type="number"],
.settings-panel input[type="color"],
.settings-panel textarea {
  min-width: 80px;
  max-width: 250px;
  flex-grow: 1;
  padding: 5px;
  font-size: 16px;
  border-radius: 8px;
  border: 1px solid #444;
  background-color: #5c5b5b;
  color: #fff;
}

.settings-panel #modeSelector {
  max-width: 120px;
  min-width: 100px;
}

.settings-panel .font-settings-row select {
  flex-grow: 1;
  min-width: 100px;
  max-width: 150px;
}

.settings-panel .font-settings-row select:nth-of-type(even) { /* Targeting size select boxes */
  min-width: 80px;
  max-width: 100px;
}

.settings-panel .timer-inputs input[type="number"] {
  width: 50px;
  min-width: 40px;
  max-width: 60px;
  flex-grow: 0;
  text-align: center;
}

.settings-panel input[type="color"] {
  width: 36px;
  height: 28px;
  padding: 0;
  border: none;
  background: none;
  flex-shrink: 0;
  margin-right: 12px;
}

.settings-panel .message-input-group {
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  width: 100%;
  margin-top: 10px;
}

.settings-panel .message-input-group label {
  min-width: unset;
  margin-right: 0;
  text-align: left;
}

.settings-panel .message-input-group select#presetMessages,
.settings-panel .message-input-group textarea#messageText {
  width: 100%;
  max-width: none;
  flex-grow: unset;
}

.settings-panel .message-input-group textarea#messageText {
  min-height: 50px;
  margin-top: 5px;
}

/* Theme-specific styles for settings panel inputs */
.settings-panel select,
.settings-panel input[type="text"],
.settings-panel input[type="number"],
.settings-panel textarea {
  border: 1px solid var(--input-border-dark) !important;
  color: #ffffff !important;
  background-color: var(--input-bg-dark);
}

/* select option 드롭다운 배경/글자색 */
.settings-panel select,
.settings-panel option {
  background: rgba(0, 0, 0, 0.5) !important;
  color: #fff !important;
}

/* --- Control Buttons Panel (Left Sidebar) --- */
#menuPanel button {
  position: absolute;
  left: var(--menu-icon-left);
  width: var(--menu-icon-width);
  height: var(--menu-icon-height);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: transparent;
  color: white !important;
  border: none;
  border-radius: 8px;
  font-size: var(--menu-icon-size);
  z-index: 1100;
  cursor: pointer;
}

/* Individual Button Positioning */
#toggleSettings { top: 40px; }
#toggleChalkboard { top: 10px; }
#calculator { top: 70px; }
#random { top: 100px; }
#focusMode { top: 130px; }
#toggleFullscreen { top: 160px; }
#loadBackgroundBtn { top: 210px; }
#clearBackgroundBtn { top: 240px; }
#playVideoButton { top: 270px; }
#selectAudioButton { top: 270px; }
#practiceManagerIcon { top: 320px; }
#SurveyIcon { top: 350px; }
#TeacherIcon { top: 380px; }
#controlHelpButton { top: 430px; }

/* Chalkboard Buttons */
#dottedLineBtn { top: 185px; }
#pencilBtn { top:215px; }
#markerBtn { top: 245px; }
#fillBtn { top: 275px; }
#eraserBtn { top: 305px; }
#clearBtn { top: 335px; }
#saveCanvasBtn { top: 385px; }
#loadCanvasBtn { top: 415px; }
#loadFolderBtn { top: 415px; }
#clearCanvasBtn { top: 445px; }
#helpButton { top: 495px; } 

body.chalkboard-mode #toggleFullscreen {
  top: 70px;
}

body.chalkboard-mode #calculator {
  top: 40px;
}

body.chalkboard-mode #toggleSettings  {
  top: 10px;
}

#menutoggleBtn  {
  bottom: 50px;
  left: 10px;
  position: fixed;
  width: var(--menu-icon-width);
  height: var(--menu-icon-height);
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ccc;
  border: none;
  border-radius: 8px;
  font-size: var(--menu-icon-size);
  z-index: 10000; /* 더 높은 z-index로 설정 */
  cursor: pointer !important; /* 강제로 pointer 커서 설정 */
  pointer-events: auto !important; /* 클릭 이벤트 강제 활성화 */
  background-color: transparent;
  filter: drop-shadow(0 0 1px #222) drop-shadow(0 0 2px #222);
}

/* 기존 hover 효과 제거 및 transform 통합 */
#menuPanel button, #menutoggleBtn {
  transition: transform 0.18s cubic-bezier(0.4,0,0.2,1), color 0.18s;
}
#menuPanel button:hover, #menutoggleBtn:hover {
  transform: scale(1.2);
  z-index: 2;
}

/* 도구 버튼 비활성화 스타일 (투명도로 표현) */
#menuPanel button.inactive {
  opacity: 0.6;
  filter: grayscale(50%);
  pointer-events: none;
}

/* 점선 모드 버튼 활성화 스타일 */
#menuPanel button.active {
  background-color: rgba(255, 255, 255, 0.2) !important;
  border-radius: 5px;
  box-shadow: 0 0 2px rgba(255, 255, 255, 0.3);
}

#calculator, #toggleChalkboard {
  font-size: 20px;
}

.control-buttons-panel {
    top: 50px;
    position: fixed;
    width: 60px;
    height: 650px;
    z-index: 1100;
    transition: transform 0.3s ease-in-out;
    display: flex; 
    margin-top: 5px;
    transform: translateX(0); /* 기본 상태: 보이는 상태 */
}

/* 메뉴 패널이 숨겨진 상태 */
.control-buttons-panel.hidden {
    transform: translateX(-100%); /* 왼쪽으로 완전히 숨김 */
}

body.dark.chalkboard-mode .control-buttons-panel {
    height: 550px;
    background-color: rgba(17, 42, 20, 0.3) !important;
    border-top-right-radius: 25px;
    border-bottom-right-radius: 25px;
    border-right: 2px solid rgba(255, 255, 255, 0.3); 
    border-bottom: 2px solid rgba(255, 255, 255, 0.3);
}

.control-buttons-panel button {
  color: var(--button-color-dark);
  background-color: transparent !important;
}

.control-buttons-panel {
  height: 490px;
  border-top-right-radius: 25px;
  border-bottom-right-radius: 25px;
  border-right: 2px solid rgba(255, 255, 255, 0.2); 
  border-bottom: 2px solid rgba(255, 255, 255, 0.2);
  background-color: rgba(0, 0, 0, 0.2) !important;
}

/* General Control Button Style (for Start/Stop/Reset) */
.control-button {
  padding: 4px 15px;
  font-weight: 400;
  font-size: 16px;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: all 0.3s ease;
  background-color: var(--control-button-bg);
  color: #fff;
}

.control-button:hover {
  background-color: var(--control-button-hover-bg);
}



/* body.chalkboard-mode {
  background-color: var(--chalkboard-bg) !important;
  background-image: linear-gradient(to bottom, rgba(200, 200, 200, 0.2) 1px, transparent 1px);
  background-size: 100% 50px; 
  color: transparent !important; 
} */


body.chalkboard-mode {
  position: relative;
  color: transparent !important;
}

body.chalkboard-mode::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 0px;
  height: 100%;
  background: var(--chalkboard-bg); /* 배경색으로 덮음 */
  z-index: 1;
  pointer-events: none;
}

body.focus-mode.chalkboard-mode::before { 
  display: none !important; 
}

/* Hide non-chalkboard elements in chalkboard mode */
body.chalkboard-mode #container,
body.chalkboard-mode #toggleChalkboard,
body.chalkboard-mode #playVideoButton,
body.chalkboard-mode #selectAudioButton,
body.chalkboard-mode #practiceManagerIcon,
body.chalkboard-mode #SurveyIcon,
body.chalkboard-mode #TeacherIcon,
body.chalkboard-mode #loadBackgroundBtn,
body.chalkboard-mode #clearBackgroundBtn,
body.chalkboard-mode #controlHelpButton,
body.chalkboard-mode #random,
body.chalkboard-mode #focusMode,
body.chalkboard-mode #loadFolderBtn,
body.chalkboard-mode .settings-panel {
  display: none !important;
}

/* Style for the chalkboard toggle button when active */
body.chalkboard-mode #toggleChalkboard {
  pointer-events: none;
  opacity: 0.6;
  cursor: default;
  background-color: var(--chalkboard-bg) !important;
}

/* Ensure other control buttons are visible and styled correctly in chalkboard mode */
body.chalkboard-mode #toggleSettings,
body.chalkboard-mode #calculator,
body.chalkboard-mode #eraserBtn,
body.chalkboard-mode #clearBtn,
body.chalkboard-mode #pencilBtn,
body.chalkboard-mode #markerBtn,
body.chalkboard-mode #fillBtn,
body.chalkboard-mode #dottedLineBtn,
body.chalkboard-mode #clearCanvasBtn,
body.chalkboard-mode #helpButton,
body.chalkboard-mode #saveCanvasBtn,
body.chalkboard-mode #loadCanvasBtn,
/*body.chalkboard-mode #loadFolderBtn,*/
body.chalkboard-mode #menutoggleBtn,
body.chalkboard-mode #toggleFullscreen {
  display: flex !important;
  background-color: transparent !important;
  color: var(--button-color-dark) !important;
  cursor: pointer !important;
}

/* 점선 버튼이 확실히 보이도록 추가 규칙 */
body.chalkboard-mode #dottedLineBtn {
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* 점선 버튼의 아이콘 스타일링 */
#dottedLineBtn i {
  font-size: 1em;
}


/* Chalkboard Tools (Initial Hidden State) */
#playVideoButton,
#eraserBtn,
#clearBtn,
#pencilBtn,
#markerBtn,
#fillBtn,
#dottedLineBtn,
#clearCanvasBtn,
#saveCanvasBtn,
#loadCanvasBtn, 
#loadFolderBtn,
#helpButton {
  display: none !important; /* Hidden by default, shown in chalkboard mode via JS */
}

/* Color Palette and Line Width Controls */
.color-palette {
  position: absolute;
  top: 110px; 
  left: 10px; 
  display: none; 
  flex-direction: column;
  gap: 6px;
  z-index: 1100;
  margin-top: 20px;
  transition: left 0.2s ease;
}

.color-palette-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Preset Color Selection */
.preset-color-wrapper {
  position: relative;
  display: inline-block;
}

.preset-color-trigger {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
}

.color-dot {
  width: var(--menu-icon-size);
  height: var(--menu-icon-size);
  border: 1px solid white; /* Match background for seamless look */
  border-radius: 50%;
  cursor: pointer;
  position: relative;
  margin-top: 8px !important;
  margin-bottom: 8px !important;
}

.color-dot.selected {
  outline: none;
}

.selected-color-dot {
  width: var(--menu-icon-size);
  height: var(--menu-icon-size);
  outline: 2px solid white !important;
  outline-offset: 2px;
  border-radius: 50%;
  position: relative;
  transition: outline 0.2s ease;
  left: 3px;
}

.preset-colors {
  position: absolute;
  left: 50px;
  height: 34px;
  width: 260px;
  top: -2px;
  display: flex;
  gap: 4px;
  justify-content: center;
  background: rgba(17, 42, 20, 0.3) !important;
  border-radius: 6px;
  z-index: 100;
}

.preset-colors.hidden {
  display: none;
}

/* Line Width Controls */
.line-width-wrapper {
  position: relative;
  display: inline-block;
}

.selected-line-width {
  width: 32px;
  height: 24px;
  left: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
}

.selected-line-width:hover {
  transform: scale(1.2);
  z-index: 2;
}

.line-width-options {
  position: absolute;
  top: -2px;
  left: 50px;
  height: 34px;
  width: 160px;
  justify-content: center;
  display: flex;
  flex-direction: row;
  gap: 4px;
  background: rgba(17, 42, 20, 0.3) !important;
  border-radius: 6px;
  z-index: 100;
}

.line-width-options.hidden {
  display: none;
}

.line-width-option {
  width: 32px;
  height: 18px;
  border: 0px solid var(--chalkboard-bg);
  border-radius: 0px;
  background-color: transparent;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  position: relative;
  margin-top: 8px !important;
  margin-bottom: 8px !important;
 /* margin-bottom: 2px;*/
}

.line-width-option > div {
  display: block;
  border-radius: 0 !important;
  width: 100%;
}

.line-width-option .dot {
  background-color: white;
  border-radius: 0%;
}

/* --- Modals and Overlays --- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 3333;
  display: none; /* Hidden by default */
  justify-content: center;
  align-items: center;
  pointer-events: auto;
}

#confirmClearModal {
  width: 700px;
}

#confirmClearModal .modal-content {
  min-width: 500px;
  max-width: 100%;
  width: 700px;
  text-align: center;
}

#confirmClearMessage {
  width: 100%;
  text-align: center;
  white-space: nowrap;
  margin-bottom: 24px;
  display: block;
}

.confirm-clear-modal-content {
  text-align: center;
  margin: 0 auto;
}

.overlay > div { /* Common modal styles */
  background: var(--modal-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--primary-text-dark);
  padding: 20px 30px;
  border-radius: 18px;
  border: 1px solid var(--modal-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  font-family: 'Segoe UI', 'Noto Sans KR', sans-serif;
  line-height: 1.6;
  position: relative;
  text-align: left;
}

.overlay h3 {
  margin-top: 0;
  font-size: 22px;
  font-weight: bold;
  color: #f1f1f1;
}

.overlay ul {
  padding-left: 20px;
  margin-bottom: 12px;
}

.overlay li {
  margin-bottom: 6px;
}

.overlay p {
  margin-bottom: 8px;
  font-size: 15px;
}

.close-btn {
  position: absolute;
  top: 12px;
  right: 16px;
  background: var(--close-btn-bg);
  color: #fff;
  border: none;
  font-size: 16px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.close-btn:hover {
  background: var(--close-btn-hover-bg);
}

/* Control Help Modal Specific */
#controlHelpModal {
  max-width: 650px;
  width: 90%;
  overflow-y: auto;
  max-height: 90vh;
}

.branding-header {
  margin-bottom: 20px;
}

.branding-header h1 {
  font-size: 28px;
  margin-bottom: 6px;
}

.branding-header .tagline {
  color: #bbb;
  font-size: 15px;
  font-style: italic;
}

.tool-icon {
  margin-right: 8px;
  min-width: 20px;
  vertical-align: middle;
  font-size: 1em;
}

.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px; /* 행, 열 간격 */
}

.tool-buttons span {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 0; /* flex의 gap으로 대체 */
}

/* 이름에 최소 너비 지정 */
.tool-buttons span > span[data-i18n] {
  min-width: 90px;   /* 원하는 값으로 조정 */
  display: inline-block;
  text-align: left;
}

/* Random Number Modal Specific */
#randModal {
  width: 650px;
  max-width: 90%;
  max-height: 500px;
  padding-top: 16px;
  padding-bottom: 40px;
  display: none; /* Hidden by default */
}

.rand-modalcontent {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  width: 100%;
  flex-grow: 1;
}

.rand-modalcontent label,
.rand-modalcontent button {
  color: var(--primary-text-dark) !important;
}

.modalheader {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
}

.modaltitle {
  font-size: 24px;
}

.rand-modalcontent .input-row {
  display: flex;
  flex-wrap: nowrap; /* Prevent line breaks */
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  min-width: 400px;
}

.rand-modalcontent .input-row input {
  width: 160px;
}

.rand-modalcontent .input-row button {
  padding: 8px 14px;
  border-radius: 6px;
  border: none;
  background-color: var(--control-button-bg);
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.rand-modalcontent .input-row button:hover {
  background-color: var(--control-button-hover-bg);
}

.rand-result {
  font-size: 240px;
  font-weight: bold;
  text-align: center;
  color: #fff;
  margin: 0;
  padding: 0;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0px !important;
}

/* Focus Mode */
body.focus-mode {
  background-color: #000 !important;
  background-image: none !important;
}

body.focus-mode *:not(#focusMode):not(canvas) { /* Keep focusMode button visible */
  display: none !important;
}

body.focus-mode canvas {
  display: none !important; /* Hide canvas in focus mode if it's not active */
}

/* Video Player */
.video-player {
  max-width: 90vw;
  max-height: 80vh;
  background-color: black;
  border: 4px solid white;
  border-radius: 12px;
}

/* Canvas styles for layering */
#backgroundCanvas, #chalkCanvas {
  position: absolute;
  top: 0;
  height: 100vh;
  display: none; /* Hidden by default */
}

#chalkCanvas {
  touch-action: none;
  left: 0; /* 60px offset 제거 */
  width: 100vw; /* 전체 화면 사용 */
  z-index: 2; /* 격자보다 위에 위치하도록 z-index 증가 */
  background-color: transparent; /* Transparent to show background canvas below */
  cursor: inherit; /* 부모 요소의 커서를 상속하지 않음 */
  pointer-events: auto; /* 다시 활성화 */
}

/* 메뉴 토글 버튼 영역에서는 캔버스 클릭 이벤트를 통과시키기 위한 설정 */
#menutoggleBtn {
  pointer-events: auto !important;
  z-index: 10000 !important;
}

#backgroundCanvas {
  width: unset !important;
  height: unset !important;
  max-width: none !important;
  max-height: none !important;
  min-width: 0 !important;
  min-height: 0 !important;
  display: block;
  margin: auto;
  aspect-ratio: unset !important;
  object-fit: none !important;
  z-index: 0; /* 격자와 분할 화면이 모두 보이도록 z-index 조정 */
}

/* Language Dropdown */
.lang-dropdown {
  background-color: black;
  color: white;
  border: 1px solid #808080;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
}

body.chalkboard-mode .lang-dropdown {
  background-color: transparent !important;
  color: var(--button-color-dark) !important;
}

.lang-dropdown {
  background-color: transparent !important;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  backdrop-filter: blur(5px);
}

.lang-dropdown option {
  background-color: rgba(0, 0, 0, 0.7) !important;
  color: white !important;
}



.lang-dropdown:hover {
  background-color: #333;
}

#audioVisualizer {
  position: fixed;
  bottom: 20px;             /* 하단 여백 */
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  height: 40px;
  pointer-events: none;
  z-index: 10001;
  opacity: 0.6; 
  display: none;            
}

#musicModal {
  color: white;
  padding: 26px;
  border-radius: 12px;
  min-width: 600px;
  height: 200px;
  justify-content: center;
}

.audio-buttons {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: center; 
}

.audio-buttons button {
  all: unset;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  cursor: pointer;
}

.audio-buttons i {
  font-size: 26px;
  color: var(--close-btn-bg);
}

.audio-buttons i:hover{
  font-size: 26px;
  color: var(--control-button-hover-bg);
}

.practice-modal-stacked {
  min-width: 400px;
  min-height: 250px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  width: 90%;
  max-width: 600px;
  box-sizing: border-box;
}

#surveyModal.practice-modal-stacked {
  min-width: 600px;
  max-width: 900px;
}

#practiceModal.practice-modal-stacked {
  min-width: 400px;
  max-width: 600px;
}

#practiceStatusModal {
  min-width: 600px;
  padding-left: 40px;
  padding-right: 40px;
}

#practiceTitleInput,
#totalStudentsInput {
  width: 545px;      /* 원하는 너비 */
  min-width: 300px;  /* 최소 너비 */
  max-width: 600px;  /* 최대 너비 */
}

.modal-title-row {
  flex-direction: row !important;
  align-items: center !important;
  gap: 12px !important;
  width: 100%;
}

#surveyModal .modal-option-input {
  width: 130px;
  min-width: 100px;
  max-width: 200px;
}

#surveyTitleInput {
  width: 660px;
  min-width: 220px;
  max-width: 900px;
}

#surveyModal .modal-button-row {
  margin-top: 18px;
  margin-bottom: 10px;
  justify-content: center !important;
}

#practiceModal .modal-button-row {
  margin-top: 18px;
  margin-bottom: 10px;
  justify-content: center !important;
}

.modal-form-group {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 16px;
}

.modal-label {
  font-size: 16px;
  color: var(--input-text-dark);
  font-weight: 500;
  margin-bottom: 4px;
  margin-right: 0;
}

.modal-input {
  font-size: 16px !important;
  padding: 8px;
  width: 100%;
  max-width: 600px;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid var(--input-border-dark) !important;
  background-color: var(--input-bg-dark) !important;
  color: var(--input-text-dark) !important;
  margin-bottom: 0;
}



.modal-btn {
  min-width: 120px;
  font-size: 16px;
  padding: 8px;
  margin: 0 4px 0 0;
  border-radius: 6px;
  font-weight: 400;
  height: 40px;
}

.modal-button-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 10px;
  width: 100%;
  flex-wrap: wrap;
}

.modal-message {
  min-height: 36px;
  color: #fff;
  font-size: 18px;
  margin-top: auto;
  margin-bottom: 10px;
  width: 100%;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-status-title {
  color: #fff;
  text-align: center;
  margin: 0 0 10px 0;
  font-size: 28px;
}

.modal-status-content {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.modal-status-text {
  margin: 10px 0;
  font-size: 16px;
  color: #fff;
  text-align: center;
}

.modal-survey-options {
  width: 100%;
  display: flex !important;
  flex-direction: row !important;
  gap: 16px;
  margin-bottom: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: nowrap;
}

.modal-option-input {
  width: 250px;
  min-width: 120px;
  max-width: 300px;
  background: #fff;
  color: #000;
}

#surveyModal .modal-title-row,
#surveyModal .modal-survey-options {
  justify-content: flex-start !important;
  text-align: left !important;
}

#surveyModal .modal-title-row label,
#surveyModal .modal-survey-options label {
  text-align: left !important;
}

#surveyModal .modal-title-row,
#surveyModal .modal-survey-options {
  width: 100%;
}

#surveyModal .modal-button-row {
  justify-content: center !important;
}

@media (max-width: 1200px) {
  #surveyModal.practice-modal-stacked {
    min-width: 0;
    max-width: 98vw;
    padding: 0 2vw;
  }
  .modal-survey-options {
    flex-wrap: wrap;
    gap: 8px;
  }
  .modal-option-input {
    width: 100%;
    min-width: 0;
    max-width: 98vw;
  }
}

input:-webkit-autofill,
input:-webkit-autofill:focus,
input:-webkit-autofill:hover,
input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px var(--input-bg-dark) inset !important;
  -webkit-text-fill-color: var(--input-text-dark) !important;
  transition: background-color 5000s ease-in-out 0s;
  color: var(--input-text-dark) !important;
}

#languageSelector {
  display: flex;
  align-items: center;
  gap: 32px;
  justify-content: flex-start;
  transform: translateY(0);
  transition: transform 0.3s ease-in-out;
}

#languageSelector.hidden {
  transform: translateY(-100%);
}
#google-auth {
  min-width: 250px;
  flex-shrink: 0;
}
#google-auth button {
  min-width: 250px;
  padding-left: 16px;
  padding-right: 16px;
  margin-right: 0 !important;
  white-space: nowrap;
}
#google-auth button i {
  margin-right: 8px;
}
#topClock {
  margin-left: 24px;
  margin-right: 8px;
  flex-shrink: 0;
}

body:not(.clock-mode) #container,
body:not(.clock-mode) #clock {
  display: none !important;
}

/* 칠판 모드 헤더(로그인, 시계, 언어 선택) 흰색/투명 강제 */
.chalkboard-mode #google-auth,
.chalkboard-mode #google-auth * {
  color: #fff !important;
  background: transparent !important;
  border-color: #fff !important;
}
.chalkboard-mode #topClock {
  color: #fff !important;
  background: transparent !important;
}
.chalkboard-mode #languageDropdown {
  color: #fff !important;
  background: transparent !important;
  border: 1px solid #fff !important;
}
.chalkboard-mode #languageDropdown option {
  color: #fff !important;
  background: #1a3a23 !important;
}

/* 색상 선택 아이콘 hover 시 오른쪽으로 이동 + 커짐 (실제 클래스명 적용) */

.preset-color-trigger:hover {
  transform: scale(1.2);
  z-index: 2;
}

#backgroundCanvas,
#chalkCanvas,
#colorPalette,
#eraserToggleBtn,
#clearCanvasBtn,
#helpButton,
#saveCanvasBtn,
#loadCanvasBtn {
  display: none;
}

#controls, .settings-panel {
  position: fixed;
  top: 20px;
  left: 70px;
  transform: none;
  z-index: 2000;
}


#teacherLoginModal {
  width: 500px;      /* 원하는 너비 */
}

body.chalkboard-mode {
  background-color: var(--chalkboard-bg) !important;
}

/* === 세션 관리 UI 스타일 === */
.session-manager {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 1001;
  background: rgba(17, 42, 20, 0.8);
  border-radius: 8px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  min-width: 200px;
  max-width: 300px;
  transition: all 0.3s ease;
  opacity: 0.8;
}

.session-manager:hover {
  opacity: 1;
  background: rgba(17, 42, 20, 0.95);
}

.session-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  user-select: none;
}

.session-toggle-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 12px;
  padding: 2px;
  border-radius: 3px;
  transition: all 0.3s ease;
}

.session-toggle-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.session-toggle-btn.collapsed i {
  transform: rotate(-90deg);
}

.session-title {
  color: white;
  font-size: 12px;
  font-weight: 500;
  flex-grow: 1;
}

.session-content {
  padding: 8px 12px;
  transition: all 0.3s ease;
  overflow: hidden;
}

.session-content.collapsed {
  padding: 0 12px;
  max-height: 0;
}

.session-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 100%;
}

.session-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  padding: 6px 8px;
  color: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 400;
  transition: all 0.3s ease;
  white-space: nowrap;
  max-width: 150px;
  min-width: 80px;
}

.session-tab:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.session-tab.active {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
}

.session-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100px;
  font-weight: 400;
}

.session-close {
  background: rgba(255, 0, 0, 0.3);
  border: none;
  border-radius: 50%;
  width: 16px;
  height: 16px;
  color: white;
  cursor: pointer;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.session-close:hover {
  background: rgba(255, 0, 0, 0.5);
  transform: scale(1.1);
  box-shadow: 0 1px 4px rgba(255, 0, 0, 0.2);
}

.add-session-btn {
  background: rgba(0, 255, 0, 0.2);
  border: 1px solid rgba(0, 255, 0, 0.3);
  border-radius: 6px;
  padding: 6px 8px;
  color: white;
  cursor: pointer;
  font-size: 11px;
  font-weight: 400;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  flex-shrink: 0;
}

.add-session-btn:hover {
  background: rgba(0, 255, 0, 0.3);
  border-color: rgba(0, 255, 0, 0.5);
  transform: scale(1.05);
  box-shadow: 0 2px 6px rgba(0, 255, 0, 0.15);
}

.add-session-btn i {
  font-size: 12px;
}

/* 세션 탭이 많을 때 스크롤 가능하도록 */
.session-tabs {
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  padding-bottom: 2px;
}

.session-tabs::-webkit-scrollbar {
  height: 4px;
}

.session-tabs::-webkit-scrollbar-track {
  background: transparent;
}

.session-tabs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
}

.session-tabs::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* 기본 세션은 삭제 버튼 숨김 */
.session-tab[data-session="default"] .session-close {
  display: none !important;
}

/* 칠판 모드에서만 세션 관리자 표시 */
body.chalkboard-mode .session-manager {
  display: block !important;
}

/* Thumbnail Navigation Arrow */
#thumbnailNavArrow {
    transition: all 0.3s ease;
}

#thumbnailNavArrow:hover {
    background: rgba(0,0,0,0.15) !important;
    opacity: 0.6 !important;
    transform: translateX(-50%) scale(1.05);
}

#thumbnailNavArrow:hover i {
    opacity: 1 !important;
}

#backgroundToggleArrow {
    position: fixed;
    top: 0px;
    left: 50%;
    transform: translateX(-50%);
    width: 140px;
    height: 40px;
    background: rgba(0,0,0,0.08);
    border-radius: 0 0 20px 20px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 9990;
    transition: all 0.3s ease;
    pointer-events: auto;
    opacity: 0.3;
    margin-top: 0px;
    margin-bottom: 0px;
}

#backgroundToggleArrow:hover {
    background: rgba(0,0,0,0.15) !important;
    opacity: 0.6 !important;
    transform: translateX(-50%) scale(1.05);
}

#backgroundToggleArrow:hover i {
    opacity: 1 !important;
}

/* Image Gallery Styles */
.gallery-item {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.gallery-item:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.4);
}

.gallery-item img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 8px 8px 0 0;
}

.gallery-item div {
  color: #fff;
  font-size: 12px;
  text-align: center;
  margin-top: -4px;
}

#imageGalleryContainer {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
  cursor: grab;
}

#imageGalleryContainer::-webkit-scrollbar {
  width: 8px;
}

#imageGalleryContainer::-webkit-scrollbar-track {
  background: transparent;
}

#imageGalleryContainer::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

#imageGalleryContainer::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.5);
}

/* --- 투명도 조절 화살표 (컨테이너 위/아래) --- */
.opacity-arrow {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 30px;
  background: rgba(0, 0, 0, 0.2);  /* 투명도를 0.4로 변경 */
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  color: white;
  font-size: 16px;
  user-select: none;
 /* backdrop-filter: blur(5px);*/
  opacity: 0;
  z-index: 1000;
  pointer-events: none;
  /* 터치와 펜 입력을 위한 스타일 */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

#container:hover .opacity-arrow {
  opacity: 1;
  pointer-events: auto;
}

/* 위쪽 화살표 위치 (컨테이너 내부) */
.opacity-arrow-top {
  top: 0px;
  border-bottom: none;
  border-radius: 0px 0px 16px 16px;  /* 위쪽만 라운드 (컨테이너에 닿는 부분은 각진 상태) */
}

/* 아래쪽 화살표 위치 (컨테이너 내부) */
.opacity-arrow-bottom {
  bottom: 0px;
  border-top: none;
  border-radius: 16px 16px 0 0;  /* 아래쪽만 라운드 (컨테이너에 닿는 부분은 각진 상태) */
}

.opacity-arrow:hover {
  border-color: rgba(255, 255, 255, 0.6);
  background: rgba(0, 0, 0, 0.1); 
  transform: translateX(-50%) scale(1.05);
}

.opacity-arrow:active {
  transform: translateX(-50%) scale(0.98);
}

/* disabled 스타일 제거 - 화살표를 숨기는 방식으로 변경 */

body:not(.clock-mode) .opacity-arrow {
  display: none;
}

.opacity-arrow.touch-active {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* 기존 파일 입력 스타일 개선 - 모든 브라우저에서 완전히 숨김 */
input[type="file"] {
  position: absolute !important;
  left: -99999px !important;
  top: -99999px !important;
  width: 0 !important;
  height: 0 !important;
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  z-index: -9999 !important;
  display: none !important; /* 완전히 숨김 */
}

/* 파일 입력의 모든 가상 요소도 숨김 */
input[type="file"]::-webkit-file-upload-button {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

input[type="file"]::file-selector-button {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

/* Firefox 전용 */
input[type="file"]::-moz-file-upload-button {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
}

/* 포커스 상태에서도 완전히 숨김 */
input[type="file"]:focus {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
  background: transparent !important;
}

/* 활성 상태에서도 완전히 숨김 */
input[type="file"]:active {
  outline: none !important;
  box-shadow: none !important;
  border: none !important;
  background: transparent !important;
}