
:root {
  --text: #f7fbff;
  --muted: #d7e3eb;
  --glass: rgba(12, 26, 40, .70);
  --glass2: rgba(12, 26, 40, .84);
  --line: rgba(255,255,255,.14);
  --green: #29c873;
  --dark: #071321;
  --danger: #ff5b6e;
  --gold: #ffd447;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body {
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(3,10,18,.18), rgba(3,10,18,.72)),
    url("assets/branding/wtrmln-bg.png") center / cover fixed no-repeat;
}

body::before {
  content:"";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at top, rgba(255,255,255,.10), transparent 34%);
  pointer-events:none;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  min-height: 92px;
  padding: 14px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(10, 28, 42, .62);
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0,0,0,.24);
}

.brand { display: flex; gap: 16px; align-items: center; }
.logo { width: 180px; max-width: 38vw; height: auto; object-fit: contain; filter: drop-shadow(0 10px 18px rgba(0,0,0,.28)); }
.brand span { display: block; font-size: .76rem; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.brand strong { display: block; font-size: 1.22rem; margin-top: 4px; }

.topActions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.11);
  color: var(--text);
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
}

.menuButton {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.11);
  cursor: pointer;
}
.menuButton span {
  display: block;
  width: 19px;
  height: 2px;
  margin: 2px 0;
  border-radius: 99px;
  background: var(--text);
}

.layout {
  margin-top: 20px;
  display: grid;
  grid-template-columns: minmax(320px, 450px) 1fr;
  gap: 20px;
  align-items: start;
}

.phone {
  position: relative;
  aspect-ratio: 9/16;
  width: 100%;
  max-width: 450px;
  border-radius: 34px;
  overflow: hidden;
  background: rgba(5, 14, 26, .35);
  border: 1px solid var(--line);
  box-shadow: 0 32px 90px rgba(0,0,0,.34);
}

canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

.hud {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  pointer-events: none;
}
.hud div {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(8, 19, 31, .76);
  border: 1px solid rgba(255,255,255,.13);
  backdrop-filter: blur(10px);
}
.hud span { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
.hud b { display:block; margin-top: 3px; font-size: 1.2rem; }

.status {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(10, 24, 38, .80);
  border: 1px solid rgba(255,255,255,.14);
  backdrop-filter: blur(10px);
  font-weight: 700;
  white-space: nowrap;
}

.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 13, 24, .22);
  backdrop-filter: blur(6px);
}

.hidden { display: none !important; }

.card {
  width: min(100%, 680px);
  border-radius: 28px;
  padding: 26px;
  background: var(--glass2);
  border: 1px solid var(--line);
  box-shadow: 0 22px 60px rgba(0,0,0,.28);
  backdrop-filter: blur(18px);
}
.phone .card { max-width: 360px; }

