* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: ui-rounded, "Avenir Next", "Trebuchet MS", system-ui, sans-serif;
  color: #2a1f3d;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 200, 80, 0.25) 0 90px, transparent 91px),
    radial-gradient(circle at 92% 22%, rgba(80, 180, 255, 0.2) 0 70px, transparent 71px),
    radial-gradient(circle at 15% 90%, rgba(255, 100, 140, 0.18) 0 80px, transparent 81px),
    radial-gradient(circle at 88% 85%, rgba(90, 210, 130, 0.2) 0 60px, transparent 61px),
    #fdf3e3;
}

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

.hidden { display: none !important; }

/* ---------- buttons ---------- */

.pill {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  background: #fff;
  border: 2px solid #2a1f3d;
  border-radius: 999px;
  padding: 0 14px;
  min-height: 40px;
  white-space: nowrap;
  box-shadow: 0 3px 0 #2a1f3d;
}
.pill:active { transform: translateY(2px); box-shadow: 0 1px 0 #2a1f3d; }
.pill.big { font-size: 16px; min-height: 52px; padding: 0 24px; background: #ffd34a; }
.pill.ghost { background: #fff; }

.group {
  display: flex;
  border: 2px solid #2a1f3d;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 3px 0 #2a1f3d;
}
.group button {
  border: 0;
  background: none;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  padding: 0 12px;
  min-height: 36px;
}
.group button + button { border-left: 2px solid #2a1f3d; }
.group button.on { background: var(--c, #ffd34a); color: #fff; text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35); }

/* ---------- the shelf ---------- */

#hub {
  min-height: 100%;
  padding:
    max(20px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(70px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
}
#hub header { text-align: center; margin: 10px auto 22px; max-width: 640px; }
#hub .bolt { font-size: 64px; animation: bob 2.4s ease-in-out infinite; }
#hub h1 { margin: 4px 0 6px; font-size: clamp(32px, 7vw, 52px); letter-spacing: 1px; text-shadow: 3px 3px 0 #ffd34a; }
#hub p { margin: 0; font-size: 17px; opacity: 0.8; }
#total { margin-top: 10px; font-weight: 800; color: #1f8a4c; }

#shelf {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  max-width: 1100px;
  margin: 0 auto;
}
.game {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 4px;
  padding: 14px 16px 12px;
  border: 3px solid #2a1f3d;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 5px 0 #2a1f3d;
  position: relative;
  overflow: hidden;
  transition: transform 0.12s;
}
.game::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 8px;
  background: var(--c);
}
.game:hover { transform: translateY(-3px) rotate(-0.5deg); }
.game:active { transform: translateY(3px); box-shadow: 0 2px 0 #2a1f3d; }
.game .emoji { font-size: 40px; margin-top: 4px; }
.game .name { font-size: 21px; font-weight: 900; }
.game .blurb { font-size: 14px; opacity: 0.75; line-height: 1.3; flex: 1; }
.game .rec { margin-top: 6px; font-size: 13px; font-weight: 800; color: var(--c); filter: brightness(0.8); }

@keyframes bob { 50% { transform: translateY(-8px) rotate(4deg); } }

/* ---------- playing ---------- */

#play {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding:
    max(10px, env(safe-area-inset-top))
    max(10px, env(safe-area-inset-right))
    max(54px, env(safe-area-inset-bottom))
    max(10px, env(safe-area-inset-left));
  gap: 6px;
  touch-action: manipulation;
}
#bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding-right: 120px; /* the arcade's 🏆 pill sits in the top right */
}
#title { font-size: 20px; font-weight: 900; padding: 0 6px; white-space: nowrap; }
@media (max-width: 720px) {
  #bar { padding-right: 0; padding-top: 34px; }
  #title { width: 100%; text-align: center; order: -1; }
}

#score {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 16px;
}
#score .side { background: #fff; border: 2px solid #2a1f3d; border-radius: 999px; padding: 3px 12px; }
#score b { font-size: 18px; }
#score .you b { color: #1f8a4c; }
#score .bot b { color: #d23a4a; }

#status {
  min-height: 26px;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}
#status .dim { opacity: 0.6; font-weight: 700; }

#area {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
#board { position: relative; }

/* ---------- win / lose ---------- */

#result {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 20, 50, 0.45);
  z-index: 50;
  animation: fade 0.3s;
}
#result .card {
  background: #fff;
  border: 4px solid #2a1f3d;
  border-radius: 28px;
  box-shadow: 0 8px 0 #2a1f3d;
  padding: 26px 30px;
  text-align: center;
  max-width: 90vw;
  animation: pop 0.4s cubic-bezier(0.3, 1.6, 0.6, 1);
}
#resultEmoji { font-size: 72px; }
#resultText { font-size: 30px; font-weight: 900; margin: 4px 0; }
#result.win #resultText { color: #1f8a4c; }
#result.lose #resultText { color: #d23a4a; }
#resultSub { font-size: 16px; opacity: 0.75; margin-bottom: 18px; }
#result .buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(0.5); opacity: 0; } }

#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
#confetti span {
  position: absolute;
  top: -50px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

/* ---------- shared bits the games use ---------- */

.die {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 0;
  gap: 0;
  background: #fff;
  border: 3px solid #2a1f3d;
  border-radius: 18%;
  box-shadow: 0 4px 0 #2a1f3d;
}
.die i { border-radius: 50%; margin: 22%; } /* percent margins follow the cell, not the page */
.die i.dot { background: #2a1f3d; }
.die.rolling { animation: shake 0.1s infinite; }
.die.ready { animation: nudge 1s ease-in-out infinite; cursor: pointer; background: #fff7c2; }
@keyframes shake { 25% { transform: rotate(-12deg) scale(1.05); } 75% { transform: rotate(12deg) scale(0.95); } }
@keyframes nudge { 50% { transform: scale(1.08); } }

.chip {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  border: 2px solid #2a1f3d;
  vertical-align: -0.1em;
}
