html {
  font-size: 18px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: "標楷體", "DFKai-SB", "BiauKai", "Noto Serif TC", "Microsoft JhengHei", serif;
  font-synthesis: none; /* 標楷體/DFKai-SB 沒有真正的粗體字重，避免瀏覽器用假粗體造成字形變形 */
  font-size: 1.05rem;
  margin: 0;
  padding: 0 1rem 2rem;
  background: #1a1410 url('/assets/theme/wood-bg.jpg') no-repeat center center;
  background-size: cover;
  background-attachment: fixed;
  color: #f0e6d2;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

header {
  text-align: center;
  padding: 1rem 0;
}

h1 {
  font-size: clamp(1.8rem, 7.5vw, 2.6rem);
  font-weight: 700;
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  overflow-wrap: break-word;
  word-break: break-word;
}

header nav {
  margin-top: 0.4rem;
}

header nav a {
  color: #d8c9a3;
  font-size: 1.5rem;
}

.intro {
  max-width: 640px;
  margin: 0 auto 1.5rem;
  background: #e9dcbd url('/assets/theme/parchment-bg.jpg') center/cover;
  border: 2px solid #33476b;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  color: #3a2a1a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.intro summary {
  cursor: pointer;
  font-weight: bold;
}

.intro p {
  line-height: 1.7;
  font-size: 1.1rem;
}

.intro a {
  color: #2f4468;
  font-weight: bold;
}

main {
  max-width: 640px;
  margin: 0 auto;
}

.notice {
  background: #cfa856;
  border: 2px solid #33476b;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: #3a2a1a;
  font-weight: bold;
  font-size: 1.1rem;
}

.room-card {
  background: #e9dcbd url('/assets/theme/parchment-bg.jpg') center/cover;
  background-image: url('/assets/theme/seal-stamp.png'), url('/assets/theme/parchment-bg.jpg');
  background-position: top 0.6rem right 0.6rem, center;
  background-repeat: no-repeat, no-repeat;
  background-size: 36px 36px, cover;
  border: 2px solid #33476b;
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  color: #3a2a1a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.room-card h2 {
  margin-top: 0;
}

.seat-grid,
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.seat,
.swatch {
  border: 1px solid #33476b;
  border-radius: 10px;
  padding: 0.3rem;
  height: 4.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1410;
  background: #efe2c4;
  font-size: 1rem;
  line-height: 1.2;
  white-space: pre-line;
  text-align: center;
}

.seat:not(.taken) {
  background: #efe2c4;
  color: #3a2a1a;
  cursor: pointer;
}

.seat.taken,
.swatch {
  font-weight: bold;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
}

.seat.disconnected {
  opacity: 0.5;
}

.swatch:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.swatch.selected {
  outline: 3px solid #2f4468;
}

.mini-badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
  margin: 0.3rem 0;
}

.mini-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 1px solid #33476b;
  border-radius: 6px;
  font-weight: bold;
  font-size: 0.9rem;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.4);
}

.confirm-section {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.confirm-section .notice {
  flex-basis: 100%;
}

.confirm-section input,
.confirm-section button {
  padding: 0.6rem;
  font-size: 1.1rem;
}

.back-btn {
  margin-top: 1rem;
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  border: 1px solid #33476b;
  background: #241d16;
  color: #f0e6d2;
  font-size: 1.25rem;
}

.seat-number-input {
  width: 4.5rem;
}

.pin-code-input {
  width: 6rem;
}

.action-panel {
  background: #e9dcbd url('/assets/theme/parchment-bg.jpg') center/cover;
  border: 2px solid #33476b;
  border-radius: 10px;
  padding: 1rem;
  margin: 1rem 0;
  color: #3a2a1a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.action-panel .back-btn {
  margin: 0.3rem 0.3rem 0 0;
}

.ability-buttons-spaced {
  margin-top: 2rem;
}

.head-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
  margin: 0.6rem 0;
}

.head-btn {
  border: 1px solid #33476b;
  border-radius: 10px;
  padding: 0.8rem 0.3rem;
  background: #241d16;
  color: #f0e6d2;
  font-size: 1.25rem;
}

.head-btn.selected,
.seat.selected,
.back-btn.selected {
  outline: 3px solid #2f4468;
}

.history-section {
  margin-top: 1.5rem;
  border-top: 1px dashed #7a6238;
  padding-top: 0.6rem;
}

.history-section ul {
  padding-left: 1.2rem;
}

.seat-settings {
  border: 1px dashed #7a6238;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-top: 1rem;
}

.host-controls {
  border: 1px dashed #7a6238;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.host-controls select {
  padding: 0.5rem;
  font-size: 1.1rem;
}

.home-menu {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 1.5rem 0;
}

.home-menu-btn {
  display: block;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  padding: 1.7rem 1.2rem;
  font-size: 1.65rem;
  font-weight: bold;
  color: #fbf7ee;
  text-align: center;
  cursor: pointer;
  transition: filter 0.1s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.75), 0 0 12px rgba(0, 0, 0, 0.5);
}

.home-menu-btn:active {
  filter: brightness(0.9);
}

