:root {
  --bg: #0f1222;
  --card: #1a1f3d;
  --text: #f5f7ff;
  --ok: #5fd18d;
  --warn: #f7b955;
  --panel-border: #3f4b89;
  --control-h: 90px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  touch-action: pan-y;
  -ms-touch-action: pan-y;
}

body {
  touch-action: pan-y;
  -ms-touch-action: pan-y;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    "Noto Sans TC",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, #1f2854, var(--bg));
  color: var(--text);
}

.app {
  width: min(96vw, 460px);
  margin: 12px auto 0;
  padding-bottom: calc(var(--control-h) + 12px);
}

.top-info {
  background: var(--card);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 8px 10px;
  margin-bottom: 10px;
}

.meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.meta-actions {
  display: flex;
  gap: 4px;
}

.meta-actions button,
.meta-actions .btn-link {
  padding: 4px 7px;
  font-size: 0.75rem;
  border-radius: 7px;
}

#autoBtn {
  display: none;
  min-width: 40px;
  touch-action: manipulation;
}

#autoBtn.active {
  background: #b65a20;
  border-color: #e47c3a;
}


.score-chip {
  font-size: 0.95rem;
  color: #ffda44;
}

.score-chip b {
  color: #5fd18d;
}

.progress-chip {
  font-size: 0.85rem;
  color: #a5b4fc;
}

.progress-chip b {
  color: #7ea6ff;
  font-size: 1.1rem;
}

button {
  border: 1px solid #5e70bf;
  background: #2a3572;
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.btn-link {
  display: inline-flex;
  align-items: center;
  border: 1px solid #5e70bf;
  background: #2a3572;
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.9rem;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.message {
  margin: 1px 0 0;
  min-height: 1em;
  font-size: 0.75rem;
  color: var(--warn);
  line-height: 1.2;
}

.message:empty {
  display: none;
}

.message.ok {
  color: var(--ok);
}

.debug-box {
  display: none;
  margin: 4px 0 0;
  padding: 6px 8px;
  border: 1px solid rgba(126, 166, 255, 0.25);
  border-radius: 8px;
  background: rgba(15, 18, 34, 0.7);
  color: #d6e2ff;
  font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.58rem;
  line-height: 1.2;
  white-space: pre;
  max-height: 240px;
  overflow: auto;
}

.debug-box.show {
  display: block;
}

.board-wrap {
  display: flex;
  justify-content: center;
}

#board {
  width: 100%;
  max-width: 100%;
  border: 2px solid #5261a6;
  border-radius: 12px;
  background: #0a0d1d;
  box-shadow: 0 12px 30px rgb(0 0 0 / 40%);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-controls {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

.mobile-controls {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--control-h);
  background: rgb(17 21 45 / 95%);
  border-top: 1px solid var(--panel-border);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 14px;
}

.mobile-controls button {
  font-size: 1.2rem;
  font-weight: 700;
  border-radius: 12px;
}

.settings-page {
  width: min(96vw, 560px);
  margin: 14px auto;
  padding-bottom: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px;
}

.version-tag {
  font-size: 0.55em;
  font-weight: 400;
  color: #7ea6ff;
  background: rgba(126, 166, 255, 0.12);
  border: 1px solid rgba(126, 166, 255, 0.25);
  border-radius: 6px;
  padding: 2px 7px;
  vertical-align: middle;
  letter-spacing: 0.5px;
}

.row-list {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid #5261a6;
  border-radius: 10px;
  background: #111735;
}

.row-item code {
  color: #dbe2ff;
  font-size: 0.9rem;
}

.pick-section {
  margin: 14px 0 4px;
  padding: 10px 12px;
  border: 1px solid #5261a6;
  border-radius: 10px;
  background: #111735;
}

.pick-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #dbe2ff;
  flex-wrap: wrap;
}

.pick-label input {
  width: 60px;
  border: 1px solid #5261a6;
  background: #1a1f3d;
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  text-align: center;
  font-size: 0.95rem;
}

.danger {
  border-color: #b65a76;
  background: #7a2d46;
}

.input-group {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.input-group input {
  border: 1px solid #5261a6;
  background: #111735;
  color: #fff;
  border-radius: 10px;
  padding: 10px;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* 群組按鈕 */
.group-btn {
  padding: 10px 16px;
  font-size: 0.9rem;
  border: 2px solid #5261a6;
  border-radius: 10px;
  background: #1a1f3d;
  color: #dbe2ff;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.group-btn.active {
  border-color: #7ea6ff;
  box-shadow: 0 0 8px 2px rgba(126, 166, 255, 0.55), inset 0 0 6px rgba(126, 166, 255, 0.15);
  color: #fff;
  background: #2a3572;
}

/* 單字模式按鈕按壓效果 */
#singleWordModeBtn:active {
  transform: scale(0.96);
  filter: brightness(0.85);
}

/* 拆分模式按鈕 */
.split-mode-btn:active {
  transform: scale(0.96);
  filter: brightness(0.85);
}
.split-mode-btn.active {
  background: #ff9800 !important;
  color: #000 !important;
  border-color: #e6a800 !important;
  box-shadow: 0 0 8px 2px rgba(255, 152, 0, 0.45);
}

/* 自訂單字區域被停用 */
.custom-words-disabled {
  opacity: 0.35;
  pointer-events: none;
}

@media (min-width: 700px) {
  .app {
    margin-top: 18px;
  }

  .mobile-controls {
    max-width: 460px;
    margin: 0 auto;
    left: 50%;
    right: auto;
    width: 460px;
    transform: translateX(-50%);
    border-left: 1px solid var(--panel-border);
    border-right: 1px solid var(--panel-border);
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
  }
}