.label {
  display: inline-flex;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.09);
  border: 1px solid rgba(255,255,255,.13);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .73rem;
  font-weight: 700;
}
h1, h2 { margin: 14px 0 12px; line-height: 1.04; }
h1 { font-size: clamp(2.3rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.8rem, 3vw, 2.55rem); }
p { color: var(--muted); line-height: 1.55; }
ul { color: var(--muted); line-height: 1.65; padding-left: 20px; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }
button.primary, button.secondary {
  border: 0;
  border-radius: 16px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.primary { background: linear-gradient(180deg, #39e084, #189b55); color: #052313; }
.secondary { background: rgba(255,255,255,.11); color: var(--text); border: 1px solid rgba(255,255,255,.13) !important; }
small { color: var(--muted); display: block; margin-top: 10px; }

.count {
  width: 170px;
  height: 170px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 4rem;
  font-weight: 900;
  background: rgba(255,255,255,.13);
  border: 1px solid var(--line);
  backdrop-filter: blur(18px);
}

.info { display: grid; gap: 20px; }
.rows { display: grid; gap: 10px; margin-top: 16px; }
.rows div {
  display:flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.11);
}
.rows span { color: var(--muted); }
.rewardBadge {
  margin: 16px 0 14px;
  padding: 16px 18px;
  border-radius: 18px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 900;
  background: rgba(41,200,115,.17);
  border: 1px solid rgba(41,200,115,.32);
}
.coupon {
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px dashed rgba(255,255,255,.23);
  background: rgba(255,255,255,.08);
}
.coupon span { color: var(--muted); text-transform: uppercase; letter-spacing: .09em; font-size: .75rem; display:block; }
.coupon b { display:block; margin-top: 8px; font-size: 2rem; letter-spacing: .07em; }
.special {
  color: #fff4bc;
  background: rgba(255,212,71,.12);
  border: 1px solid rgba(255,212,71,.25);
  padding: 12px 14px;
  border-radius: 14px;
}


.briefIntro { margin-bottom: 16px; }

.briefGrid {
  display: grid;
  gap: 10px;
  margin: 16px 0 18px;
}
.briefGrid div {
  padding: 14px 15px;
  border-radius: 16px;
  background: rgba(255,255,255,.075);
  border: 1px solid rgba(255,255,255,.12);
}
.briefGrid b {
  display: block;
  margin-bottom: 6px;
}
.briefGrid span {
  display: block;
  color: var(--muted);
  line-height: 1.45;
  font-size: .94rem;
}

.menuOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: block;
}
.menuBackdrop {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(2, 8, 14, .54);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.menuPanel {
  position: absolute;
  top: 14px;
  right: 14px;
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - 28px);
  overflow: auto;
  padding: 22px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(10, 25, 40, .92);
  box-shadow: 0 28px 90px rgba(0,0,0,.45);
  backdrop-filter: blur(22px);
}
.menuHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.closeButton {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.09);
  color: var(--text);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
}
.menuPanel h2 {
  margin-top: 16px;
}
.menuList {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}
.menuList button {
  width: 100%;
  text-align: left;
  padding: 15px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.075);
  color: var(--text);
  cursor: pointer;
}
.menuList b {
  display: block;
  margin-bottom: 4px;
}
.menuList span {
  color: var(--muted);
  font-size: .92rem;
}
.menuRewardBox {
  display: grid;
  gap: 9px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid rgba(41,200,115,.24);
  background: rgba(41,200,115,.09);
}
.menuRewardBox div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.menuRewardBox div:last-of-type { border-bottom: 0; }
.menuRewardBox span, .menuRewardBox small { color: var(--muted); }


@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .phone { margin: 0 auto; }
}
@media (max-width: 560px) {
  .page { padding: 10px; }
  .topbar { border-radius: 20px; min-height: 76px; }
  .logo { width: 130px; }
  .brand div { display:none; }
  .pill { padding: 11px 13px; font-size: .9rem; }
  .menuButton { width: 45px; height: 45px; }
  .phone { border-radius: 24px; }
  .screen { padding: 18px; }
  .card { padding: 20px; border-radius: 22px; }
  .phone .card { max-width: 330px; }
  .actions button { width: 100%; }
  .hud { gap: 7px; top: 10px; left: 10px; right: 10px; }
  .hud div { padding: 8px 9px; }
}


/* MOBILE-FIX: compact high-end briefing and practical burger menu */
.compactBrief {
  max-width: 338px;
  padding: 22px;
}

.compactBrief h2 {
  font-size: clamp(2rem, 8vw, 2.7rem);
  margin-bottom: 10px;
}

.compactBrief .briefIntro {
  margin-bottom: 13px;
  line-height: 1.45;
}

.compactRules {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 0 14px;
}

.compactRules div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 13px;
  border-radius: 15px;
}

.compactRules b {
  margin: 0;
}

.compactRules span {
  font-size: .92rem;
  line-height: 1.2;
}

.fixedActions {
  margin-top: 12px;
}

.menuPanel {
  width: min(365px, calc(100vw - 24px));
  padding: 22px;
}

.menuQuickRules {
  display: grid;
  gap: 10px;
  margin: 17px 0;
}

.menuQuickRules div {
  padding: 14px 15px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.075);
}

.menuQuickRules b {
  display: block;
  margin-bottom: 4px;
}

.menuQuickRules span {
  color: var(--muted);
}

.menuActions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.menuActions button {
  width: 100%;
}

.menuHint {
  margin-top: 14px;
  line-height: 1.45;
}

.menuList,
.menuRewardBox {
  display: none !important;
}

