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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f9fafb;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

#app {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.clock-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 選項面板 */
.options-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 16px;
  width: 280px;
  font-size: 13px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.panel-header span {
  font-weight: 600;
  color: #374151;
}

.panel-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
  color: #6b7280;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.panel-toggle:hover {
  background-color: #f3f4f6;
}

.options-panel.collapsed .panel-content {
  display: none;
}

.options-panel.collapsed {
  width: auto;
  padding: 8px;
}

.options-panel.collapsed .panel-header {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.options-panel.collapsed .panel-header span#optionsPanelTitle {
  display: none;
}

.options-panel.collapsed .panel-toggle {
  font-size: 20px;
  padding: 4px;
}

.option-group {
  padding: 8px 0;
  border-bottom: 1px solid #f3f4f6;
}

.option-group:last-child {
  border-bottom: none;
}

.option-group .checkbox-label {
  width: 100%;
}

.option-group .slider-label {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.option-group .slider-label input[type="range"] {
  width: 100%;
}

/* 精簡視圖調整區 */
.compact-view-controls {
  margin-top: 8px;
  padding: 12px;
  background-color: #f9fafb;
  border-radius: 8px;
}

.compact-view-controls.hidden {
  display: none;
}

.compact-control-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
}

.compact-control-item:last-child {
  margin-bottom: 0;
}

.compact-control-item span:first-child {
  width: 70px;
  flex-shrink: 0;
  color: #6b7280;
}

.compact-control-item input[type="range"] {
  flex: 1;
  cursor: pointer;
}

.compact-control-item span:last-child {
  width: 45px;
  text-align: right;
  color: #374151;
  font-weight: 500;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.slider-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
}

.slider-label input[type="range"] {
  width: 100%;
  cursor: pointer;
}

#secondFreqValue {
  min-width: 50px;
  font-size: 12px;
  color: #666;
}

#manualTimeInput {
  padding: 6px 12px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 14px;
  width: 100%;
  margin-top: 8px;
}

#manualTimeInput.hidden {
  display: none;
}

.clock-svg {
  filter: drop-shadow(0 25px 25px rgba(0, 0, 0, 0.15));
  max-width: 100%;
  height: auto;
}

/* 主布局 */
.main-layout {
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

/* 農民曆資訊面板 */
.almanac-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 16px;
  width: 320px;
  font-size: 13px;
}

.almanac-section {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.almanac-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

/* 宜忌區塊 */
.yi-ji .almanac-row {
  display: flex;
  align-items: flex-start;
  margin-bottom: 8px;
}

.yi-ji .almanac-row:last-child {
  margin-bottom: 0;
}

.yi-ji .label {
  display: inline-block;
  width: 24px;
  height: 24px;
  line-height: 24px;
  text-align: center;
  border-radius: 4px;
  font-weight: bold;
  margin-right: 10px;
  flex-shrink: 0;
}

.yi-ji .label.yi {
  background-color: #fef3c7;
  color: #d97706;
}

.yi-ji .label.ji {
  background-color: #fee2e2;
  color: #dc2626;
}

.yi-ji .content {
  flex: 1;
  line-height: 1.6;
  color: #374151;
}

/* 資訊網格 */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.info-item {
  display: flex;
  flex-direction: column;
}

.info-item.wide {
  grid-column: span 3;
}

.info-label {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 2px;
}

.info-value {
  color: #374151;
  font-weight: 500;
}

/* 時辰吉凶 */
.shichen-section {
  padding: 0;
}

.shichen-header {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 8px;
}

.shichen-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
}

.shichen-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 4px 0;
  border-radius: 4px;
  font-size: 10px;
}

.shichen-item .zhi {
  font-weight: 500;
  margin-bottom: 2px;
}

.shichen-item .luck {
  font-size: 9px;
}

.shichen-item.ji {
  background-color: #fef3c7;
}

.shichen-item.xiong {
  background-color: #fee2e2;
}

/* 彭祖百忌 */
.pz-section {
  padding: 0;
}

.pz-header {
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
}

.pz-content {
  color: #374151;
  line-height: 1.5;
}

/* 二十八宿 */
.xiu-section {
  padding: 0;
}

.xiu-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.xiu-label {
  font-size: 11px;
  color: #9ca3af;
}

.xiu-value {
  color: #374151;
  font-weight: 500;
}

/* 響應式設計 */
@media (max-width: 1400px) {
  .main-layout {
    flex-direction: column;
    align-items: center;
  }

  .almanac-panel {
    width: 100%;
    max-width: 600px;
  }

  .info-grid {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

@media (max-width: 950px) {
  .clock-svg {
    width: 100%;
    height: auto;
  }

  .controls {
    flex-wrap: wrap;
    justify-content: center;
  }
}

/* 農民曆面板隱藏 */
.almanac-panel.hidden {
  display: none;
}

/* 選項面板隱藏 */
.options-panel.hidden {
  display: none;
}

/* 精簡視圖（只顯示部分圓盤） */
.clock-container.compact-view {
  --compact-width: 500px;
  --compact-height: 240px;
  --compact-left: -388px;
  --compact-top: -328px;
  position: relative;
  overflow: hidden;
  width: var(--compact-width);
  height: var(--compact-height);
}

.clock-container.compact-view .clock-svg {
  position: absolute;
  width: 900px;
  height: 900px;
  min-width: 900px;
  max-width: 900px;
  top: var(--compact-top);
  left: var(--compact-left);
}

/* 右側面板容器 */
.right-panels-container {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 12px;
}

/* 宜忌查詢面板 */
.yiji-query-panel {
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 12px;
  width: 128px;
  font-size: 12px;
}

.yiji-query-panel.hidden {
  display: none;
}

.yiji-query-header {
  font-weight: 600;
  color: #374151;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12px;
}

.yiji-query-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.yiji-control-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.yiji-control-row label {
  color: #6b7280;
  font-size: 11px;
}

.yiji-control-row select {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 11px;
  background: white;
  cursor: pointer;
}

.yiji-control-row select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.yiji-search-btn {
  width: 100%;
  padding: 6px 10px;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.yiji-search-btn:hover {
  background: #2563eb;
}

.yiji-search-btn:active {
  background: #1d4ed8;
}

.yiji-query-results {
  max-height: 250px;
  overflow-y: auto;
}

.yiji-result-item {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  border-bottom: 1px solid #f3f4f6;
}

.yiji-result-item:last-child {
  border-bottom: none;
}

.yiji-result-date {
  font-weight: 500;
  font-size: 11px;
  color: #374151;
}

.yiji-result-lunar {
  font-size: 10px;
  color: #9ca3af;
}

.yiji-result-weekday {
  font-size: 10px;
  color: #6b7280;
  margin-top: 2px;
}

.yiji-no-result {
  text-align: center;
  color: #9ca3af;
  padding: 20px 0;
}

/* Google AdSense 廣告容器 */
.ad-container {
  text-align: center;
  margin: 8px 0;
  min-height: 50px;
}

.ad-container.ad-bottom {
  max-width: 900px;
  margin: 12px auto;
  padding: 0 16px;
}

.ad-container.ad-sidebar {
  margin-top: 12px;
}
