:root {
  --navy: #2b2766; --deep: #110e36; --ink: #0a0826;
  --teal: #1bbdc9; --teal-l: #6fe6ee; --leaf: #8be38f; --gold: #ffc93c;
  --violet: #8b6cff; --pink: #ff6fb5; --white: #fff; --muted: #b9b6e6; --stress: #ff8a5b;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Cairo", system-ui, sans-serif; color: var(--white);
  background: radial-gradient(120% 80% at 50% 0%, var(--navy) 0%, var(--deep) 55%, var(--ink) 100%) fixed;
  min-height: 100vh; user-select: none;
}
button { font: inherit; color: inherit; border: 0; cursor: pointer; }
button:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }

.top { display: flex; align-items: center; gap: 16px; padding: 12px 20px; }
.brand img { height: 40px; display: block; filter: drop-shadow(0 0 10px #1bbdc988); }
.top h1 { flex: 1; margin: 0; font-size: clamp(20px, 3vw, 30px); font-weight: 900; text-align: center; }
.icon-btn { background: #ffffff14; border-radius: 50%; width: 46px; height: 46px; font-size: 22px; }

main { max-width: 1200px; margin: 0 auto; padding: 8px 16px 40px; }

/* home */
.hero { display: flex; align-items: center; justify-content: center; gap: 20px; margin: 10px 0 24px; }
.hero img { width: 110px; animation: float 3s ease-in-out infinite; }
.hero p { margin: 0; font-size: clamp(18px, 2.4vw, 26px); font-weight: 800; color: var(--muted); }
@keyframes float { 50% { transform: translateY(-10px); } }
.games { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.game-card {
  background: linear-gradient(160deg, #ffffff16, #ffffff05); border: 3px solid #1bbdc966; border-radius: 28px;
  padding: 22px; text-align: right; display: flex; flex-direction: column; gap: 8px; min-height: 170px;
  transition: transform .15s, box-shadow .15s;
}
.game-card:hover { transform: translateY(-4px); box-shadow: 0 0 40px #1bbdc966; border-color: var(--teal); }
.game-card .emoji { font-size: 44px; }
.game-card b { font-size: 24px; font-weight: 900; }
.game-card span { color: var(--muted); font-weight: 700; font-size: 16px; }

/* table picker */
.picker { text-align: center; }
.picker h2 { font-size: clamp(22px, 3vw, 32px); margin: 8px 0 4px; }
.picker p { color: var(--muted); margin: 0 0 16px; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 20px; }
.chip {
  min-width: 64px; height: 64px; border-radius: 18px; font-size: 28px; font-weight: 900;
  background: #ffffff10; border: 3px solid #ffffff30;
}
.chip.on { background: var(--teal); color: var(--ink); border-color: var(--teal); box-shadow: 0 0 20px #1bbdc988; }
.chip.all { min-width: 120px; font-size: 20px; }
.go { background: var(--leaf); color: var(--ink); font-weight: 900; font-size: 26px; padding: 12px 48px; border-radius: 999px; box-shadow: 0 0 30px #8be38f88; }
.go:disabled { opacity: .4; }
.ghost { background: #ffffff14; padding: 10px 26px; border-radius: 999px; font-weight: 800; color: var(--white); }

/* shared game bits */
.q { direction: ltr; font-size: clamp(44px, 8vw, 88px); font-weight: 900; text-align: center; margin: 8px 0; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; font-weight: 800; }
.pill { background: #ffffff14; border-radius: 999px; padding: 6px 18px; }
.hint {
  min-height: 48px; text-align: center; font-weight: 800; font-size: clamp(16px, 2.2vw, 22px); color: var(--gold);
  opacity: 0; transition: opacity .2s;
}
.hint.show { opacity: 1; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

/* keypad */
.answer { direction: ltr; text-align: center; font-size: 56px; font-weight: 900; min-height: 80px; letter-spacing: 4px; color: var(--teal-l); }
.keypad { direction: ltr; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 360px; margin: 0 auto; }
.keypad button { height: 68px; border-radius: 18px; background: #ffffff16; font-size: 30px; font-weight: 900; }
.keypad button:active { background: #ffffff30; }
.keypad .ok { background: var(--leaf); color: var(--ink); }
.keypad .del { background: #ff8a5b55; }

/* race */
.race { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.team { border-radius: 26px; padding: 14px; border: 3px solid; position: relative; }
.team.a { border-color: var(--teal); background: #1bbdc914; }
.team.b { border-color: var(--violet); background: #8b6cff14; }
.team h3 { margin: 0 0 8px; text-align: center; font-size: 24px; }
.team .score { font-size: 40px; font-weight: 900; }
.team.locked { opacity: .45; }
.circles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.circle { aspect-ratio: 1; border-radius: 50%; font-size: clamp(24px, 4vw, 40px); font-weight: 900; color: var(--ink); direction: ltr; }
.circle.win { box-shadow: 0 0 0 6px #fff, 0 0 30px #fff; }

/* map */
.map { direction: ltr; display: grid; grid-template-columns: auto repeat(10, 1fr); gap: 4px; max-width: 640px; margin: 0 auto; }
.map .h { text-align: center; font-weight: 900; color: var(--muted); align-self: center; }
.cell { aspect-ratio: 1; border-radius: 8px; background: #ffffff12; font-size: clamp(10px, 1.6vw, 15px); font-weight: 800; color: transparent; }
.cell.done { background: var(--leaf); color: var(--ink); }
.cell.twin { background: var(--teal); color: var(--ink); }
.modal { position: fixed; inset: 0; background: #0a0826cc; display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 5; }
.modal .box { background: var(--deep); border: 3px solid var(--teal); border-radius: 28px; padding: 18px; width: min(420px, 100%); }

/* memory */
.mem { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; max-width: 720px; margin: 0 auto; }
.card { aspect-ratio: 3/4; border-radius: 20px; font-size: clamp(22px, 4vw, 40px); font-weight: 900; direction: ltr; perspective: 600px; background: transparent; }
.card .in { position: relative; width: 100%; height: 100%; transition: transform .35s; transform-style: preserve-3d; }
.card.open .in, .card.gone .in { transform: rotateY(180deg); }
.card .f, .card .b { position: absolute; inset: 0; border-radius: 20px; display: flex; align-items: center; justify-content: center; backface-visibility: hidden; }
.card .f { background: linear-gradient(160deg, var(--navy), var(--deep)); border: 3px solid var(--teal); }
.card .f img { width: 55%; opacity: .9; }
.card .b { transform: rotateY(180deg); background: var(--gold); color: var(--ink); }
.card .b.ans { background: var(--teal-l); }
.card.gone .b { background: var(--leaf); }

/* boom */
.boom-num { font-size: clamp(110px, 22vw, 220px); font-weight: 900; text-align: center; direction: ltr; line-height: 1.1; }
.boom-btn { display: block; margin: 10px auto; width: min(420px, 90%); height: 110px; border-radius: 999px; background: var(--gold); color: var(--ink); font-size: 48px; font-weight: 900; box-shadow: 0 0 40px #ffc93c88; }
.boom-btn:active { transform: scale(.96); }
.lives { font-size: 30px; letter-spacing: 6px; }

/* result */
.result { text-align: center; }
.result .big { font-size: 72px; font-weight: 900; }
.result .lvl { display: inline-block; font-size: 30px; font-weight: 900; padding: 8px 36px; border-radius: 999px; color: var(--ink); margin: 6px 0 16px; }
.result ul { list-style: none; padding: 0; max-width: 520px; margin: 0 auto 18px; }
.result li { background: #ffffff10; border-radius: 16px; padding: 10px 14px; margin: 8px 0; font-weight: 700; }
.result li b { direction: ltr; display: inline-block; }
.row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.flash-ok { animation: ok .5s; }
@keyframes ok { 30% { background: #8be38f55; } }

@media (max-width: 640px) {
  .race { grid-template-columns: 1fr; }
  .mem { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1000px) { .games { grid-template-columns: repeat(5, 1fr); } }
