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

:root {
  --ink: #241a45;
  --ink-dim: #6a5f8f;
  --surface: #ffffff;
  --accent: #ffc93c;
  --danger: #ff4d5e;
  --success: #2ecc71;
  --shadow: 0 12px 28px rgba(36, 26, 69, 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, #ff9f43, #7c5cff, #2ed9c3, #ffc93c);
  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, #ff8a3d, var(--accent));
  color: #2b1a00;
  box-shadow: 0 10px 22px rgba(255, 201, 60, 0.4);
}
.btn-action {
  margin-bottom: 12px;
}
.btn-correct {
  background: linear-gradient(135deg, var(--success), #1a8f4e);
}
.btn-fail {
  background: linear-gradient(135deg, var(--danger), #c23a30);
}

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

/* ===================== 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.92);
  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(4, 1fr);
  gap: 8px;
}
.count-btn {
  padding: 13px 0;
  border-radius: 12px;
  border: 2px solid #eee0ff;
  background: #f7f4ff;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
}
.count-btn.selected {
  background: linear-gradient(135deg, #ff8a3d, var(--accent));
  color: #2b1a00;
  border-color: transparent;
}
.count-hint {
  text-align: center;
  color: var(--ink-dim);
  font-size: 0.85rem;
  margin: 14px 0 0;
}

.duration-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.duration-btn {
  padding: 14px 0;
  border-radius: 12px;
  border: 2px solid #eee0ff;
  background: #f7f4ff;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 700;
}
.duration-btn.selected {
  background: linear-gradient(135deg, #7c5cff, #4834d4);
  color: #fff;
  border-color: transparent;
}

.rule-card {
  text-align: left;
}
.rule-text {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--ink-dim);
}

/* ===================== Word card (shared) ===================== */
.word-card {
  text-align: center;
}
.word-category {
  margin: 0 0 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.word-text {
  margin: 0 0 16px;
  font-size: 2.2rem;
  font-weight: 700;
}
.taboo-heading {
  margin: 0 0 10px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink-dim);
}
.taboo-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}
.taboo-badge {
  background: linear-gradient(135deg, var(--danger), #c23a30);
  color: #fff;
  padding: 8px 14px;
  border-radius: 100px;
  font-weight: 700;
  font-size: 0.95rem;
}

/* ===================== Round intro screen ===================== */
.intro-wrap {
  padding-top: 4px;
  text-align: center;
}
.explainer-card {
  animation: popCard 0.45s 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 6px;
  font-weight: 700;
  color: var(--ink-dim);
  font-size: 0.9rem;
}
.intro-big-text {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
}
.preview-countdown-text {
  color: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  text-shadow: 0 2px 8px rgba(0,0,0,0.25);
  margin: 6px 0 20px;
}
#preview-countdown-number {
  font-size: 1.5rem;
}

/* ===================== Playing screen ===================== */
.playing-wrap {
  padding-top: 4px;
  text-align: center;
}
.timer-wrap {
  display: flex;
  justify-content: center;
  margin: 4px 0 20px;
}
.timer-circle {
  width: 130px;
  height: 130px;
  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.6rem;
  font-weight: 700;
  color: var(--ink);
}
.playing-actions {
  margin-top: 20px;
}

/* ===================== Result screen ===================== */
.result-wrap {
  padding-top: 30px;
  text-align: center;
}
.result-card {
  animation: popCard 0.5s ease;
}
.result-emoji {
  font-size: 3rem;
  margin: 0 0 6px;
}
.result-text {
  margin: 0 0 10px;
  font-size: 1.9rem;
  font-weight: 700;
}
.result-word-text {
  margin: 0;
  font-size: 1.1rem;
  color: var(--ink-dim);
  font-weight: 600;
}

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