.home-menu-btn-label {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

/* 釉裡紅：銅紅釉瓷器花紋 */
.home-menu-btn-create {
  background: linear-gradient(rgba(50, 15, 8, 0.4), rgba(50, 15, 8, 0.5)), url('/assets/theme/btn-create.jpg') center/cover;
}

/* 青花瓷：白瓷底、鈷藍花紋 */
.home-menu-btn-join {
  background: linear-gradient(rgba(8, 20, 32, 0.4), rgba(8, 20, 32, 0.5)), url('/assets/theme/btn-join.jpg') center/cover;
}

/* 翠玉：淡雅翡翠玉紋理 */
.home-menu-btn-reconnect {
  background: linear-gradient(rgba(10, 28, 16, 0.35), rgba(10, 28, 16, 0.45)), url('/assets/theme/btn-reconnect.jpg') center/cover;
}

.home-menu-btn-expanded {
  cursor: default;
  text-align: left;
}

.home-menu-expand-title {
  margin: 0 0 0.8rem;
  font-size: 1.25rem;
}

.home-menu-expand-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
}

.home-menu-expand-row input {
  padding: 0.6rem;
  font-size: 1.1rem;
  border-radius: 8px;
  border: 1px solid rgba(240, 230, 210, 0.4);
  background: rgba(0, 0, 0, 0.25);
  color: #fbf7ee;
}

.home-menu-confirm-btn {
  padding: 0.6rem 1.1rem;
  font-size: 1.1rem;
  font-weight: bold;
  border-radius: 8px;
  border: 1px solid rgba(240, 230, 210, 0.4);
  background: rgba(0, 0, 0, 0.3);
  color: #fbf7ee;
  cursor: pointer;
}

.home-menu-collapse-btn {
  display: block;
  margin: 0.8rem 0 0;
  padding: 0;
  background: none;
  border: none;
  color: #fbf7ee;
  opacity: 0.85;
  font-size: 0.95rem;
  text-decoration: underline;
  cursor: pointer;
}

.action-btn-large {
  font-size: 1.25rem;
  padding: 0.9rem 1.2rem;
}

.start-game-btn {
  display: block;
  width: 100%;
  padding: 1.2rem;
  margin-top: 1rem;
  font-size: 1.4rem;
  font-weight: bold;
}

.seat-grid-spaced {
  margin-top: 3rem;
}

.danger-btn {
  background: #5c2e2e;
  border-color: #8a4a4a;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal-panel {
  position: relative;
  background: #e9dcbd url('/assets/theme/parchment-bg.jpg') center/cover;
  border: 2px solid #33476b;
  border-radius: 12px;
  padding: 1.2rem;
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  color: #3a2a1a;
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: none;
  border: none;
  color: #3a2a1a;
  font-size: 1.3rem;
  line-height: 1;
  padding: 0.3rem 0.6rem;
}

.vote-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.vote-row input {
  width: 5rem;
  padding: 0.4rem;
  font-size: 1.1rem;
}

.result-text {
  font-size: 1.5rem;
  font-weight: bold;
  text-align: center;
  padding: 1rem 0;
}

.notes-area {
  width: 100%;
  min-height: 120px;
  padding: 0.6rem;
  font-family: inherit;
  font-size: 1.05rem;
  background: #f3e9d2;
  color: #3a2a1a;
  border: 1px solid #33476b;
  border-radius: 8px;
  resize: vertical;
}

.role-card {
  background: #e9dcbd url('/assets/theme/parchment-bg.jpg') center/cover;
  border: 2px solid #33476b;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
  color: #3a2a1a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.role-name {
  font-size: 1.3rem;
  font-weight: bold;
}

.role-portrait {
  display: block;
  width: 140px;
  height: auto;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  margin: 0 auto 1rem;
  border-radius: 10px;
  border: 2px solid #33476b;
}

.countdown {
  font-weight: bold;
  text-align: center;
  font-size: 1.1rem;
}

.changelog-page {
  max-width: 640px;
}

.changelog-entry {
  background: #e9dcbd url('/assets/theme/parchment-bg.jpg') center/cover;
  border: 2px solid #33476b;
  border-radius: 10px;
  padding: 0.8rem 1rem;
  margin-bottom: 1rem;
  color: #3a2a1a;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.changelog-entry-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.changelog-date {
  color: #6b532f;
  font-size: 0.95rem;
  margin-left: auto;
}

.badge {
  font-size: 1.05rem;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-weight: bold;
}

.badge-release {
  background: #2e5c3d;
  color: #d9f5df;
}

.badge-announcement {
  background: #6b4a1f;
  color: #fbe6c2;
}

.changelog-entry ul {
  margin: 0.3rem 0 0;
  padding-left: 1.2rem;
}

.changelog-entry li {
  margin-bottom: 0.2rem;
  line-height: 1.6;
  font-size: 1.1rem;
}

.changelog-entry li.changelog-section-header {
  list-style: none;
  margin-left: -1.2rem;
  margin-top: 0.8rem;
  font-weight: bold;
  color: #5a4020;
}

.changelog-entry li.changelog-section-header:first-child {
  margin-top: 0;
}

@media (min-width: 600px) {
  h1 {
    font-size: clamp(2.6rem, 5vw, 3.3rem);
  }

  .seat-grid,
  .swatch-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
