:root {
  --bg: #172033;
  --panel: rgba(25, 35, 52, 0.88);
  --panel-strong: rgba(31, 43, 63, 0.98);
  --line: rgba(255, 255, 255, 0.13);
  --text: #f7f4ee;
  --muted: #aab3c2;
  --green: #4bd6a5;
  --yellow: #f4c75e;
  --red: #ef6a73;
  --blue: #65b7f5;
  --ink: #0e1725;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 18% 4%, rgba(101, 183, 245, 0.24), transparent 25rem),
    radial-gradient(circle at 92% 18%, rgba(244, 199, 94, 0.18), transparent 22rem),
    linear-gradient(145deg, #172033 0%, #1f2b3f 50%, #182f2b 100%);
  color: var(--text);
  overflow-x: hidden;
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  filter: saturate(0.5);
  opacity: 0.62;
}

.app-shell {
  width: min(100%, 480px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto minmax(440px, 1fr) auto auto;
  gap: 12px;
}

.topbar,
.score-strip,
  .mission-grid article,
  .leaderboard-card,
  .bottom-nav {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.topbar {
  min-height: 76px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
}

.brand-block {
  min-width: 0;
}

.eyebrow,
.mode-label {
  margin: 0 0 4px;
  color: var(--yellow);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 27px;
  line-height: 1.05;
}

.icon-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: rgba(75, 214, 165, 0.17);
  color: var(--green);
  font-size: 22px;
}

.score-strip {
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.score-strip div {
  min-width: 0;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
}

.score-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.score-strip strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: clamp(19px, 6.5vw, 29px);
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.office-wrap {
  position: relative;
  min-width: 0;
  min-height: 440px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.045) 1px, transparent 1px),
    #111c2b;
  background-size: 42px 42px;
  box-shadow: inset 0 0 90px rgba(75, 214, 165, 0.08), var(--shadow);
}

#gameCanvas {
  width: 100%;
  max-width: 100%;
  height: 100%;
  min-height: 440px;
  display: block;
  touch-action: none;
}

.float-panel {
  position: absolute;
  inset: auto 16px 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
}

.float-panel h2 {
  margin-bottom: 8px;
  font-size: 22px;
  line-height: 1.15;
}

.float-panel p,
.mission-grid p,
.leaderboard-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.primary-button,
.secondary-button,
.ghost-button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  width: 100%;
  margin-top: 14px;
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: var(--ink);
}

.secondary-button {
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.ghost-button {
  width: 100%;
  margin-top: 10px;
  border: 1px solid rgba(244, 199, 94, 0.32);
  background: rgba(244, 199, 94, 0.1);
  color: var(--yellow);
}

.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.result-actions .primary-button,
.result-actions .secondary-button {
  margin-top: 14px;
}

.hidden {
  display: none !important;
}

.mission-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.mission-grid article {
  min-height: 64px;
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.mission-grid strong {
  display: block;
  margin-bottom: 2px;
  font-size: 14px;
}

.mission-dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  flex: 0 0 auto;
  background: var(--yellow);
  box-shadow: 0 0 0 5px rgba(244, 199, 94, 0.14);
}

.mission-dot.done {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(75, 214, 165, 0.14);
}

.leaderboard-card {
  padding: 12px;
  border-radius: 8px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
}

.mini-button {
  min-height: 34px;
  padding: 0 12px;
  border-radius: 7px;
  background: rgba(101, 183, 245, 0.14);
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
}

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

.leaderboard-list li {
  min-width: 0;
  min-height: 38px;
  padding: 7px 8px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

.leaderboard-list span {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: rgba(244, 199, 94, 0.16);
  color: var(--yellow);
  font-size: 12px;
  font-weight: 850;
}

.leaderboard-list strong {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-list em {
  color: var(--green);
  font-style: normal;
  font-size: 13px;
  font-weight: 850;
}

.bottom-nav {
  min-height: 56px;
  padding: 7px;
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.bottom-nav button {
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.bottom-nav button.active {
  background: rgba(101, 183, 245, 0.16);
  color: var(--blue);
}

.ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 12, 19, 0.68);
  backdrop-filter: blur(10px);
}

.ad-card {
  width: min(100%, 320px);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  text-align: center;
}

.ad-card strong {
  display: block;
  font-size: 20px;
}

.ad-card span {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 16px auto 0;
  place-items: center;
  border-radius: 50%;
  background: rgba(75, 214, 165, 0.16);
  color: var(--green);
  font-size: 28px;
  font-weight: 900;
}

@media (min-width: 720px) {
  .app-shell {
    width: min(100%, 1040px);
    grid-template-columns: minmax(320px, 380px) minmax(420px, 1fr);
    grid-template-rows: auto auto 1fr auto;
    align-items: stretch;
    padding: 24px;
  }

  .topbar,
  .score-strip,
  .mission-grid,
  .leaderboard-card,
  .bottom-nav {
    grid-column: 1;
  }

  .office-wrap {
    grid-column: 2;
    grid-row: 1 / span 4;
    min-height: calc(100vh - 48px);
  }
}
