* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --accent: #ff8a3d;
  --accent-dark: #ef6c00;
  --ink: #4a3526;
}

html {
  height: 100%;
}

html, body {
  font-family: "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fff3e0 0%, #ffe0b2 45%, #ffccbc 100%);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* min-height fills the screen so content centers when it fits, but the body
     can grow taller and scroll when it doesn't (fixes top/bottom clipping on
     small mobile viewports). dvh accounts for mobile browser chrome. */
  min-height: 100vh;
  min-height: 100dvh;
  padding: 16px;
  padding-top: max(16px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

/* Center vertically when there's room; top-align (auto margins collapse to 0)
   and let the page scroll when the content is taller than the viewport. */
.screen {
  margin: auto 0;
}

/* Language toggle — top-right corner, matches the playful button style. */
#langToggle {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  right: max(10px, env(safe-area-inset-right));
  z-index: 60;
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 3px solid var(--accent);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 0 rgba(239, 108, 0, 0.25);
}

#langToggle button {
  font-family: inherit;
  font-size: clamp(11px, 2.6vw, 13px);
  font-weight: 800;
  padding: 5px 8px;
  border: none;
  border-radius: 11px;
  background: transparent;
  color: var(--accent-dark);
  cursor: pointer;
  white-space: nowrap;
}

#langToggle button.active { background: var(--accent); color: #fff; }
#langToggle button:active { transform: translateY(1px); }

/* Confetti overlay */
#fx {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
}

.screen {
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.hidden { display: none !important; }

/* ---- Menu ---- */
h1 {
  font-size: clamp(32px, 8vw, 52px);
  text-shadow: 2px 2px 0 #fff, 4px 4px 0 rgba(239, 108, 0, 0.25);
}

.subtitle {
  font-size: clamp(16px, 4vw, 22px);
  color: var(--accent-dark);
  font-weight: 600;
}

.card {
  width: 100%;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 6px 0 rgba(239, 108, 0, 0.15);
  text-align: center;
}

.card h2 {
  font-size: clamp(16px, 4.5vw, 20px);
  margin-bottom: 12px;
}

.emoji-picker {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.emoji-btn {
  font-size: clamp(28px, 7vw, 38px);
  width: 56px;
  height: 56px;
  border: 3px solid transparent;
  border-radius: 14px;
  background: #fff;
  cursor: pointer;
  transition: transform 0.08s;
}

.emoji-btn:active { transform: scale(0.92); }
.emoji-btn.selected {
  border-color: var(--accent);
  background: #fff3e0;
  transform: scale(1.05);
}

.segmented {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.segmented button {
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: 700;
  padding: 12px 18px;
  border: 3px solid var(--accent);
  border-radius: 14px;
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
}

.segmented button.selected {
  background: var(--accent);
  color: #fff;
}

.big-btn {
  font-size: clamp(22px, 6vw, 30px);
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #ffa94d, var(--accent-dark));
  border: none;
  border-radius: 18px;
  padding: 16px 40px;
  cursor: pointer;
  box-shadow: 0 6px 0 #c75b00;
}

.big-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #c75b00; }

/* ---- Game ---- */
.status {
  font-size: clamp(20px, 5.5vw, 28px);
  font-weight: 800;
  min-height: 38px;
  text-align: center;
}

#board {
  border-radius: 16px;
  box-shadow: 0 8px 0 rgba(180, 120, 60, 0.35), 0 12px 24px rgba(0, 0, 0, 0.15);
  touch-action: manipulation;
  cursor: pointer;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.ctrl-btn {
  font-size: clamp(15px, 4vw, 18px);
  font-weight: 700;
  padding: 12px 16px;
  border: none;
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(180, 120, 60, 0.3);
}

.ctrl-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(180, 120, 60, 0.3); }
