/* ===================== Reset & Base ===================== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --ink: #241a2e;
  --ink-dim: #6a5f78;
  --surface: #ffffff;
  --accent: #ffc93c;
  --normal-color: #00cec9;
  --normal-dark: #00958f;
  --hard-color: #ff7675;
  --hard-dark: #c94a4a;
  --success: #2ecc71;
  --danger: #ff4d5e;
  --shadow: 0 12px 28px rgba(36, 26, 46, 0.25);
  --radius-lg: 24px;
  --radius-md: 16px;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: 'IBM Plex Sans Thai', 'Mitr', sans-serif;
  overscroll-behavior: none;
  background: linear-gradient(135deg, #ff7675, #fd79a8, #a29bfe, #00cec9);
  background-size: 400% 400%;
  animation: gradientShift 14s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

h1, h2, h3, .btn {
  font-family: 'Mitr', 'IBM Plex Sans Thai', sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
}

.page {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 24px 16px 44px;
  position: relative;
}

/* ===================== Screens ===================== */
.screen {
  display: none;
  animation: fadeSlideIn 0.35s ease;
}
.screen.active {
  display: block;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===================== Shared elements ===================== */
.back-home {
  display: inline-block;
  margin-bottom: 12px;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.back-home:active {
  opacity: 0.7;
}

.card {
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: 100px;
  padding: 17px 18px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  transition: transform 0.12s ease, filter 0.12s ease;
}
.btn:active {
  transform: scale(0.96);
  filter: brightness(0.94);
}
.btn-big {
  padding: 19px;
  font-size: 1.2rem;
}
.btn-primary {
  background: linear-gradient(135deg, #ff7675, #fd79a8);
  box-shadow: 0 10px 22px rgba(255, 118, 117, 0.35);
}
.btn-secondary {
  background: linear-gradient(135deg, #a29bfe, #6c5ce7);
  box-shadow: 0 10px 22px rgba(108, 92, 231, 0.35);
}

.section-label {
  font-weight: 700;
  margin: 0 0 12px;
  color: var(--ink);
}

.screen-heading {
  text-align: center;
  color: #fff;
  font-size: 1.4rem;
  margin: 0 0 16px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.category-badge {
  display: block;
  text-align: center;
  margin: -8px 0 16px;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  text-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.category-badge span {
  background: rgba(255,255,255,0.25);
  padding: 4px 12px;
  border-radius: 100px;
}

/* ===================== Start screen ===================== */
.start-wrap {
  text-align: center;
  padding-top: 6px;
}
.badge-emoji {
  font-size: 3rem;
  margin-bottom: 6px;
  animation: floatY 2.4s ease-in-out infinite;
}
@keyframes floatY {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}
.game-title {
  font-size: 2.1rem;
  line-height: 1.2;
  margin: 6px 0 10px;
  color: #fff;
  text-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
.game-subtitle {
  color: rgba(255,255,255,0.95);
  font-size: 0.95rem;
  margin-bottom: 24px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.start-card {
  text-align: left;
}
.count-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.count-btn {
  padding: 13px 0;
  border-radius: 12px;
  border: 2px solid #ffe0ec;
  background: #fff5f8;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}
.count-btn.selected {
  background: linear-gradient(135deg, #ff7675, #fd79a8);
  color: #fff;
  border-color: transparent;
}
.count-hint {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.82rem;
  margin: 14px 0 0;
}

.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 14px;
  border: 2px solid #e5e0f5;
  background: #f9f8ff;
  text-align: left;
}
.mode-btn.mode-normal {
  border-color: #b6f3f0;
}
.mode-btn.mode-hard {
  border-color: #ffd3d2;
}
.mode-btn.selected.mode-normal {
  border-color: var(--normal-color);
  background: #e6fffe;
}
.mode-btn.selected.mode-hard {
  border-color: var(--hard-color);
  background: #fff0ef;
}
.mode-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}
.mode-desc {
  font-size: 0.8rem;
  color: var(--ink-dim);
}

.rule-card {
  text-align: left;
}
.rule-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink-dim);
}
.discuss-rules {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
  font-size: 0.92rem;
  color: var(--ink-dim);
}

/* ===================== Reveal / Pass-device pattern ===================== */
.progress-text {
  text-align: center;
  color: rgba(255,255,255,0.9);
  font-weight: 600;
  margin-bottom: 14px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.15);
}
.reveal-hidden-card {
  text-align: center;
  padding: 40px 20px;
}
.pass-icon {
  font-size: 3rem;
  animation: shake 1.6s ease-in-out infinite;
}
@keyframes shake {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-6deg); }
  75% { transform: rotate(6deg); }
}
.pass-text {
  font-size: 1.2rem;
  margin: 16px 0 4px;
}
.pass-hint {
  color: var(--ink-dim);
  font-size: 0.85rem;
  margin-bottom: 22px;
}

.word-card {
  text-align: center;
  animation: popCard 0.4s ease;
}
@keyframes popCard {
  0% { opacity: 0; transform: scale(0.7) rotate(-4deg); }
  70% { transform: scale(1.05) rotate(1deg); }
  100% { opacity: 1; transform: scale(1) rotate(0); }
}
.intro-label {
  margin: 0 0 8px;
  font-weight: 700;
  color: var(--ink-dim);
  font-size: 0.9rem;
}
.word-text {
  margin: 0 0 20px;
  font-size: 2rem;
  font-weight: 700;
}

/* ===================== Discuss / timer ===================== */
.discuss-wrap {
  padding-top: 4px;
}
.timer-wrap {
  display: flex;
  justify-content: center;
  margin: 20px 0;
}
.timer-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  border: 6px solid var(--accent);
  transition: border-color 0.3s ease;
}
.timer-circle.warn {
  border-color: var(--danger);
  animation: pulseWarn 0.7s ease infinite;
}
@keyframes pulseWarn {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.timer-number {
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--ink);
}

/* ===================== Match pick screen ===================== */
.match-wrap {
  padding-top: 4px;
}
.select-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 14px;
}
.select-btn {
  padding: 20px 6px;
  border-radius: 16px;
  border: 2px solid #ffe0ec;
  background: #fff5f8;
  color: var(--ink);
  font-size: 1.1rem;
  font-weight: 700;
}
.select-btn:active {
  background: #ffe0ec;
}

/* ===================== Result screen ===================== */
.result-wrap {
  padding-top: 4px;
}
.impostor-banner {
  text-align: center;
  background: linear-gradient(160deg, #2b1a45, #4a2e70);
  color: #fff;
  animation: popCard 0.5s ease;
}
.impostor-text {
  margin: 0 0 4px;
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 700;
}
.impostor-name {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}

.pairs-list, .guesses-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}
.pair-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #fff5f8;
  font-weight: 700;
  font-size: 1rem;
  text-align: center;
  flex-wrap: wrap;
}
.guess-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 12px;
  background: #f9f8ff;
  font-weight: 600;
  font-size: 0.92rem;
}
.guess-row.correct {
  background: #e4fbe9;
}
.guess-row.wrong {
  background: #ffecec;
}

/* ===================== Small screens ===================== */
@media (max-width: 340px) {
  .game-title { font-size: 1.7rem; }
  .word-text { font-size: 1.6rem; }
}
