:root {
  --bg1: #6c4cf1;
  --bg2: #ff7eb3;
  --card: #ffffff;
  --text: #2b2250;
  --good: #2ecc71;
  --bad: #ff5c5c;
  --gap: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: var(--bg1); }
html, body {
  margin: 0;
  min-height: 100%;
  font-family: "Chalkboard SE", "Comic Sans MS", "Marker Felt", system-ui, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  background-attachment: fixed;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  cursor: pointer;
  touch-action: manipulation;
}

.hidden { display: none !important; }

.screen {
  min-height: 100%;
  padding: calc(env(safe-area-inset-top) + 16px) calc(env(safe-area-inset-right) + 16px)
           calc(env(safe-area-inset-bottom) + 16px) calc(env(safe-area-inset-left) + 16px);
}

/* ---------- Home ---------- */
.hero { text-align: center; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.15); }
.hero h1 { font-size: clamp(32px, 8vw, 56px); margin: 10px 0 4px; }
.hero p { font-size: 20px; margin: 0 0 20px; }

.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--gap);
  max-width: 900px;
  margin: 0 auto;
}

.game-card {
  background: var(--card);
  border-radius: 24px;
  padding: 18px 10px;
  text-align: center;
  box-shadow: 0 6px 0 rgba(0,0,0,.15);
  transition: transform .1s;
}
.game-card:active { transform: translateY(4px) scale(.97); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.game-card .emoji { font-size: 56px; display: block; }
.game-card .name { font-size: 20px; font-weight: bold; margin-top: 6px; display: block; }
.game-card .desc { font-size: 14px; opacity: .7; display: block; margin-top: 2px; }

.footer { text-align: center; color: #fff; margin-top: 28px; opacity: .9; }

/* ---------- Game screen ---------- */
#play { display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #fff;
}
.topbar h2 { margin: 0; font-size: clamp(22px, 6vw, 32px); text-align: center; flex: 1; }

.round-btn {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  font-size: 26px;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
  flex: none;
}
.round-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.15); }

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--gap);
  margin-top: 14px;
  width: 100%;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* Shared pieces used by games */
.info {
  background: rgba(255,255,255,.9);
  border-radius: 18px;
  padding: 10px 18px;
  font-size: 22px;
  font-weight: bold;
  text-align: center;
  min-width: 60%;
  white-space: pre-wrap;
}

.big-btn {
  background: #ffd43b;
  border-radius: 20px;
  padding: 14px 28px;
  font-size: 24px;
  font-weight: bold;
  box-shadow: 0 5px 0 #d9a400;
}
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 #d9a400; }

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

.choice {
  background: #fff;
  border-radius: 16px;
  padding: 10px 18px;
  font-size: 20px;
  box-shadow: 0 4px 0 rgba(0,0,0,.15);
}
.choice.selected { background: #ffd43b; }

.arena {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 380px;
  background: rgba(255,255,255,.25);
  border-radius: 24px;
  overflow: hidden;
  touch-action: none;
}

.celebrate {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 18px;
  background: rgba(0,0,0,.45);
  z-index: 50;
  animation: fade .2s;
}
.celebrate .box {
  background: #fff;
  border-radius: 28px;
  padding: 26px 30px;
  text-align: center;
  max-width: 90%;
  animation: pop .35s;
}
.celebrate .big { font-size: 70px; }
.celebrate .msg { font-size: 28px; font-weight: bold; margin: 8px 0 18px; }

.confetti {
  position: fixed;
  top: -40px;
  font-size: 30px;
  z-index: 60;
  pointer-events: none;
  animation: fall linear forwards;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { 0% { transform: scale(.4); } 70% { transform: scale(1.1); } 100% { transform: scale(1); } }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
.shake { animation: shake .3s; }
