/* テーマ変数 */
:root {
  --bg-main: #10203e;
  --bg-container: #14284e;
  --bg-scroll: #14284e;
  --bg-palette: #0e1d3a;
  --bg-time-label: #2e5dad;
  --text-calendar: #ddd;
  --text-stat: white;
}

/* 月テーマ（デフォルト） */
body[data-theme="moon"] {
  --bg-main: #10203e;
  --bg-container: #14284e;
  --bg-scroll: #14284e;
  --bg-palette: #0e1d3a;
  --bg-time-label: #2e5dad;
  --text-calendar: #ddd;
  --text-stat: white;
}

/* 太陽テーマ */
body[data-theme="sun"] {
  --bg-main: #fff5e6;
  --bg-container: #ffffff;
  --bg-scroll: #fffaf0;
  --bg-palette: #fff8dc;
  --bg-time-label: #ff9800;
  --text-calendar: #333;
  --text-stat: #333;
}

/* 植物テーマ */
body[data-theme="plant"] {
  --bg-main: #e8f5e9;
  --bg-container: #f1f8f4;
  --bg-scroll: #f1f8f4;
  --bg-palette: #c8e6c9;
  --bg-time-label: #4caf50;
  --text-calendar: #1b5e20;
  --text-stat: #1b5e20;
}

/* 夜テーマ */
body[data-theme="deceased"] {
  --bg-main: #1a1a1a;
  --bg-container: #2a2a2a;
  --bg-scroll: #2a2a2a;
  --bg-palette: #1a1a1a;
  --bg-time-label: #666666;
  --text-calendar: #999;
  --text-stat: #999;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-user-select: none; /* Safari, iOS Safari対応 */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* Edge(旧) */
  user-select: none; /* 標準仕様 */
  touch-action: manipulation;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans",
    sans-serif;
  background: var(--bg-main);
  min-height: 100vh;
  padding: 20px;
  overflow: hidden; /* 全体はスクロール不可 */
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  background: var(--bg-container);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  position: relative;
  height: calc(100vh - 40px); /* 画面いっぱいに調整 */
  display: flex;
  flex-direction: column;
}

.header {
  background: var(--bg-container);
  color: var(--text-calendar);
  padding: 10px;
  text-align: center;
  flex-shrink: 0;
  /* 以下追加分 */
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  top: 15px;
  left: 20px;
  right: 20px;
  z-index: 1000;
  border-top-left-radius: 15px;
  border-top-right-radius: 15px;
}

.header h1 {
  font-size: 25px;
}
.version {
  font-size: 10px;
}
.login-screen {
  margin-top: 50px;
  padding: 10px 30px;
  text-align: center;
  color: var(--text-calendar);
  background: var(--bg-container);
}

.login-screen input {
  width: 100%;
  max-width: 400px;
  padding: 15px 20px;
  font-size: 16px;
  border: 2px solid #667eea;
  border-radius: 10px;
  margin: 10px 0;
  text-align: center;
}

.login-screen button {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 15px 40px;
  font-size: 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.2s;
}

.login-screen button:hover {
  transform: translateY(-2px);
}
#loginError {
  color: red;
  margin-top: 10px;
}
.terms {
  margin: 0 auto;
  text-align: left;
  height: 33vh;
  overscroll-behavior: contain;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}
.main-content {
  display: none;
  flex: 1;
  position: relative;
}

.user-info {
  background: #f8f9fa;
  padding: 15px 20px;
  border-radius: 10px;
  display: none;
  /*よくよく考えれば不要*/
  justify-content: space-between;
  align-items: center;
  position: relative;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.logout-btn {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 20px;
  border-radius: 5px;
  cursor: pointer;
}

/* bandPaletteを完全固定 */
.band-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 20px;
  background: var(--bg-palette);
  position: fixed;
  top: 70px;
  left: 20px;
  right: 20px;
  width: auto;
  max-width: 1400px;
  margin: 0;
  z-index: 999;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* 下のスクロール領域 */
.scroll-area {
  background: var(--bg-scroll);
  position: absolute;
  top: 140px;
  left: 0;
  right: 0;
  bottom: 0;
  overflow-y: auto;
  padding-top: 160px;
  padding-left: 10px;
  padding-right: 10px;
  box-sizing: border-box;
  -ms-overflow-style: none;
  scrollbar-width: none;
  display: flex;
}
#calendarsContainer {
  color: var(--text-calendar);
}
.calendar {
  margin-bottom: 40px;
}

