:root {
  --bg: #e7e2d8;
  --bg-2: #d8d1c5;
  --panel: rgba(18, 24, 32, 0.18);
  --panel-strong: rgba(18, 24, 32, 0.28);
  --ink: #111820;
  --ink-soft: rgba(17, 24, 32, 0.74);
  --ink-muted: rgba(17, 24, 32, 0.54);
  --cream: #f4efe7;
  --ad-w: clamp(330px, 24.5vw, 470px);
  --ad-h: clamp(132px, 14.5vh, 190px);
  --corner-gap: 10px;
  --layout-w: min(92vw, 760px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  position: relative;
  min-height: 100svh;
  isolation: isolate;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

#liquidBack,
#liquidOverlay,
.scene-depth {
  position: fixed;
  inset: 0;
}

#liquidBack {
  z-index: -4;
  width: 100%;
  height: 100%;
  display: block;
  background:
    radial-gradient(circle at 22% 14%, rgba(255,255,255,0.24), transparent 24%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
}

.scene-depth {
  z-index: -3;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 40%, rgba(53, 48, 39, 0.055) 68%, rgba(19, 22, 24, 0.15) 100%),
    radial-gradient(circle at 84% 72%, rgba(29, 66, 72, 0.07), transparent 28%),
    radial-gradient(circle at 14% 20%, rgba(255,255,255,0.15), transparent 24%);
  mix-blend-mode: multiply;
}

#liquidOverlay {
  z-index: 50;
  pointer-events: none;
  width: 100%;
  height: 100%;
  display: block;
  mix-blend-mode: soft-light;
}

.stage {
  position: relative;
  z-index: 10;
  width: 100vw;
  height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(34px + var(--safe-top)) 28px calc(34px + var(--safe-bottom));
  pointer-events: none;
}

.game-layout {
  pointer-events: auto;
  position: relative;
  width: var(--layout-w);
  padding: 24px 24px 20px;
  color: var(--ink);
  border-radius: 28px;
}

/* No popup shell. This only helps the old inner layout stay readable under liquid. */
.game-layout::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 28px;
  pointer-events: none;
}

.boat-topline,
.boat-body {
  position: relative;
  z-index: 1;
}

.boat-topline {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 17px;
}

.eyebrow {
  margin: 0 0 7px;
  color: rgba(17,24,32,0.58);
  font-size: 0.72rem;
  letter-spacing: 0.20em;
  text-transform: uppercase;
  font-weight: 950;
}

h1 {
  margin: 0;
  font-family: 'Bebas Neue', Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: clamp(2.6rem, 5.5vw, 5.0rem);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  filter: url(#waterFx);
  text-shadow:
    0 2px 0 rgba(255,255,255,0.21),
    0 18px 52px rgba(25, 53, 60, 0.12);
}

h1 span { letter-spacing: 0.03em; text-transform: uppercase; }

.challenge-line {
  margin: 11px 0 0;
  max-width: 31rem;
  color: var(--ink-soft);
  font-size: 0.98rem;
  font-weight: 650;
  line-height: 1.38;
}

.ai-pill {
  flex: 0 0 auto;
  padding: 10px 13px;
  border-radius: 999px;
  border: 1px solid rgba(17,24,32,0.10);
  background: rgba(255,255,255,0.16);
  color: rgba(17,24,32,0.78);
  font-size: 0.74rem;
  font-weight: 950;
  letter-spacing: 0.04em;
  backdrop-filter: blur(7px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.36), 0 14px 32px rgba(20,22,22,0.06);
}

.boat-body {
  display: grid;
  grid-template-columns: minmax(300px, 350px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.board-wrap {
  padding: 14px;
  border-radius: 24px;
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.32),
    0 18px 46px rgba(17,24,32,0.07);
}

.tic-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cell {
  aspect-ratio: 1 / 1;
  border-radius: 20px;
  border: 1px solid rgba(17,24,32,0.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22), rgba(255,255,255,0.10)),
    rgba(17, 24, 32, 0.055);
  color: rgba(17,24,32,0.92);
  font: 950 clamp(2rem, 6vw, 4.2rem)/1 Inter, ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  backdrop-filter: blur(5px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.35),
    inset 0 -16px 34px rgba(40, 84, 92, 0.045),
    0 12px 24px rgba(17,24,32,0.075);
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.cell:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(17,24,32,0.24);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.28), rgba(255,255,255,0.13)),
    rgba(17, 24, 32, 0.065);
}

.cell:disabled { cursor: default; }

.cell.mark-x,
.cell.mark-o { animation: markPop 260ms cubic-bezier(.2,1.4,.2,1) both; }

.cell.mark-o { color: rgba(31, 83, 96, 0.94); }

.cell.win-cell {
  border-color: rgba(17,24,32,0.30);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.38),
    0 0 0 3px rgba(255,255,255,0.14),
    0 12px 24px rgba(17,24,32,0.09);
}

.info-stack {
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
}

.score-deck {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.score-card,
.result-panel {
  border-radius: 18px;
  border: 1px solid rgba(17,24,32,0.10);
  background: rgba(255,255,255,0.13);
  backdrop-filter: blur(6px);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.32),
    0 14px 34px rgba(17,24,32,0.055);
}

.score-card {
  padding: 14px 12px;
  text-align: center;
}

