:root {
  --bg: #07101d;
  --panel: rgba(12, 24, 42, 0.72);
  --panel-2: rgba(20, 35, 58, 0.68);
  --line: rgba(255,255,255,0.09);
  --text: #f4f7fb;
  --muted: #8fa1b9;
  --blue: #44a8ff;
  --blue-2: #1f6fff;
  --red: #ff5f67;
  --red-2: #ef2945;
  --green: #65e8ae;
  --shadow: 0 24px 90px rgba(0,0,0,0.42);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(circle at 20% 20%, rgba(27, 99, 181, 0.18), transparent 32%),
    radial-gradient(circle at 78% 78%, rgba(218, 42, 71, 0.12), transparent 35%),
    linear-gradient(145deg, #050c16 0%, #091424 55%, #06101d 100%);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

button { color: inherit; }

.ambient {
  position: fixed;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: .15;
  z-index: 0;
}
.ambient-one { background: #1088ff; top: -190px; right: -130px; }
.ambient-two { background: #ff314f; bottom: -240px; left: -120px; }

.topbar {
  position: relative;
  z-index: 5;
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 12px;
  background: linear-gradient(145deg, rgba(68,168,255,.22), rgba(255,95,103,.17));
  border: 1px solid rgba(255,255,255,.13);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  cursor: pointer;
  transition: .2s ease;
}
.icon-btn:hover { transform: translateY(-2px); background: rgba(255,255,255,.07); }

.app-shell {
  position: relative;
  z-index: 2;
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

.screen { display: none; }
.screen.active { display: block; animation: screenIn .45s ease both; }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.glass {
  background: linear-gradient(145deg, rgba(19,35,58,.78), rgba(10,22,38,.65));
  border: 1px solid var(--line);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.045);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.hero-card {
  min-height: 680px;
  border-radius: 34px;
  padding: 64px;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 40px;
  align-items: center;
  overflow: hidden;
  position: relative;
}

.hero-card::after {
  content: "";
  position: absolute;
  inset: auto -10% -35% auto;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(71,168,255,.12), transparent 66%);
}

.eyebrow {
  color: #8fa5bf;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .2em;
}

.hero-copy h1 {
  margin: 14px 0 18px;
  max-width: 590px;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(52px, 7vw, 88px);
  line-height: .96;
  letter-spacing: -0.065em;
}

.hero-copy h1 span {
  background: linear-gradient(90deg, #69bbff, #ff747c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-copy > p {
  max-width: 560px;
  margin: 0 0 36px;
  color: var(--muted);
  line-height: 1.8;
  font-size: 16px;
}

.mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  max-width: 620px;
}

.mode-card {
  min-height: 96px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.035);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  cursor: pointer;
  text-align: left;
  transition: .22s ease;
}
.mode-card:hover {
  transform: translateY(-4px);
  border-color: rgba(255,255,255,.18);
  background: rgba(255,255,255,.06);
}
.primary-card {
  background: linear-gradient(135deg, rgba(54,143,255,.18), rgba(31,111,255,.08));
  border-color: rgba(76,165,255,.22);
}
.mode-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 15px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.07);
  font-size: 21px;
}
.mode-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.mode-text b { font-size: 14px; }
.mode-text small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.arrow { margin-left: auto; color: #8fa5bf; }

.mini-stats {
  display: flex;
  gap: 34px;
  margin-top: 34px;
}
.mini-stats div { display: flex; flex-direction: column; gap: 3px; }
.mini-stats strong { font-family: "Space Grotesk"; font-size: 19px; }
.mini-stats span { color: var(--muted); font-size: 11px; }

.hero-visual {
  min-height: 500px;
  position: relative;
  display: grid;
  place-items: center;
}

.showcase-ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,.06);
}
.ring-one { width: 380px; height: 380px; }
.ring-two { width: 500px; height: 500px; border-color: rgba(255,255,255,.035); }

.showcase-bottle {
  position: absolute;
  width: 140px;
  height: 310px;
  filter: drop-shadow(0 26px 30px rgba(0,0,0,.34));
}
.blue-bottle { transform: translate(-92px, 18px) rotate(-8deg); }
.red-bottle { transform: translate(92px, -8px) rotate(8deg); }

