:root {
  color-scheme: light;
  --bg: #f3eee8;
  --panel: #fffdfb;
  --text: #2f2724;
  --muted: #7a6d67;
  --border: #ddd3cc;
  --accent: #8f2f24;
  --accent-soft: #f4e4df;
  --success: #377a4a;
  --warn-soft: #fff1df;
  --rail: #efe7e0;
  font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(circle at 70% 20%, rgba(143, 47, 36, 0.08), transparent 40%),
    linear-gradient(160deg, #faf6f1, var(--bg));
  color: var(--text);
}

button, a { font: inherit; }

.hidden { display: none !important; }

.reminder-banner {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  width: min(920px, calc(100% - 24px));
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid #e0b27a;
  background: var(--warn-soft);
  box-shadow: 0 10px 30px rgba(47, 39, 36, 0.12);
}

.reminder-banner p { margin: 4px 0 0; }
.reminder-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.stage {
  height: 100%;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 25% 75%;
}

.status-rail {
  background: color-mix(in srgb, var(--rail) 88%, white);
  border-right: 1px solid var(--border);
  padding: 18px 16px 24px;
  overflow: auto;
}

.brand {
  margin: 0 0 12px;
  color: var(--accent);
  font-weight: 800;
  font-size: 18px;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 14px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot.online { background: var(--success); }
.dot.offline { background: #b54d42; }

.status-rail h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--muted);
  font-weight: 700;
}

.status-rail h2 + .logs { margin-top: 0; }

.status-rail h2:not(:first-of-type) { margin-top: 20px; }

.status {
  min-height: 110px;
  padding: 14px;
  border-radius: 14px;
  background: var(--accent-soft);
  line-height: 1.65;
  font-size: 16px;
}

.launch-link {
  display: inline-block;
  margin: 12px 0 0;
  color: #fff;
  background: var(--accent);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 10px;
}

.logs {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 14px;
}

.logs li {
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.logs strong { color: var(--text); }

.keypad-stage {
  display: grid;
  place-items: center;
  padding: clamp(12px, 3vw, 36px);
  position: relative;
}

.keypad {
  width: min(92%, 820px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(10px, 1.6vw, 18px);
}

.key {
  border: 1px solid var(--border);
  border-radius: clamp(16px, 2vw, 28px);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  box-shadow: 0 8px 22px rgba(53, 43, 37, 0.08);
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
  touch-action: manipulation;
  user-select: none;
}

.key.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.key:not(.disabled):hover { border-color: var(--accent); }

.key:active,
.key.pressed {
  transform: scale(0.97);
  background: var(--accent-soft);
  border-color: var(--accent);
}

.key-number {
  color: var(--accent);
  font-weight: 800;
  font-size: clamp(14px, 1.8vw, 20px);
}

.key-icon {
  font-size: clamp(28px, 4.2vw, 48px);
  font-weight: 700;
  line-height: 1;
}

.key-label {
  font-size: clamp(16px, 2.2vw, 24px);
  font-weight: 800;
}

.hint {
  position: absolute;
  bottom: 14px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  border-radius: 11px;
  padding: 9px 12px;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(40, 28, 24, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.modal-card {
  width: min(100%, 420px);
  background: var(--panel);
  border-radius: 20px;
  padding: 22px;
  border: 1px solid var(--border);
}

.modal-card h2 {
  margin: 0 0 10px;
  color: var(--accent);
}

.modal-card p {
  margin: 0;
  line-height: 1.7;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

@media (max-width: 860px) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .status-rail {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    max-height: 32vh;
  }

  .keypad-stage {
    min-height: 68vh;
  }

  .keypad {
    width: min(96%, 520px);
  }
}
