/* ============================================================
   Max Tac Sahil
   ============================================================ */

:root {
  --bg:        #1b1033;
  --bg-2:      #2b1657;
  --ink:       #fff6e5;
  --max:       #ffd23f;   /* Max = sunny yellow */
  --sahil:     #4ecdc4;   /* Sahil = teal */
  --hot:       #ff5d8f;
  --line:      rgba(255, 246, 229, 0.16);
  --cell:      rgba(255, 255, 255, 0.06);
  --shadow:    0 10px 0 rgba(0,0,0,.28);
  --pad:       env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px)
               env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

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

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Nunito', system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 50% -10%, var(--bg-2) 0%, var(--bg) 62%),
    var(--bg);
  user-select: none;
}

/* confetti-ish background dots */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(3px 3px at 12% 22%, var(--max) 50%, transparent 51%),
    radial-gradient(3px 3px at 82% 14%, var(--sahil) 50%, transparent 51%),
    radial-gradient(2px 2px at 68% 78%, var(--hot) 50%, transparent 51%),
    radial-gradient(2px 2px at 24% 84%, var(--sahil) 50%, transparent 51%),
    radial-gradient(2px 2px at 92% 56%, var(--max) 50%, transparent 51%),
    radial-gradient(2px 2px at 6% 58%, var(--hot) 50%, transparent 51%);
  opacity: .5;
  pointer-events: none;
  animation: drift 14s ease-in-out infinite alternate;
}
@keyframes drift { to { transform: translateY(-14px); } }

#app {
  position: relative;
  height: 100%;
  padding: var(--pad);
}

/* ---------- screens ---------- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 24px calc(20px + env(safe-area-inset-left, 0px))
           calc(24px + env(safe-area-inset-bottom, 0px))
           calc(20px + env(safe-area-inset-right, 0px));
  text-align: center;
}
.screen.is-active { display: flex; animation: screenIn .32s ease both; }
@keyframes screenIn { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ---------- title ---------- */
.logo {
  margin: 0;
  font-family: 'Luckiest Guy', cursive;
  font-weight: 400;
  letter-spacing: .02em;
  line-height: .92;
  font-size: clamp(2.6rem, 13vw, 5.4rem);
  display: flex;
  flex-direction: column;
}
.logo-word { display: block; text-shadow: 0 5px 0 rgba(0,0,0,.35); }
.logo-word--max   { color: var(--max);   transform: rotate(-3deg); }
.logo-word--tac   { color: var(--ink);   font-size: .62em; letter-spacing: .18em; }
.logo-word--sahil { color: var(--sahil); transform: rotate(2.5deg); }

.tagline {
  margin: -6px 0 0;
  font-weight: 700;
  opacity: .6;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: .8rem;
}

.title-faces { display: flex; gap: clamp(10px, 6vw, 40px); align-items: flex-end; }
.title-face {
  width: clamp(84px, 26vw, 150px);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,.45));
}
.title-face--left  { animation: bobA 2.4s ease-in-out infinite; }
.title-face--right { animation: bobB 2.4s ease-in-out infinite .3s; }
@keyframes bobA { 0%,100% { transform: translateY(0) rotate(-6deg); } 50% { transform: translateY(-12px) rotate(-2deg); } }
@keyframes bobB { 0%,100% { transform: translateY(0) rotate(6deg); }  50% { transform: translateY(-12px) rotate(2deg); } }

/* ---------- buttons ---------- */
.heading {
  font-family: 'Luckiest Guy', cursive;
  font-weight: 400;
  font-size: clamp(1.5rem, 7vw, 2.4rem);
  margin: 0;
  text-shadow: 0 4px 0 rgba(0,0,0,.3);
}

.stack { display: flex; flex-direction: column; gap: 14px; width: min(340px, 88vw); }

.btn {
  font-family: 'Luckiest Guy', cursive;
  font-size: clamp(1.05rem, 4.6vw, 1.4rem);
  letter-spacing: .04em;
  color: #2a1350;
  background: var(--ink);
  border: 0;
  border-radius: 18px;
  padding: 16px 26px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  width: 100%;
}
.btn small {
  font-family: 'Nunito', sans-serif;
  font-weight: 700;
  font-size: .68rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  opacity: .55;
}
.btn:active { transform: translateY(6px); box-shadow: 0 4px 0 rgba(0,0,0,.28); }
.btn--big { width: min(300px, 78vw); background: var(--hot); color: #fff; font-size: clamp(1.4rem, 6vw, 2rem); padding: 18px 32px; }
.btn--ghost {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  opacity: .6;
  font-family: 'Nunito', sans-serif;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: .78rem;
  width: auto;
  padding: 10px 18px;
}
.btn--ghost:active { transform: none; opacity: 1; }

/* ---------- picker ---------- */
.picker { display: flex; gap: clamp(12px, 5vw, 28px); flex-wrap: wrap; justify-content: center; }
.pick-card {
  background: var(--cell);
  border: 3px solid var(--line);
  border-radius: 26px;
  padding: 18px 16px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--ink);
  font-family: 'Luckiest Guy', cursive;
  font-size: 1.2rem;
  letter-spacing: .06em;
  transition: transform .14s ease, border-color .14s ease, background .14s ease;
  width: clamp(130px, 40vw, 168px);
}
.pick-card img { width: 100%; aspect-ratio: 1; object-fit: contain; filter: drop-shadow(0 6px 8px rgba(0,0,0,.4)); }
.pick-card:active { transform: scale(.95); }
.pick-card[data-pick="max"]:hover   { border-color: var(--max);   background: rgba(255,210,63,.12); }
.pick-card[data-pick="sahil"]:hover { border-color: var(--sahil); background: rgba(78,205,196,.12); }