.showcase-bottle .cap,
.bottle .cap {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 58px;
  height: 34px;
  border-radius: 12px 12px 7px 7px;
  background: linear-gradient(#2b3543, #111a27);
  border: 1px solid rgba(255,255,255,.12);
  z-index: 3;
}
.showcase-bottle .neck,
.bottle .neck {
  position: absolute;
  top: 28px;
  left: 50%;
  transform: translateX(-50%);
  width: 48px;
  height: 46px;
  border: 2px solid rgba(255,255,255,.18);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  background: rgba(255,255,255,.028);
}
.showcase-bottle .body,
.bottle .body {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 66px;
  width: 100%;
  height: 230px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.18);
  border-radius: 28px 28px 38px 38px;
  background:
    linear-gradient(90deg, rgba(255,255,255,.07), rgba(255,255,255,.015) 35%, rgba(255,255,255,.06) 72%, rgba(255,255,255,.015)),
    rgba(255,255,255,.025);
  box-shadow: inset 12px 0 20px rgba(255,255,255,.025), inset -10px 0 18px rgba(0,0,0,.11);
}
.showcase-bottle .body::after,
.bottle .body::after {
  content: "";
  position: absolute;
  top: 24px;
  left: 16px;
  width: 14px;
  height: 125px;
  border-radius: 999px;
  background: linear-gradient(rgba(255,255,255,.22), transparent);
  opacity: .48;
}
.showcase-bottle .liquid,
.bottle .liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 76%;
  border-radius: 22px 22px 32px 32px;
}
.blue-bottle .liquid { background: linear-gradient(#52baff, #176de6); box-shadow: 0 -15px 40px rgba(68,168,255,.34); }
.red-bottle .liquid { background: linear-gradient(#ff747d, #dd2440); box-shadow: 0 -15px 40px rgba(255,95,103,.3); }

.vs-chip {
  position: absolute;
  z-index: 5;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: "Space Grotesk";
  font-weight: 700;
  background: #0d1929;
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 16px 40px rgba(0,0,0,.34);
}

/* GAME */
.game-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 18px;
  min-height: 690px;
}
.side-panel,
.board-panel {
  border-radius: 30px;
}
.side-panel { padding: 24px; }
.board-panel { padding: 30px; }

.back-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0;
}
.back-btn:hover { color: white; }

.match-title { margin: 46px 0 22px; }
.match-title h2 {
  margin: 8px 0 0;
  font-family: "Space Grotesk";
  font-size: 29px;
}

.score-card {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 18px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
}
.avatar-dot {
  width: 38px;
  height: 38px;
  border-radius: 13px;
}
.avatar-dot.blue { background: linear-gradient(145deg, var(--blue), var(--blue-2)); box-shadow: 0 8px 24px rgba(68,168,255,.23); }
.avatar-dot.red { background: linear-gradient(145deg, var(--red), var(--red-2)); box-shadow: 0 8px 24px rgba(255,95,103,.2); }
.score-card div:nth-child(2) { display: flex; flex-direction: column; gap: 2px; }
.score-card small { color: var(--muted); font-size: 9px; font-weight: 800; letter-spacing: .13em; }
.score-card strong { font-size: 13px; }
.score-card > span { font-family: "Space Grotesk"; font-size: 24px; font-weight: 700; }

.difficulty-block {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.difficulty-block label { color: var(--muted); font-size: 11px; font-weight: 700; }
.difficulty-block select {
  appearance: none;
  color: var(--text);
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px;
  outline: none;
}
.difficulty-block select option { color: #111; }

.secondary-btn, .primary-btn {
  width: 100%;
  border-radius: 15px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  cursor: pointer;
  font-weight: 700;
  transition: .2s ease;
}
.secondary-btn { margin-top: 12px; background: rgba(255,255,255,.04); }
.secondary-btn:hover { background: rgba(255,255,255,.075); }
.primary-btn {
  margin-top: 18px;
  border-color: rgba(78,164,255,.24);
  background: linear-gradient(135deg, #2587ff, #155ddf);
  box-shadow: 0 13px 30px rgba(23,105,231,.22);
}
.primary-btn:hover { transform: translateY(-2px); }

.turn-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.turn-row h3 {
  margin: 7px 0 0;
  font-family: "Space Grotesk";
  font-size: 25px;
}
.turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}
.blue-pill { color: #7ec5ff; background: rgba(68,168,255,.09); border: 1px solid rgba(68,168,255,.18); }
.red-pill { color: #ff858c; background: rgba(255,95,103,.09); border: 1px solid rgba(255,95,103,.18); }
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 14px currentColor;
}

.board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  max-width: 660px;
  margin: 10px auto 0;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border: 1px solid rgba(255,255,255,.075);
  border-radius: 22px;
  background:
    radial-gradient(circle at 50% 80%, rgba(255,255,255,.035), transparent 50%),
    rgba(255,255,255,.022);
  cursor: pointer;
  transition: .2s ease;
  overflow: hidden;
}
.cell:hover:not(.taken) {
  transform: translateY(-3px);
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.042);
}
.cell.winner {
  border-color: rgba(101,232,174,.38);
  box-shadow: inset 0 0 0 1px rgba(101,232,174,.14), 0 0 34px rgba(101,232,174,.08);
}

.bottle {
  width: 54px;
  height: 120px;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%);
  filter: drop-shadow(0 14px 18px rgba(0,0,0,.28));
  transition: transform .22s ease;
}
.cell:hover .bottle { transform: translate(-50%, -50%) scale(1.03); }
.bottle .cap { width: 24px; height: 14px; border-radius: 5px 5px 3px 3px; }
.bottle .neck { top: 12px; width: 20px; height: 19px; border-width: 1px; border-radius: 5px 5px 0 0; }
.bottle .body {
  top: 28px;
  width: 54px;
  height: 88px;
  border-width: 1px;
  border-radius: 13px 13px 17px 17px;
}
.bottle .body::after {
  top: 10px;
  left: 6px;
  width: 5px;
  height: 48px;
}
.bottle .liquid {
  height: 0%;
  border-radius: 10px 10px 16px 16px;
  transition: height .5s cubic-bezier(.22,.85,.33,1), background .2s ease;
}
.cell.blue .bottle .liquid {
  height: 76%;
  background: linear-gradient(#54bdff, #176ce6);
  box-shadow: 0 -8px 24px rgba(68,168,255,.33);
}
.cell.red .bottle .liquid {
  height: 76%;
  background: linear-gradient(#ff7880, #df2741);
  box-shadow: 0 -8px 24px rgba(255,95,103,.3);
}
.cell.taken .bottle { animation: bottlePop .42s ease both; }

@keyframes bottlePop {
  0% { transform: translate(-50%, -48%) scale(.9) rotate(-2deg); }
  60% { transform: translate(-50%, -53%) scale(1.08) rotate(2deg); }
  100% { transform: translate(-50%, -48%) scale(1); }
}

.result-banner {
  max-width: 660px;
  margin: 18px auto 0;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.045);
  padding: 13px 14px 13px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.result-banner div { display: flex; flex-direction: column; gap: 3px; }
.result-banner small { color: var(--muted); font-size: 9px; letter-spacing: .13em; font-weight: 800; }
.result-banner strong { font-size: 14px; }
.result-banner button {
  border: 0;
  background: white;
  color: #09111f;
  font-weight: 800;
  border-radius: 12px;
  padding: 10px 15px;
  cursor: pointer;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(2, 8, 15, .68);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 22px;
}
.modal {
  width: min(620px, 100%);
  border-radius: 28px;
  padding: 30px;
  position: relative;
  animation: modalIn .28s ease both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
  position: absolute;
  right: 18px;
  top: 16px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
}
.modal h2 {
  margin: 8px 0 8px;
  font-family: "Space Grotesk";
  font-size: 30px;
}
.modal > p { margin: 0 0 24px; color: var(--muted); line-height: 1.65; }

.difficulty-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.difficulty-choice {
  min-height: 128px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.03);
  border-radius: 18px;
  color: white;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 16px;
  transition: .2s ease;
}
.difficulty-choice:hover,
.active-choice {
  transform: translateY(-2px);
  border-color: rgba(68,168,255,.32);
  background: rgba(68,168,255,.07);
}
.difficulty-choice span { font-size: 22px; }
.difficulty-choice b { margin-top: auto; font-size: 13px; }
.difficulty-choice small { color: var(--muted); font-size: 10px; }

.online-actions { display: grid; gap: 12px; }
.join-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.join-box input {
  min-width: 0;
  color: white;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.04);
  border-radius: 15px;
  padding: 14px 16px;
  outline: none;
  letter-spacing: .14em;
}
.join-box input:focus { border-color: rgba(68,168,255,.32); }
.join-box button {
  border: 0;
  border-radius: 15px;
  padding: 0 22px;
  background: white;
  color: #07101d;
  font-weight: 800;
  cursor: pointer;
}
.demo-note {
  margin-top: 14px;
  padding: 13px 14px;
  border-radius: 14px;
  color: #b7c8db;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid rgba(255,255,255,.07);
  background: rgba(255,255,255,.035);
}

.hidden { display: none !important; }

@media (max-width: 900px) {
  .hero-card { grid-template-columns: 1fr; padding: 40px; }
  .hero-visual { min-height: 420px; order: -1; }
  .game-layout { grid-template-columns: 1fr; }
  .side-panel { display: grid; grid-template-columns: auto 1fr 1fr; gap: 10px; align-items: center; }
  .match-title { margin: 0 10px; }
  .difficulty-block { grid-column: 1 / -1; margin-top: 8px; }
  .secondary-btn { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .topbar { padding-top: 18px; }
  .app-shell { padding: 20px 14px 34px; }
  .hero-card { min-height: auto; padding: 24px; border-radius: 25px; }
  .hero-visual { min-height: 320px; }
  .showcase-bottle { width: 100px; height: 230px; }
  .showcase-bottle .body { height: 170px; }
  .blue-bottle { transform: translate(-66px, 12px) rotate(-8deg); }
  .red-bottle { transform: translate(66px, -6px) rotate(8deg); }
  .ring-one { width: 280px; height: 280px; }
  .ring-two { width: 355px; height: 355px; }
  .hero-copy h1 { font-size: 50px; }
  .mode-grid { grid-template-columns: 1fr; }
  .mini-stats { justify-content: space-between; gap: 10px; }
  .side-panel { grid-template-columns: 1fr 1fr; padding: 18px; }
  .back-btn, .match-title { grid-column: 1 / -1; }
  .board-panel { padding: 18px 12px; }
  .board { gap: 8px; }
  .cell { border-radius: 16px; }
  .bottle { transform: translate(-50%, -48%) scale(.9); }
  .cell:hover .bottle { transform: translate(-50%, -50%) scale(.92); }
  .difficulty-cards { grid-template-columns: 1fr; }
  .difficulty-choice { min-height: 92px; }
  .turn-row { align-items: flex-end; }
  .turn-row h3 { font-size: 21px; }
}


/* Mystery bottle reveal animation */
.cell.shaking {
  pointer-events: none;
  border-color: rgba(255,255,255,.16);
  background: rgba(255,255,255,.05);
}

.cell.shaking .bottle {
  animation: mysteryShake .7s cubic-bezier(.36,.07,.19,.97) both;
}

.cell.revealed .bottle {
  animation: revealPop .48s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes mysteryShake {
  0%   { transform: translate(-50%, -48%) rotate(0deg) scale(1); }
  10%  { transform: translate(-55%, -50%) rotate(-8deg) scale(1.02); }
  20%  { transform: translate(-44%, -47%) rotate(8deg) scale(1.03); }
  30%  { transform: translate(-56%, -51%) rotate(-10deg) scale(1.04); }
  40%  { transform: translate(-43%, -46%) rotate(10deg) scale(1.04); }
  50%  { transform: translate(-55%, -51%) rotate(-8deg) scale(1.05); }
  60%  { transform: translate(-45%, -46%) rotate(8deg) scale(1.04); }
  75%  { transform: translate(-52%, -50%) rotate(-4deg) scale(1.03); }
  100% { transform: translate(-50%, -48%) rotate(0deg) scale(1); }
}

@keyframes revealPop {
  0%   { transform: translate(-50%, -48%) scale(.95); filter: brightness(1); }
  55%  { transform: translate(-50%, -54%) scale(1.10); filter: brightness(1.35); }
  100% { transform: translate(-50%, -48%) scale(1); filter: brightness(1); }
}