.calendar h3 {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text-calendar);
}

.calendar-grid {
  display: grid;
  grid-template-columns: 100px repeat(7, 1fr);
  gap: 5px;
}

.time-label {
  background: var(--bg-time-label);
  color: white;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.day-header {
  background: var(--bg-time-label);
  color: white;
  padding: 10px;
  text-align: center;
  font-weight: bold;
  border-radius: 5px;
}

.slot {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  min-height: 80px;
  padding: 8px;
  font-size: 12px;
  transition: all 0.3s;
  background: #aaaaaa;
}

.slot.current-time {
  border: 3px solid #ffc107;
  box-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.slot.drag-over {
  background: #e3f2fd;
  border-color: #2196f3;
}

.slot.reserved {
  color: white;
  font-weight: bold;
}

.slot-info {
  font-size: 11px;
  margin-top: 5px;
  opacity: 0.9;
}

.stats {
  margin-top: 40px;
  padding: 20px;
  background: var(--bg-scroll);
  border-radius: 10px;
}

.stats h3 {
  margin-bottom: 15px;
  color: var(--text-stat);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px 20px; /* 行間と列間 */
}

.stat-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  color: #fff;
  font-family: "Segoe UI", sans-serif;
  min-width: 50px;
}

.band-name {
  flex: 1;
  text-align: left;
  padding-right: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.band-count {
  text-align: right;
  min-width: 3em;
}

.band-block {
  padding: 6px 10px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  cursor: move;
  user-select: none;
  touch-action: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
@media (max-width: 1024px) {
  .calendar-grid {
    font-size: 11px;
  }
  .band-block {
    padding: 10px 6px;
    font-size: 10px;
  }
  .stats {
    display: none;
  }
}

.loadingText {
  text-align: center;
}

.dragging-clone {
  position: fixed;
  pointer-events: none;
  display: block;
  z-index: 1000000;
  opacity: 0.8;
  padding: 10px 6px;
  border-radius: 8px;
  color: white;
  font-weight: bold;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  transition: none;
  font-size: 10px;
  white-space: nowrap;
  text-align: center;
}
#loadingOverlay {
  position: fixed;
  padding: 0;
  margin: 0;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  color: #333;
  z-index: 999999999999;
  backdrop-filter: blur(5px);
}
#knowledge {
  padding: 100px;
}
.loadingText {
  animation: pulse 1.5s infinite;
  font-weight: bold;
}

@keyframes pulse {
  0% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0.4;
  }
}
.material-symbols-outlined {
  -webkit-tap-highlight-color: transparent;
  outline: none;
  user-select: none;
}
.switchers {
  display: flex;
  align-items: center;
}
.theme-switcher {
  cursor: pointer;
  font-size: 28px;
  padding: 0 15px;
  user-select: none;
  transition: transform 0.2s;
}

.theme-switcher:hover {
  transform: scale(1.1);
}

/* デバイス切り替えアイコン用スタイルを追加 */
.device-switcher {
  cursor: pointer;
  font-size: 28px;
  padding: 0 15px;
  user-select: none;
  transition: transform 0.2s;
  display: none; /* デフォルトは非表示 */
}

.device-switcher:hover {
  transform: scale(1.1);
}

/* iPad縦(768px)未満でデバイス切り替えを表示 */
@media (max-width: 767px) {
  .device-switcher {
    display: block;
  }
  body[data-display-mode="mobile"] .slot {
    min-height: 50px;
  }
}

/* モバイルモード時のスロット表示 */
body[data-display-mode="mobile"] .slot.reserved {
  font-size: 10px;
}

body[data-display-mode="mobile"] .slot-info {
  display: none; /* ユーザー名と日付を非表示 */
}

/* 768px以上の場合は強制的にPC表示 */
@media (min-width: 768px) {
  body[data-display-mode="mobile"] .slot.reserved {
    font-size: 12px;
  }
  body[data-display-mode="mobile"] .slot-info {
    display: block;
  }
}
@media (max-width: 767px) {
  .mobilenone {
    display: none;
  }
}
