/* ===== English Quest — Voxel Runner ===== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a0e2a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai",
               "Helvetica Neue", Arial, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
}

#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg,
    #2a1454 0%,
    #4a1f5c 20%,
    #8a2a5e 40%,
    #d65a3a 60%,
    #f0a35a 75%,
    #ffd28a 100%);
}

/* ====================================================== */
/* ====================== SCREENS ======================= */
/* ====================================================== */

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  background: radial-gradient(ellipse at center, rgba(20, 5, 40, 0.55) 0%, rgba(20, 5, 40, 0.9) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.screen-content {
  text-align: center;
  padding: 32px;
  max-width: 540px;
  width: 90%;
}

.title {
  font-size: clamp(48px, 11vw, 96px);
  font-weight: 900;
  letter-spacing: 4px;
  line-height: 0.95;
  background: linear-gradient(180deg, #ffd97a 0%, #ff8a3a 50%, #d92e6a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 20px rgba(255, 138, 58, 0.5));
  margin-bottom: 16px;
  animation: titlePulse 2.5s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.03); }
}

h2 {
  font-size: clamp(36px, 7vw, 56px);
  font-weight: 900;
  margin-bottom: 24px;
  background: linear-gradient(180deg, #fff 0%, #ffd97a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

.subtitle {
  font-size: clamp(15px, 3vw, 19px);
  color: #ffd9a8;
  margin-bottom: 36px;
  font-weight: 500;
  line-height: 1.4;
}

.result-line {
  font-size: clamp(18px, 3.5vw, 22px);
  color: #ffe2b8;
  margin: 8px 0;
  font-weight: 600;
}

.hint {
  font-size: clamp(12px, 2.5vw, 15px);
  color: rgba(255, 240, 220, 0.7);
  margin-top: 20px;
  line-height: 1.6;
}

.hint-mobile { display: none; }

@media (max-width: 720px), (hover: none) {
  .hint-mobile { display: block; }
  .hint:not(.hint-mobile) { display: none; }
}

.key {
  display: inline-block;
  padding: 3px 9px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 5px;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  font-size: 0.9em;
  box-shadow: 0 2px 0 rgba(0,0,0,0.3);
  min-width: 26px;
  text-align: center;
}

/* ====================================================== */
/* ====================== BUTTONS ====================== */
/* ====================================================== */

.btn-primary, .btn-secondary {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 12px auto;
  padding: 16px 32px;
  font-size: clamp(16px, 3.5vw, 20px);
  font-weight: 800;
  letter-spacing: 1px;
  color: #fff;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}

.btn-primary {
  background: linear-gradient(180deg, #ffb04a 0%, #ff7a2a 50%, #e64a8a 100%);
  box-shadow: 0 6px 0 #a82a55, 0 8px 20px rgba(0,0,0,0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 0 #a82a55, 0 12px 28px rgba(0,0,0,0.5);
}

.btn-primary:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #a82a55, 0 4px 12px rgba(0,0,0,0.4);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.12);
  border: 2px solid rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  backdrop-filter: blur(8px);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.btn-secondary:active { transform: translateY(1px); }

/* ====================================================== */
/* ====================== HUD ========================== */
/* ====================================================== */

#hud {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

#hud-top-left, #hud-top-right, #hud-bottom-left, #hud-bottom-right {
  position: absolute;
  display: flex;
  gap: 10px;
  flex-direction: column;
}

#hud-top-left    { top: 16px;    left: 16px;  }
#hud-top-right   { top: 16px;    right: 16px; align-items: flex-end; }
#hud-bottom-left { bottom: 16px; left: 16px;  }
#hud-bottom-right{ bottom: 16px; right: 16px; align-items: flex-end; }

.hud-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(20, 10, 40, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  font-size: clamp(13px, 2.5vw, 16px);
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  min-width: 130px;
}

.hud-icon {
  font-size: 1.2em;
  line-height: 1;
}

.hud-label {
  color: #ffd9a8;
  letter-spacing: 0.5px;
}

.hud-value {
  color: #fff;
  font-weight: 900;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-size: 1.1em;
}

.lives-card .hud-value { color: #ff6080; }

.hint-card {
  background: rgba(40, 20, 60, 0.65);
  border-color: rgba(255, 200, 100, 0.3);
}

#mode-card {
  background: linear-gradient(135deg, rgba(80, 40, 120, 0.6) 0%, rgba(40, 20, 60, 0.6) 100%);
  border-color: rgba(180, 130, 255, 0.4);
}

.hud-btn {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  background: rgba(20, 10, 40, 0.55);
  backdrop-filter: blur(12px);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  color: #fff;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  transition: all 0.15s;
}

.hud-btn:hover {
  background: rgba(40, 20, 60, 0.7);
  border-color: rgba(255, 255, 255, 0.35);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: translateY(1px) scale(0.96);
}

/* ====================================================== */
/* ====================== QUIZ ========================= */
/* ====================================================== */

#quiz-popup {
  background: rgba(10, 5, 25, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.quiz-box {
  background: linear-gradient(160deg, #2a1454 0%, #4a1f5c 100%);
  border: 2px solid rgba(255, 200, 100, 0.4);
  border-radius: 24px;
  padding: 40px 32px;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.15);
  animation: quizPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes quizPop {
  0%   { transform: scale(0.7); opacity: 0; }
  100% { transform: scale(1);   opacity: 1; }
}

.quiz-thai {
  font-size: clamp(48px, 12vw, 84px);
  font-weight: 900;
  color: #ffd97a;
  text-shadow: 0 4px 16px rgba(255, 200, 100, 0.5), 0 2px 4px rgba(0,0,0,0.5);
  margin-bottom: 8px;
  letter-spacing: 2px;
}

.quiz-label {
  font-size: clamp(14px, 3vw, 17px);
  color: #ffd9a8;
  margin-bottom: 28px;
  font-weight: 500;
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 480px) {
  .quiz-options { grid-template-columns: 1fr; }
}

.quiz-option {
  padding: 18px 16px;
  font-size: clamp(17px, 4vw, 22px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.05) 100%);
  border: 2px solid rgba(255, 200, 100, 0.35);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.15s;
  text-transform: lowercase;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
}

.quiz-option:hover {
  background: linear-gradient(180deg, rgba(255, 200, 100, 0.3) 0%, rgba(255, 138, 58, 0.2) 100%);
  border-color: #ffd97a;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 138, 58, 0.3);
}

.quiz-option:active { transform: translateY(1px); }

.quiz-option.correct {
  background: linear-gradient(180deg, #4ade80 0%, #16a34a 100%) !important;
  border-color: #bbf7d0 !important;
  color: #fff;
  animation: correctPulse 0.5s;
}

.quiz-option.wrong {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%) !important;
  border-color: #fecaca !important;
  color: #fff;
  animation: wrongShake 0.4s;
}

.quiz-option:disabled { cursor: not-allowed; opacity: 0.5; }

@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}

@keyframes wrongShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ====================================================== */
/* ====================== TOAST ======================== */
/* ====================================================== */

.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 16px 28px;
  border-radius: 12px;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 900;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  border: 2px solid rgba(255, 200, 100, 0.5);
  animation: toastIn 0.3s ease-out, toastOut 0.4s ease-in 1.0s forwards;
}

.toast.correct { color: #86efac; border-color: #4ade80; }
.toast.wrong   { color: #fca5a5; border-color: #ef4444; }
.toast.star    { color: #ffd97a; border-color: #fbbf24; }
.toast.hit     { color: #fca5a5; border-color: #ef4444; }

@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  to   { opacity: 0; transform: translate(-50%, -70%) scale(0.8); }
}

/* ====================================================== */
/* ====================== UTIL ========================= */
/* ====================================================== */

.hidden { display: none !important; }
