:root {
  --form: #008080;
  --form-light: #00c0c0;
  --log-bg: #ffff80;
  --score-bg: #ffffff;
  --score-fg: #cc0000;
  --rank-bg: #800000;
  --rank-fg: #ffff00;
  --btn-radius: 6px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft JhengHei", "PingFang TC", "Segoe UI", sans-serif;
  background: var(--form);
  color: #000;
  min-height: 100vh;
}

.app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 24px;
}

.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.title-banner {
  flex: 1;
  background: var(--form-light);
  padding: 10px 14px;
  font-size: 1.25rem;
  font-weight: bold;
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 10px;
}

.guess-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 280px;
}

.guess-row.hidden {
  display: none;
}

.badge {
  background: var(--form-light);
  padding: 6px 12px;
  font-size: 1.2rem;
  font-weight: bold;
  min-width: 3rem;
  text-align: center;
}

.mask {
  background: #fff;
  color: var(--score-fg);
  padding: 6px 14px;
  font-size: 1.2rem;
  font-weight: bold;
  font-family: Consolas, monospace;
  min-width: 5rem;
  text-align: center;
  user-select: none;
}

#guessInput {
  width: 6rem;
  font-size: 1.35rem;
  font-family: Consolas, monospace;
  text-align: center;
  padding: 6px;
}

.mid-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.timer-box {
  background: #fff;
  color: var(--score-fg);
  font-size: 1.2rem;
  font-weight: bold;
  padding: 8px 16px;
  min-width: 5.5rem;
  text-align: center;
  display: none;
}

.timer-box.visible {
  display: block;
}

.panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  min-height: 380px;
}

@media (max-width: 800px) {
  .panels {
    grid-template-columns: 1fr;
  }
}

.panel {
  border: 2px ridge #ccc;
  min-height: 320px;
  display: flex;
  flex-direction: column;
}

.panel-log {
  background: var(--log-bg);
}

.panel-right {
  position: relative;
  min-height: 320px;
  border: 2px ridge #ccc;
}

.panel-right > .panel {
  border: none;
  min-height: 100%;
}

.panel-score {
  background: var(--score-bg);
  height: 100%;
}

.panel-rank {
  position: absolute;
  inset: 0;
  background: var(--rank-bg);
  color: var(--rank-fg);
  display: none;
}

.panel-rank.visible {
  display: flex;
}

.panel pre {
  flex: 1;
  margin: 0;
  padding: 10px;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.panel-score pre {
  color: var(--score-fg);
}

.lang-bar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  color: #e0ffff;
}

.lang-bar button {
  background: transparent;
  border: 1px solid #b0e0e0;
  color: #fff;
  padding: 4px 10px;
  cursor: pointer;
  border-radius: 4px;
}

/* 立體漸層按鈕 */
.btn {
  border: none;
  border-radius: var(--btn-radius);
  padding: 8px 14px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  color: #111;
  position: relative;
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.85),
    inset -1px -1px 0 rgba(0, 0, 0, 0.2),
    1px 2px 3px rgba(0, 0, 0, 0.25);
  transition: transform 0.05s, box-shadow 0.05s;
}

.btn:active,
.btn.pressed {
  transform: translateY(1px);
  box-shadow:
    inset -1px -1px 0 rgba(255, 255, 255, 0.5),
    inset 1px 1px 0 rgba(0, 0, 0, 0.25);
}

.btn-default {
  background: linear-gradient(180deg, #f4f7fa 0%, #a8b4c4 100%);
}

.btn-primary {
  background: linear-gradient(180deg, #c8f5d0 0%, #3a9e52 100%);
  color: #0a3018;
}

.btn-accent {
  background: linear-gradient(180deg, #d4ebff 0%, #4a8cc8 100%);
  color: #0a2848;
}

.btn-warn {
  background: linear-gradient(180deg, #fff0c0 0%, #d4a828 100%);
  color: #4a3800;
}

.btn-danger {
  background: linear-gradient(180deg, #ffd0c8 0%, #c84840 100%);
  color: #4a1010;
}

.btn-start {
  font-size: 1.05rem;
  padding: 10px 18px;
}

.btn.hidden {
  display: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  background: #f0f0f0;
  border: 2px ridge #888;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow: auto;
  padding: 16px 20px;
  box-shadow: 4px 6px 20px rgba(0, 0, 0, 0.35);
}

.modal h2 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}

.modal pre {
  white-space: pre-wrap;
  font-family: inherit;
  margin: 0 0 16px;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal input {
  width: 100%;
  padding: 8px;
  font-size: 1rem;
  margin-bottom: 12px;
}
