/* ===== CSS Custom Properties ===== */
:root {
  --bg:          #f5f0e6;
  --card:        #ffffff;
  --choice-fill: #fdf8ee;
  --primary:     #4d80d1;
  --accent:      #9a6bc7;
  --gauge-full:  #6bb884;
  --gauge-warn:  #cc7566;
  --gauge-bg:    #dbd9cc;
  --text:        #383843;
  --muted:       #858588;
  --glass:       rgba(255, 255, 255, 0.55);
  --glass-border:rgba(255, 255, 255, 0.35);
  --shadow:      rgba(56, 56, 67, 0.08);
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ===== Animated Background ===== */
.bg-orbs {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.bg-orbs .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
  animation: orbFloat 12s ease-in-out infinite alternate;
}

.bg-orbs .orb:nth-child(1) {
  width: 320px; height: 320px;
  background: var(--primary);
  top: -80px; left: -60px;
  animation-duration: 14s;
}

.bg-orbs .orb:nth-child(2) {
  width: 260px; height: 260px;
  background: var(--accent);
  bottom: -40px; right: -40px;
  animation-duration: 10s;
  animation-delay: -4s;
}

.bg-orbs .orb:nth-child(3) {
  width: 200px; height: 200px;
  background: var(--gauge-full);
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 16s;
  animation-delay: -8s;
}

@keyframes orbFloat {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(30px, -40px) scale(1.15); }
}

/* ===== Game Container ===== */
.game-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  height: 100dvh;
  max-height: 780px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

/* ===== Screens ===== */
.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  animation: fadeIn 0.4s ease;
}

.screen.active {
  display: flex;
}

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

/* ===== Glass Card ===== */
.glass-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: 0 8px 32px var(--shadow);
  padding: 32px 24px;
  width: 100%;
}

/* ===== Title Screen ===== */
.title-logo {
  font-size: 56px;
  font-weight: 900;
  letter-spacing: -2px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.title-sub {
  font-size: 15px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 28px;
  letter-spacing: 1px;
}

.title-rule {
  font-size: 14px;
  color: var(--muted);
  text-align: center;
  line-height: 1.7;
  margin-bottom: 32px;
}

.title-rule strong {
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 16px;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 16px 36px;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 6px 24px rgba(77, 128, 209, 0.3);
}

.btn-primary:active {
  box-shadow: 0 2px 12px rgba(77, 128, 209, 0.2);
}

.btn-appstore {
  background: #000;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.btn-appstore svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.btn-secondary {
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 16px;
  padding: 14px 28px;
}

/* ===== Play Screen ===== */
.play-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 12px;
}

.score-display {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

.score-display span {
  font-size: 22px;
  color: var(--text);
}

.combo-display {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  min-height: 20px;
  transition: transform 0.2s ease;
}

.combo-display.pop {
  animation: comboPop 0.3s ease;
}

@keyframes comboPop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); }
  100% { transform: scale(1); }
}

/* Gauge */
.gauge-wrapper {
  width: 100%;
  height: 12px;
  background: var(--gauge-bg);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 24px;
  position: relative;
}

.gauge-bar {
  height: 100%;
  border-radius: 6px;
  background: var(--gauge-full);
  transition: width 0.08s linear, background-color 0.4s ease;
  will-change: width;
}

/* Question Card */
.question-area {
  width: 100%;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
}

.question-card {
  background: var(--glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 20px;
  box-shadow: 0 8px 32px var(--shadow);
  position: relative;
}

.question-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.question-number {
  font-size: 80px;
  font-weight: 900;
  line-height: 1;
  color: var(--primary);
  transition: transform 0.2s ease;
}

.question-number.animate-in {
  animation: numberIn 0.25s ease;
}

@keyframes numberIn {
  from { transform: scale(0.5) rotate(-8deg); opacity: 0; }
  to   { transform: scale(1) rotate(0); opacity: 1; }
}

.question-hint {
  font-size: 14px;
  color: var(--muted);
  margin-top: 8px;
  font-weight: 700;
}

.question-hint span {
  color: var(--accent);
  font-size: 15px;
}

.next-label {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  opacity: 0.7;
}

.next-number {
  position: absolute;
  top: 24px;
  right: 16px;
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  opacity: 0.5;
}

/* Tiles */
.tiles-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  width: 100%;
  margin-bottom: 16px;
}

.tile {
  aspect-ratio: 1.4;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--choice-fill);
  border: 2px solid var(--glass-border);
  border-radius: 18px;
  font-size: 42px;
  font-weight: 900;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  position: relative;
  overflow: hidden;
}

.tile:active {
  transform: scale(0.93);
}

.tile.correct {
  background: rgba(107, 184, 132, 0.2);
  border-color: var(--gauge-full);
  animation: tileCorrect 0.35s ease;
}

.tile.wrong {
  background: rgba(204, 117, 102, 0.15);
  border-color: var(--gauge-warn);
  animation: tileWrong 0.35s ease;
}

@keyframes tileCorrect {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

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

.tile.appear {
  animation: tileAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes tileAppear {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* Feedback Overlay */
.feedback {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  pointer-events: none;
  animation: feedbackPop 0.5s ease forwards;
  z-index: 10;
}

@keyframes feedbackPop {
  0%   { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.3); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0; }
}

/* Combo Emoji Reaction */
.combo-emoji {
  position: fixed;
  font-size: 36px;
  pointer-events: none;
  z-index: 20;
  animation: emojiRise 1.2s ease forwards;
}

@keyframes emojiRise {
  0%   { transform: translateY(0) scale(0.5) rotate(0deg); opacity: 1; }
  100% { transform: translateY(-160px) scale(1.2) rotate(20deg); opacity: 0; }
}

/* ===== Result Screen ===== */
.result-score-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 4px;
}

.result-score {
  font-size: 72px;
  font-weight: 900;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 8px;
  animation: scoreReveal 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scoreReveal {
  from { transform: scale(0.3); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

.result-message {
  font-size: 24px;
  font-weight: 900;
  color: var(--accent);
  margin-bottom: 6px;
}

.result-combo {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 32px;
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  align-items: center;
}

/* Home Button */
.btn-home {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: transform 0.12s ease;
  padding: 0;
  flex-shrink: 0;
}

.btn-home:active {
  transform: scale(0.9);
}

/* ===== Responsive ===== */
@media (max-height: 640px) {
  .question-number { font-size: 56px; }
  .tile { font-size: 34px; }
  .question-card { padding: 14px; }
  .glass-card { padding: 24px 20px; }
}

@media (min-width: 500px) {
  .tile { aspect-ratio: 1.6; }
}
