/* 基礎重設 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #F5F5DC; /* 米白 */
  --accent: #FFA500; /* 橘色 */
  --text: #2b2b2b;
  --muted: #666666;
  --card: #ffffff;
  --chip: #222222;
  --chip-alt: #6b3b00;
  --shadow: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 16px;
}

html, body {
  height: 100%;
}

body {
  font-family: 'Noto Sans TC', system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

.container {
  width: min(1100px, 92%);
  margin: 0 auto;
}

.site-header {
  padding: 40px 0 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.brand-text { display: grid; gap: 2px; }

.site-title {
  font-size: 2rem;
  font-weight: 700;
}

.site-subtitle {
  color: var(--muted);
}

.site-main {
  padding-bottom: 64px;
}

.section-title {
  font-size: 1.25rem;
  margin-bottom: 16px;
}

/* 模式按鈕列 */
.mode-section {
  padding: 8px 0 24px;
}

.mode-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.mode-button {
  appearance: none;
  border: 2px solid transparent;
  background: #fff;
  color: var(--text);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform .06s ease, box-shadow .2s ease, border-color .2s ease;
  box-shadow: var(--shadow);
}

.mode-button:hover {
  transform: translateY(-1px);
}

.mode-button:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.mode-button.is-accent {
  background: var(--accent);
  color: #111;
}

/* 遊戲區域 */
.game-section[aria-hidden="true"] { display: none; }

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 8px;
}

.game-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.difficulty-group {
  border: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 1px, 1px);
  white-space: nowrap;
  border: 0;
}

input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.difficulty-pill {
  display: inline-block;
  background: #fff;
  border-radius: 999px;
  padding: 8px 14px;
  border: 2px solid transparent;
  box-shadow: var(--shadow);
  cursor: pointer;
  user-select: none;
  transition: border-color .2s ease, transform .06s ease;
}

input#diff-basic:checked + label[for="diff-basic"],
input#diff-advanced:checked + label[for="diff-advanced"] {
  border-color: var(--accent);
}

.primary-actions {
  display: flex;
  gap: 10px;
}

.draw-button, .reset-button, .history-toggle-button {
  appearance: none;
  border: 0;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .06s ease, filter .2s ease;
}

.draw-button { background: var(--accent); }
.reset-button { background: #fff; }
.history-toggle-button { background: #fff; }

.draw-button:hover, .reset-button:hover, .history-toggle-button:hover {
  transform: translateY(-1px);
}

/* 卡牌舞台 */
.card-stage {
  display: grid;
  place-items: center;
  margin: 28px 0 0;
  min-height: 320px;
}

.card {
  width: min(560px, 88vw);
  height: 320px;
  perspective: 1200px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .8s cubic-bezier(.2,.7,.2,1);
}

.card.is-flipped .card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card-front {
  background: #fff7e8;
}

.card-back {
  transform: rotateY(180deg);
}

.card-back-pattern {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  background: repeating-linear-gradient(45deg, rgba(255,165,0,.15) 0 10px, transparent 10px 20px);
}

.card-hint {
  position: relative;
  z-index: 1;
  color: var(--muted);
}

.card-meta {
  position: absolute;
  top: 16px;
  left: 16px;
  display: flex;
  gap: 8px;
}

.chip {
  background: #ffe0b2;
  color: var(--chip);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: .875rem;
}

.chip-alt {
  background: #ffd7a0;
  color: var(--chip-alt);
}

.card-question {
  font-size: 1.25rem;
  text-align: center;
}

/* 歷史側欄 */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 88vw);
  height: 100dvh;
  background: #fff;
  box-shadow: -16px 0 40px rgba(0,0,0,.12);
  transform: translateX(100%);
  transition: transform .35s ease;
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.history-panel[aria-hidden="false"] {
  transform: translateX(0);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee0c7;
}

.history-title { font-size: 1rem; }

.history-close-button {
  appearance: none;
  background: transparent;
  border: 0;
  font-size: 24px;
  cursor: pointer;
}

.history-list {
  list-style: decimal inside;
  padding: 16px 20px 28px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.history-list li {
  background: #fff7e8;
  border-radius: 12px;
  padding: 12px 14px;
  line-height: 1.5;
}

/* RWD */
@media (max-width: 720px) {
  .game-header { flex-direction: column; align-items: flex-start; }
  .game-controls { width: 100%; justify-content: space-between; }
  .card { height: 360px; }
}


