:root {
  --page-bg: #111827;
  --panel-bg: rgba(17, 24, 39, 0.92);
  --line: rgba(255, 255, 255, 0.14);
  --text: #f9fafb;
  --muted: #9ca3af;
  --accent: #f97316;
  --gold: #facc15;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  justify-content: center;
}

#appShell {
  width: min(100vw, 520px);
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: #020617;
  position: relative;
  overflow: hidden;
}

#gameViewport {
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  position: relative;
}

#stage {
  display: block;
  background: #fff;
  touch-action: none;
}

.ad-slot {
  width: 100%;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(2, 6, 23, 0.94);
  color: var(--muted);
  font-size: 12px;
}

.ad-slot[hidden] {
  display: none;
}

.ad-slot-placeholder {
  border-style: dashed;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ad-action-panel {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 88px;
  z-index: 20;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-bg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.4);
}

.ad-action-panel[hidden] {
  display: none;
}

.ad-action-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}

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

.ad-action-grid button,
.mock-ad-card button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  color: #111827;
  background: var(--gold);
  font-weight: 700;
  cursor: pointer;
}

.ad-action-grid button:first-child {
  background: var(--accent);
  color: #fff;
}

#plainReplayBtn {
  grid-column: 1 / -1;
  background: #374151;
  color: #fff;
}

.ad-action-grid button:disabled,
.mock-ad-card button:disabled {
  opacity: 0.55;
  cursor: default;
}

#adStatus {
  min-height: 18px;
  margin: 8px 0 0;
  color: #fecaca;
  font-size: 12px;
  text-align: center;
}

.mock-ad-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.68);
}

.mock-ad-overlay[hidden] {
  display: none;
}

.mock-ad-card {
  width: min(300px, 100%);
  padding: 20px;
  border-radius: 12px;
  background: #111827;
  border: 1px solid var(--line);
  text-align: center;
}

.mock-ad-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.mock-ad-count {
  margin: 12px auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #0f172a;
  color: var(--gold);
  font-size: 32px;
  font-weight: 700;
}

@media (max-height: 700px) {
  .ad-slot {
    min-height: 56px;
  }

  .ad-action-panel {
    bottom: 64px;
  }
}