@media (max-width: 560px) {
  .screen {
    padding: 18px;
    align-items: center;
  }

  .compactBrief {
    padding: 20px;
    max-width: 320px;
  }

  .compactBrief h2 {
    font-size: 2.05rem;
  }

  .compactBrief .briefIntro {
    font-size: .98rem;
    margin-bottom: 10px;
  }

  .compactRules {
    gap: 7px;
    margin: 10px 0 12px;
  }

  .compactRules div {
    padding: 10px 12px;
  }

  .fixedActions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .fixedActions button {
    width: 100%;
    padding: 13px 16px;
  }

  .menuPanel {
    top: 10px;
    right: 10px;
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    border-radius: 24px;
  }
}


/* RESPONSIVE-CREDITS FINAL PATCH */
.credits {
  margin: 18px 0 4px;
  padding: 14px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(10, 28, 42, .52);
  backdrop-filter: blur(14px);
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: .9rem;
}

.hud {
  z-index: 5;
}

.status {
  z-index: 6;
  bottom: 112px;
  max-width: calc(100% - 36px);
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: .9rem;
  pointer-events: none;
}

@media (max-width: 980px) {
  .page {
    max-width: 460px;
  }

  .layout {
    margin-top: 14px;
  }

  .phone {
    width: min(100%, calc((100svh - 104px) * 9 / 16));
    max-width: 100%;
    margin: 0 auto;
  }

  .info {
    margin-top: 12px;
  }
}

@media (max-width: 560px) {
  body {
    overflow-x: hidden;
  }

  .page {
    padding: 7px;
    max-width: 100%;
  }

  .topbar {
    min-height: 72px;
    padding: 10px 12px;
    position: sticky;
    top: 6px;
    z-index: 20;
  }

  .layout {
    margin-top: 10px;
  }

  .phone {
    width: min(100%, calc((100svh - 92px) * 9 / 16));
    min-height: 0;
    margin-inline: auto;
  }

  .hud {
    top: 8px;
    left: 8px;
    right: 8px;
    gap: 6px;
  }

  .hud div {
    padding: 7px 8px;
    border-radius: 13px;
  }

  .hud span {
    font-size: .64rem;
  }

  .hud b {
    font-size: 1.02rem;
  }

  .status {
    bottom: 92px;
    padding: 8px 12px;
    font-size: .78rem;
    border-radius: 999px;
  }

  .screen {
    padding: 14px;
  }

  .compactBrief {
    max-width: 310px;
    padding: 18px;
  }

  .info {
    margin-top: 10px;
  }

  .info .card {
    padding: 18px;
  }

  .credits {
    margin-top: 12px;
    padding: 12px 14px;
    flex-direction: column;
    gap: 4px;
    font-size: .78rem;
    text-align: center;
  }
}

@media (max-height: 740px) and (max-width: 560px) {
  .topbar {
    min-height: 64px;
  }

  .logo {
    width: 118px;
  }

  .pill {
    padding: 9px 11px;
  }

  .menuButton {
    width: 42px;
    height: 42px;
  }

  .phone {
    width: min(100%, calc((100svh - 82px) * 9 / 16));
  }

  .status {
    bottom: 82px;
  }
}


