html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background:
    radial-gradient(1200px 600px at 50% -10%, #1a2744 0%, transparent 55%),
    #050508;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  position: fixed;
  inset: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  box-sizing: border-box;
}

.phone-bezel {
  --bezel-pad: 12px;
  width: var(--phone-w, min(100vw - 24px, 420px));
  height: var(--phone-h, auto);
  aspect-ratio: 390 / 844;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 100%);
  border-radius: 44px;
  padding: var(--bezel-pad);
  box-shadow:
    0 0 0 2px #222,
    0 24px 64px rgba(0, 0, 0, 0.65),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  box-sizing: border-box;
  position: relative;
  flex: 0 0 auto;
}

.phone-bezel::before {
  content: "";
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 96px;
  height: 22px;
  background: #000;
  border-radius: 0 0 14px 14px;
  z-index: 2;
  pointer-events: none;
}

/* Mobile / fullscreen: fill viewport, drop fake bezel chrome */
body.is-mobile .phone-bezel,
body.is-fullscreen .phone-bezel {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  aspect-ratio: auto;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  background: #000;
}

body.is-mobile .phone-bezel::before,
body.is-fullscreen .phone-bezel::before {
  display: none;
}

/* Mobile but not fullscreen yet: keep a fitted phone frame */
body.is-mobile:not(.is-fullscreen) .phone-bezel {
  width: var(--phone-w);
  height: var(--phone-h);
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  aspect-ratio: 390 / 844;
  border-radius: 36px;
  padding: 10px;
  box-shadow:
    0 0 0 2px #222,
    0 16px 40px rgba(0, 0, 0, 0.55);
  background: linear-gradient(145deg, #1a1a1a 0%, #0a0a0a 100%);
}

body.is-mobile:not(.is-fullscreen) .phone-bezel::before {
  display: block;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 32px;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

body.is-mobile .phone-bezel #screen,
body.is-fullscreen .phone-bezel #screen {
  border-radius: 0;
}

body.is-mobile:not(.is-fullscreen) .phone-bezel #screen {
  border-radius: 26px;
}

/* Landscape mobile: tighter padding so canvas stays usable */
body.is-mobile.is-landscape:not(.is-fullscreen) {
  padding: 4px;
}

body.is-mobile.is-landscape:not(.is-fullscreen) .phone-bezel {
  max-width: calc(100vw - 8px);
  max-height: calc(100dvh - 8px);
  border-radius: 28px;
  padding: 8px;
}

body.is-mobile.is-landscape:not(.is-fullscreen) .fs-btn {
  top: calc(8px + env(safe-area-inset-top));
  padding: 10px 14px;
  font-size: 13px;
}

/* En haut : avant ça recouvrait la barre home en bas sur téléphone */
.fs-btn {
  position: fixed;
  z-index: 50;
  top: calc(12px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font: 600 14px system-ui, sans-serif;
  color: #fff;
  background: rgba(91, 140, 255, 0.95);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.fs-btn[hidden],
body.is-fullscreen .fs-btn,
body:not(.is-mobile) .fs-btn {
  display: none !important;
}

/* bobpk HTML runner — client-side iframe over the phone bezel */
.bobpk-runner {
  position: absolute;
  inset: var(--bezel-pad, 12px);
  border-radius: 32px;
  overflow: hidden;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: #0b0f1a;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

body.is-mobile .bobpk-runner,
body.is-fullscreen .bobpk-runner {
  inset: 0;
  border-radius: 0;
}

.bobpk-runner.hidden {
  display: none !important;
}

.bobpk-runner-bar {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: rgba(18, 26, 46, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #e8ecf4;
  font: 600 14px system-ui, sans-serif;
}

.bobpk-runner-back {
  border: 0;
  background: transparent;
  color: #5b8cff;
  font: 700 28px/1 system-ui, sans-serif;
  padding: 0 8px;
  cursor: pointer;
}

.bobpk-runner-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bobpk-runner-badge {
  font: 600 10px system-ui, sans-serif;
  color: #8b95a8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bobpk-runner-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

body.bobpk-open #screen {
  visibility: hidden;
}

/* WebBOBView — system web surface */
.webbobview {
  position: absolute;
  inset: var(--bezel-pad, 12px);
  border-radius: 28px;
  overflow: hidden;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: #0b0f1a;
}

body.is-mobile .webbobview,
body.is-fullscreen .webbobview {
  inset: 0;
  border-radius: 0;
}

.webbobview.hidden {
  display: none !important;
}

.webbobview-bar {
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  background: rgba(18, 26, 46, 0.98);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #e8ecf4;
  font: 600 14px system-ui, sans-serif;
}

.webbobview-back {
  border: 0;
  background: transparent;
  color: #5b8cff;
  font: 700 28px/1 system-ui, sans-serif;
  padding: 0 8px;
  cursor: pointer;
}

.webbobview-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.webbobview-badge {
  font: 600 10px system-ui, sans-serif;
  color: #8b95a8;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.webbobview-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

body.webbobview-open #screen {
  visibility: hidden;
}
