:root {
  --bg0: #070910;
  --bg1: #0b1020;
  --fg: #e9eefc;
  --muted: rgba(233, 238, 252, 0.74);
  --glass: rgba(16, 22, 38, 0.58);
  --glass2: rgba(16, 22, 38, 0.76);
  --border: rgba(233, 238, 252, 0.14);
  --shadow: rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--fg);
  background: radial-gradient(1200px 800px at 30% 15%, #1b2a5a 0%, rgba(27, 42, 90, 0) 60%),
    radial-gradient(1000px 700px at 85% 30%, rgba(218, 141, 255, 0.28) 0%, rgba(218, 141, 255, 0) 65%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  position: relative;
  isolation: isolate;
}

body.cyber {
  background: radial-gradient(1200px 800px at 30% 15%, rgba(120, 40, 255, 0.35) 0%, rgba(0, 0, 0, 0) 60%),
    radial-gradient(1000px 700px at 85% 30%, rgba(0, 220, 255, 0.22) 0%, rgba(0, 0, 0, 0) 65%),
    linear-gradient(180deg, #050510, #02020a);
}

.linkbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  border: 1px solid rgba(233, 238, 252, 0.22);
  background: rgba(233, 238, 252, 0.10);
  color: rgba(233, 238, 252, 0.95);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.linkbtn:hover {
  background: rgba(233, 238, 252, 0.14);
}

.linkbtn.primary {
  background: linear-gradient(180deg, rgba(255, 231, 120, 0.92), rgba(255, 185, 66, 0.90));
  border-color: rgba(255, 245, 205, 0.35);
  color: rgba(20, 16, 10, 0.95);
}

.linkbtn.primary:hover {
  filter: brightness(1.05);
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
}

@supports (height: 100svh) {
  #app {
    height: 100svh;
  }
}

@supports (height: 100dvh) {
  #app {
    height: 100dvh;
  }
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#gameFW {
  width: 100%;
  height: 100%;
  display: block;
}

#game3d {
  width: 100%;
  height: 100%;
  display: block;
}

#hud {
  position: absolute;
  left: 14px;
  top: 14px;
  display: flex;
  gap: 10px;
  z-index: 5;
  user-select: none;
  pointer-events: none;
}

.hudActions {
  position: absolute;
  right: max(14px, env(safe-area-inset-right));
  top: max(14px, env(safe-area-inset-top));
  z-index: 6;
  user-select: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

button.hudAction {
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 13px;
  min-width: 132px;
  border: 1px solid rgba(233, 238, 252, 0.28);
  background: rgba(16, 22, 38, 0.70);
  color: rgba(233, 238, 252, 0.98);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.65);
}

button.hudAction:hover {
  background: rgba(16, 22, 38, 0.78);
}

button.hudAction:active {
  transform: translateY(1px);
}

button.hudAction:focus-visible {
  outline: 2px solid rgba(233, 238, 252, 0.45);
  outline-offset: 2px;
}

button.hudAction:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.touchControls {
  position: absolute;
  inset: 0;
  z-index: 7;
  pointer-events: none;
  --joy-size: clamp(132px, 22vmin, 210px);
  --btn-w: clamp(112px, 24vw, 180px);
  --btn-h: clamp(58px, 9.5vh, 86px);
  --joy-x: 0px;
  --joy-y: 0px;
  user-select: none;
  touch-action: none;
}

.joy {
  position: absolute;
  left: max(18px, env(safe-area-inset-left));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: var(--joy-size);
  height: var(--joy-size);
  pointer-events: auto;
  touch-action: none;
}

.joyBase {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(16, 22, 38, 0.40);
  border: 1px solid rgba(233, 238, 252, 0.18);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.joyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(var(--joy-size) * 0.46);
  height: calc(var(--joy-size) * 0.46);
  border-radius: 999px;
  transform: translate(-50%, -50%) translate(var(--joy-x), var(--joy-y));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.10));
  border: 1px solid rgba(233, 238, 252, 0.22);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
}

.touchButtons {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: auto;
  touch-action: none;
}