/* ---------- game ---------- */
.screen--game { justify-content: center; gap: clamp(20px, 5vh, 44px); padding-top: 18px; }
.screen--game .scoreboard { margin-bottom: auto; }
.screen--game .game-actions { margin-top: auto; }

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 6vw, 40px);
  width: min(420px, 92vw);
}
.score { display: flex; align-items: center; gap: 8px; opacity: .45; transition: opacity .2s ease, transform .2s ease; }
.score.is-turn { opacity: 1; transform: scale(1.08); }
.score img { width: clamp(38px, 12vw, 54px); aspect-ratio: 1; object-fit: contain; }
.score-num { font-family: 'Luckiest Guy', cursive; font-size: 1.5rem; }
.score-mid { display: flex; flex-direction: column; gap: 2px; min-width: 96px; }
.score-mid span {
  font-family: 'Luckiest Guy', cursive;
  font-size: .95rem;
  letter-spacing: .04em;
}
.score-mid small { font-size: .62rem; text-transform: uppercase; letter-spacing: .14em; opacity: .45; font-weight: 900; }

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: clamp(8px, 2.4vw, 14px);
  width: min(88vw, 60vh, 440px);
  aspect-ratio: 1;
}
.cell {
  border: 0;
  border-radius: 20px;
  background: var(--cell);
  box-shadow: inset 0 0 0 3px var(--line);
  cursor: pointer;
  padding: 8%;
  display: grid;
  place-items: center;
  transition: background .15s ease;
}
.cell:not(.is-filled):active { background: rgba(255,255,255,.14); }
.cell img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 6px rgba(0,0,0,.45)); }
.cell.is-filled { cursor: default; }
.cell.just-placed img { animation: pop .34s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes pop { from { transform: scale(0) rotate(-40deg); } 60% { transform: scale(1.18) rotate(8deg); } to { transform: scale(1) rotate(0); } }

.cell.is-win { background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 4px currentColor; }
.cell.is-win img { animation: shake .45s ease-in-out infinite; }
.cell.is-lose img { animation: flop .6s cubic-bezier(.3,1.4,.5,1) both; }

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(-7deg) scale(1.06); }
  25%      { transform: translateX(-4px) rotate(7deg) scale(1.1); }
  50%      { transform: translateX(4px) rotate(-5deg) scale(1.06); }
  75%      { transform: translateX(-3px) rotate(6deg) scale(1.1); }
}
@keyframes flop { to { transform: rotate(180deg) scale(.82); filter: grayscale(.7) drop-shadow(0 4px 6px rgba(0,0,0,.45)); } }
@keyframes wobble {
  0%, 100% { transform: rotate(-9deg); }
  50%      { transform: rotate(9deg); }
}

.game-actions { padding-bottom: 6px; }

/* ---------- overlay ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(12, 6, 26, .84);
  backdrop-filter: blur(10px);
  animation: screenIn .28s ease both;
  padding: 24px;
}
.overlay[hidden] { display: none; }
.overlay-inner { display: flex; flex-direction: column; align-items: center; gap: 22px; text-align: center; }

.result-faces { display: flex; gap: clamp(12px, 6vw, 34px); align-items: center; }
.result-face {
  width: clamp(96px, 30vw, 168px);
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 10px 14px rgba(0,0,0,.5));
}
.result-face.is-winner { animation: shake .42s ease-in-out infinite; }
.result-face.is-loser  { transform: rotate(180deg) scale(.8); filter: grayscale(.7) drop-shadow(0 10px 14px rgba(0,0,0,.5)); }
.result-face.is-tie    { animation: wobble 1s ease-in-out infinite; }
.result-face.is-tie:nth-child(2) { animation-delay: .5s; }

.result-text {
  margin: 0;
  font-family: 'Luckiest Guy', cursive;
  font-weight: 400;
  font-size: clamp(1.8rem, 9vw, 3.2rem);
  text-shadow: 0 5px 0 rgba(0,0,0,.35);
  line-height: 1;
}
.result-text.max   { color: var(--max); }
.result-text.sahil { color: var(--sahil); }
.result-text.tie   { color: var(--hot); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