/* PERFECT-MOBILE UPGRADE */
html {
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

button, canvas {
  user-select: none;
  -webkit-user-select: none;
}

.page {
  padding-left: max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}

.phone {
  background:
    linear-gradient(180deg, rgba(3,10,18,.18), rgba(3,10,18,.18)),
    url("assets/branding/wtrmln-bg.png") center / cover no-repeat;
}

canvas {
  image-rendering: auto;
}

@media (max-width: 720px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .info {
    display: none;
  }

  .phone {
    width: min(100%, calc((100svh - 90px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 9 / 16));
    max-height: calc(100svh - 90px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    box-shadow: 0 20px 70px rgba(0,0,0,.36);
  }

  .credits {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
  }
}

@media (max-width: 420px) {
  .page {
    padding-top: max(6px, env(safe-area-inset-top));
  }

  .topbar {
    width: min(100%, 420px);
    margin-left: auto;
    margin-right: auto;
  }

  .logo {
    width: 126px;
  }

  .phone {
    border-radius: 22px;
  }

  .card {
    box-shadow: 0 18px 45px rgba(0,0,0,.32);
  }

  .coupon b {
    font-size: 1.8rem;
  }
}


/* APPLE-SAFE PATCH
   iOS Safari handles viewport height and fixed touch areas differently.
   This patch keeps page scrolling possible while blocking touch scroll only on the game canvas during active gameplay. */

html,
body {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body {
  position: relative;
  overscroll-behavior-y: auto;
}

.page {
  min-height: var(--app-height, 100dvh);
  overflow: visible;
}

.layout,
.phone,
.info,
.credits {
  flex-shrink: 0;
}

/* Screens inside the phone can scroll if a small iPhone viewport clips a button. */
.screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
}

.screen .card {
  margin-top: auto;
  margin-bottom: auto;
}

/* The canvas itself should not scroll the page during gameplay. */
canvas {
  touch-action: none;
}

/* Menus need their own iOS scroll area. */
.menuOverlay {
  overflow: hidden;
}

.menuPanel {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

/* iOS-specific viewport fallback. */
@supports (-webkit-touch-callout: none) {
  .page {
    min-height: var(--app-height, 100vh);
  }

  @media (max-width: 720px) {
    .phone {
      width: min(100%, calc((var(--app-height, 100vh) - 92px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 9 / 16));
      max-height: calc(var(--app-height, 100vh) - 92px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
  }

  @media (max-height: 740px) and (max-width: 560px) {
    .phone {
      width: min(100%, calc((var(--app-height, 100vh) - 82px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 9 / 16));
      max-height: calc(var(--app-height, 100vh) - 82px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }

    .compactBrief {
      padding: 16px;
    }

    .compactRules div {
      padding: 9px 11px;
    }

    .fixedActions button {
      padding: 12px 14px;
    }
  }
}

/* Very small iPhones: keep all interactive controls reachable. */
@media (max-width: 390px) and (max-height: 700px) {
  .topbar {
    min-height: 58px;
    padding: 8px 10px;
  }

  .logo {
    width: 110px;
  }

  .pill {
    padding: 8px 10px;
    font-size: .82rem;
  }

  .menuButton {
    width: 40px;
    height: 40px;
  }

  .compactBrief {
    max-width: 300px;
    padding: 15px;
  }

  .compactBrief h2 {
    font-size: 1.75rem;
    margin-bottom: 8px;
  }

  .compactBrief .briefIntro {
    font-size: .92rem;
  }

  .compactRules {
    gap: 6px;
  }

  .fixedActions {
    gap: 7px;
  }
}


/* UNIVERSAL FINAL v2: Start credit + mobile menu info hub */
.creatorTag {
  margin: 10px 0 0;
  color: rgba(247,251,255,.76);
  font-size: .78rem;
  line-height: 1.35;
  letter-spacing: .02em;
}

#startScreen .card {
  position: relative;
}

.menuInfoBlock {
  margin-top: 14px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.055);
}

.menuInfoBlock .label {
  margin-bottom: 10px;
}

.menuRows {
  display: grid;
  gap: 8px;
}

.menuRows div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.menuRows div:last-child {
  border-bottom: 0;
}

.menuRows b {
  color: var(--text);
}

.menuRows span {
  color: var(--muted);
  text-align: right;
}

.menuCredits {
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid rgba(255,255,255,.12);
  color: var(--muted);
  display: grid;
  gap: 4px;
  font-size: .84rem;
  line-height: 1.4;
}

.menuCredits b {
  color: var(--text);
}

@media (max-width: 560px) {
  .creatorTag {
    font-size: .72rem;
  }

  #startScreen h1 {
    margin-top: 10px;
  }

  .menuPanel {
    padding: 20px;
  }

  .menuPanel h2 {
    font-size: 1.9rem;
  }

  .menuInfoBlock {
    padding: 12px;
  }

  .menuRows div {
    font-size: .92rem;
  }

  .menuCredits {
    font-size: .78rem;
  }
}

@media (max-width: 390px) and (max-height: 700px) {
  .creatorTag {
    font-size: .68rem;
  }

  #startScreen .card {
    padding: 18px;
  }

  #startScreen h1 {
    font-size: 2rem;
  }

  #startScreen ul {
    margin: 8px 0;
  }
}