.touchBtn {
  width: var(--btn-w);
  height: var(--btn-h);
  border-radius: 16px;
  font-weight: 900;
  letter-spacing: 0.6px;
  border: 1px solid rgba(233, 238, 252, 0.22);
  background: rgba(16, 22, 38, 0.55);
  color: rgba(233, 238, 252, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.touchBtn.jump {
  background: linear-gradient(180deg, rgba(255, 231, 120, 0.78), rgba(255, 185, 66, 0.55));
  border-color: rgba(255, 245, 205, 0.25);
  color: rgba(20, 16, 10, 0.95);
}

.pill {
  padding: 8px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 13px;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
  background: radial-gradient(1200px 800px at 50% 40%, rgba(10, 16, 35, 0.35), rgba(5, 7, 16, 0.85));
}

.card {
  width: min(860px, calc(100% - 24px));
  background: var(--glass2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.card h1 {
  margin: 0 0 6px;
  font-size: 26px;
  letter-spacing: 0.2px;
}

.card p {
  margin: 8px 0 12px;
  color: var(--muted);
  line-height: 1.45;
}

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

.grid h2 {
  margin: 0 0 8px;
  font-size: 14px;
  color: rgba(233, 238, 252, 0.92);
}

ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

li {
  margin: 6px 0;
}

kbd {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 8px;
  border: 1px solid rgba(233, 238, 252, 0.22);
  background: rgba(233, 238, 252, 0.08);
  color: rgba(233, 238, 252, 0.95);
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.end {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 10px 0 6px;
}

button {
  appearance: none;
  border: 1px solid rgba(233, 238, 252, 0.22);
  background: rgba(233, 238, 252, 0.10);
  color: rgba(233, 238, 252, 0.95);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.2px;
}

button:hover {
  background: rgba(233, 238, 252, 0.14);
}

button.primary {
  background: linear-gradient(180deg, rgba(255, 231, 120, 0.92), rgba(255, 185, 66, 0.90));
  border-color: rgba(255, 245, 205, 0.35);
  color: rgba(20, 16, 10, 0.95);
}

button.primary:hover {
  filter: brightness(1.05);
}

.fineprint {
  margin: 12px 0 0;
  font-size: 12px;
  opacity: 0.75;
}

.hub .overlay {
  background: radial-gradient(1200px 800px at 50% 40%, rgba(10, 16, 35, 0.25), rgba(5, 7, 16, 0.88));
}

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

.tile {
  border: 1px solid rgba(233, 238, 252, 0.14);
  background: rgba(16, 22, 38, 0.35);
  border-radius: 14px;
  padding: 14px 14px 12px;
}

.tile h2 {
  margin: 0 0 6px;
  font-size: 18px;
}

.tile p {
  margin: 0 0 10px;
  color: var(--muted);
}

.tile.firewater {
  border-color: rgba(120, 220, 255, 0.22);
  background: linear-gradient(180deg, rgba(20, 40, 60, 0.35), rgba(45, 20, 30, 0.24));
}

body.firewater {
  background: radial-gradient(1200px 800px at 24% 22%, rgba(255, 95, 60, 0.28) 0%, rgba(255, 95, 60, 0) 62%),
    radial-gradient(1000px 700px at 82% 32%, rgba(40, 210, 255, 0.22) 0%, rgba(40, 210, 255, 0) 65%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

body.millionaire {
  background: radial-gradient(1200px 800px at 24% 22%, rgba(255, 200, 60, 0.18) 0%, rgba(255, 200, 60, 0) 62%),
    radial-gradient(1000px 700px at 82% 32%, rgba(120, 120, 255, 0.18) 0%, rgba(120, 120, 255, 0) 65%),
    linear-gradient(180deg, var(--bg1), var(--bg0));
}

body.millionaire::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("./milyoner-bg.jpg");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  opacity: 0.35;
  filter: saturate(1.05) contrast(1.05);
  transform: scale(1.02);
  z-index: -1;
  pointer-events: none;
}

.millionaireCard {
  width: min(1020px, calc(100% - 24px));
}

.millionaireTop {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.millionaireLayout {
  display: flex;
  gap: 14px;
  align-items: stretch;
  margin-top: 10px;
}

.millionaireMain {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 12px;
}

.pill[data-tone="good"] {
  border-color: rgba(120, 255, 170, 0.28);
  background: rgba(40, 120, 70, 0.28);
}

.pill[data-tone="bad"] {
  border-color: rgba(255, 120, 140, 0.28);
  background: rgba(120, 35, 45, 0.30);
}

.questionBox {
  border: 1px solid rgba(233, 238, 252, 0.14);
  background: rgba(16, 22, 38, 0.35);
  border-radius: 14px;
  padding: 12px;
}

.questionMeta {
  font-size: 12px;
  color: rgba(233, 238, 252, 0.72);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.questionMeta .timer {
  font-weight: 800;
  letter-spacing: 0.2px;
  color: rgba(233, 238, 252, 0.82);
}

.questionMeta .timer[data-urgent="true"] {
  color: rgba(255, 120, 140, 0.95);
}

.questionText {
  margin: 0 0 10px;
  font-size: 18px;
  line-height: 1.35;
}

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choiceBtn {
  width: 100%;
  text-align: left;
  padding: 12px 12px;
  border-radius: 12px;
}

.choiceBtn.correct {
  border-color: rgba(120, 255, 170, 0.35);
  background: rgba(40, 120, 70, 0.30);
}

.choiceBtn.wrong {
  border-color: rgba(255, 120, 140, 0.35);
  background: rgba(120, 35, 45, 0.34);
}

.choiceBtn.dimmed {
  opacity: 0.45;
}

.choiceBtn.suggested {
  outline: 2px solid rgba(255, 231, 120, 0.65);
  outline-offset: 2px;
}

.lifelines {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.lifelines button.used {
  opacity: 0.55;
}

.moneyLadder {
  width: 260px;
  border: 1px solid rgba(233, 238, 252, 0.14);
  background: rgba(16, 22, 38, 0.26);
  border-radius: 14px;
  padding: 12px;
}

.ladderTitle {
  font-size: 12px;
  color: rgba(233, 238, 252, 0.72);
  margin-bottom: 8px;
}

.ladder {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.ladderItem {
  padding: 10px 10px;
  border-radius: 12px;
  border: 1px solid rgba(233, 238, 252, 0.14);
  background: rgba(16, 22, 38, 0.26);
  font-weight: 700;
  font-size: 13px;
}

.ladderItem.passed {
  opacity: 0.55;
}

.ladderItem.current {
  border-color: rgba(255, 231, 120, 0.40);
  background: linear-gradient(180deg, rgba(255, 231, 120, 0.20), rgba(255, 185, 66, 0.12));
}

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

  .tiles {
    grid-template-columns: 1fr;
  }

  .millionaireLayout {
    flex-direction: column;
  }

  .moneyLadder {
    width: 100%;
  }

  .choices {
    grid-template-columns: 1fr;
  }
}