.score-card span {
  display: block;
  color: var(--ink-muted);
  font-size: 0.68rem;
  font-weight: 950;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.score-card strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.05rem, 2vw, 1.5rem);
  letter-spacing: -0.05em;
  color: rgba(17,24,32,0.90);
}

.result-panel {
  padding: 16px;
  background: rgba(255,255,255,0.12);
}

.result-panel span,
.result-panel small { display: block; }

.result-panel span {
  font-weight: 850;
  color: rgba(17,24,32,0.88);
}

.result-panel small {
  margin-top: 6px;
  color: var(--ink-soft);
}

.boat-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.primary-btn,
.ghost-btn {
  appearance: none;
  border: 1px solid rgba(17,24,32,0.12);
  border-radius: 16px;
  padding: 14px 16px;
  font: 950 0.94rem/1 Inter, ui-sans-serif, system-ui, sans-serif;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.32),
    0 14px 34px rgba(17,24,32,0.065);
}

.primary-btn {
  color: #f7f2e9;
  background: linear-gradient(180deg, rgba(17,24,32,0.92), rgba(17,24,32,0.78));
}

.ghost-btn {
  color: rgba(17,24,32,0.84);
  background: rgba(255,255,255,0.16);
  backdrop-filter: blur(7px);
}

.tiny-links {
  display: flex;
  justify-content: center;
  align-items: end;
  gap: 8px;
  font-size: 0.74rem;
  color: var(--ink-muted);
  font-weight: 700;
}

.tiny-links a {
  color: inherit;
  text-decoration: none;
}

.desktop-ad-field {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.ad-slot {
  pointer-events: auto;
  position: relative;
  width: var(--ad-w);
  height: var(--ad-h);
  padding: 19px 22px;
  border-radius: 24px;
  border: 1px solid rgba(17,24,32,0.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.23), rgba(255,255,255,0.10)),
    rgba(17,24,32,0.055);
  color: rgba(17,24,32,0.90);
  backdrop-filter: blur(8px);
  overflow: hidden;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.35),
    0 20px 50px rgba(17,24,32,0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.ad-tag {
  font-size: 1.02rem;
  font-weight: 950;
  letter-spacing: 0.18em;
}

.ad-copy {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(17,24,32,0.52);
}

.desktop-ad-slot.ad-1 { position: absolute; top: var(--corner-gap); left: var(--corner-gap); }
.desktop-ad-slot.ad-2 { position: absolute; top: var(--corner-gap); right: var(--corner-gap); }
.desktop-ad-slot.ad-3 { position: absolute; bottom: var(--corner-gap); left: 50%; transform: translateX(-50%); width: var(--ad-w); height: var(--ad-h); }
.desktop-ad-slot.ad-4 { position: absolute; bottom: var(--corner-gap); left: var(--corner-gap); }
.desktop-ad-slot.ad-5 { position: absolute; bottom: var(--corner-gap); right: var(--corner-gap); }

.mobile-ad-rail {
  display: none;
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  flex-direction: column;
  gap: 12px;
}

.mobile-ad-rail-left { left: 5px; }
.mobile-ad-rail-right { right: 5px; }

.mobile-ad-slot {
  width: clamp(58px, 15vw, 86px);
  height: clamp(116px, 24vh, 150px);
  padding: 10px 7px;
  text-align: center;
  align-items: center;
}

.mobile-ad-slot .ad-tag { font-size: 0.78rem; letter-spacing: 0.08em; }
.mobile-ad-slot .ad-copy { font-size: 0.57rem; }

@keyframes markPop {
  0% { transform: scale(0.4); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 1320px) {
  :root { --ad-w: clamp(290px, 23vw, 360px); --ad-h: clamp(116px, 13vh, 150px); }
}

@media (max-width: 1100px) {
  .desktop-ad-field { display: none; }
  .mobile-ad-rail { display: flex; }
  .stage { padding-left: 94px; padding-right: 94px; }
}

@media (max-width: 780px) {
  :root { --layout-w: min(92vw, 640px); }
  .boat-topline { flex-direction: column; }
  .boat-body { grid-template-columns: 1fr; }
  .board-wrap { width: min(100%, 360px); margin: 0 auto; }
  .stage { padding-left: 82px; padding-right: 82px; }
}

@media (max-width: 560px) {
  .stage { padding-left: 66px; padding-right: 66px; }
  .mobile-ad-rail-left { left: 3px; }
  .mobile-ad-rail-right { right: 3px; }
  .mobile-ad-slot { width: 58px; height: 112px; }
  .game-layout { padding: 18px 15px 14px; }
  h1 { font-size: clamp(1.75rem, 9vw, 2.45rem); }
  .challenge-line { font-size: 0.88rem; }
  .boat-actions { grid-template-columns: 1fr; }
}

@media (max-height: 760px) and (min-width: 1101px) {
  :root { --ad-h: 118px; --ad-w: 330px; }
  .game-layout { transform: scale(0.94); }
}
/* Desktop Adsterra 300x250 live banner sizing */
.desktop-ad-slot {
  width: 300px !important;
  height: 250px !important;
  padding: 0 !important;
  display: grid !important;
  place-items: center !important;
  overflow: hidden !important;
}

.desktop-ad-slot .ad-tag,
.desktop-ad-slot .ad-copy {
  display: none !important;
}

.ad-code {
  width: 300px;
  height: 250px;
  display: grid;
  place-items: center;
}

.ad-code iframe {
  width: 300px !important;
  height: 250px !important;
  border: 0 !important;
  display: block !important;
}