:root {
  color-scheme: dark;
  --black: #08090c;
  --panel: rgba(14, 17, 23, .94);
  --line: #3c414c;
  --gold: #e2b653;
  --gold-soft: #ffe2a0;
  --text: #f5f6f8;
  --muted: #a6adba;
  --green: #46d48f;
  --red: #ff5d61;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--black); font-family: Inter, Arial, sans-serif; }
button, a { font: inherit; }
button { cursor: pointer; }

#canvas { width: 100vw; height: 100vh; display: block; outline: 0; image-rendering: pixelated; background: #10141a; }
#status { position: fixed; z-index: 4; top: 88px; left: 18px; color: #d9dee7; pointer-events: none; }
#start-game { position: fixed; z-index: 9; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 13px 28px; border: 1px solid #9f7b35; border-radius: 9px; color: var(--gold-soft); background: #171a20; font-weight: 800; box-shadow: 0 18px 60px #000; }
#game-error { position: fixed; z-index: 20; left: 16px; right: 16px; bottom: 108px; padding: 11px; border: 1px solid #a54848; background: #35191b; color: #ffdada; }

.stream-status { position: fixed; z-index: 8; top: 12px; left: 50%; transform: translateX(-50%); min-width: min(620px, calc(100% - 30px)); height: 58px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; border: 1px solid rgba(226, 182, 83, .34); border-radius: 14px; background: rgba(7, 9, 12, .88); backdrop-filter: blur(15px); box-shadow: 0 12px 35px rgba(0, 0, 0, .38); }
.pythera-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #8f702e; border-radius: 50%; color: var(--gold-soft); font: 23px Georgia; background: #18130b; }
.stream-status > div { display: grid; }
.stream-status small { color: var(--gold); font-size: 9px; letter-spacing: .18em; }
.stream-status strong { color: var(--text); font-size: 13px; }
.live-dot { width: 9px; height: 9px; margin-left: auto; border-radius: 50%; background: #68707d; }
.live-dot.on { background: var(--red); box-shadow: 0 0 0 5px rgba(255, 93, 97, .15); }
#viewer-count { color: var(--muted); font-size: 11px; }
.room-chip { padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #171a20; font-size: 10px; }
.room-chip b { color: var(--gold-soft); letter-spacing: .12em; }

.facecam { position: fixed; z-index: 7; top: 88px; right: 18px; width: 220px; aspect-ratio: 16/9; overflow: hidden; border: 2px solid var(--gold); border-radius: 12px; background: #11151b; box-shadow: 0 18px 45px rgba(0, 0, 0, .55); touch-action: none; }
.facecam video { width: 100%; height: 100%; display: block; object-fit: cover; transform: scaleX(-1); }
.facecam-off { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 7px; color: var(--muted); background: radial-gradient(circle, #262d38, #101318); }
.facecam-off span { font-size: 25px; filter: grayscale(1); }
.facecam.off video { visibility: hidden; }
.facecam:not(.off) .facecam-off { display: none; }
.facecam #hide-facecam { position: absolute; top: 5px; right: 5px; width: 24px; height: 24px; border: 0; border-radius: 50%; color: white; background: rgba(0, 0, 0, .64); }
.drag-hint { position: absolute; left: 7px; bottom: 5px; padding: 3px 6px; border-radius: 5px; color: #ddd; background: rgba(0, 0, 0, .58); font-size: 8px; letter-spacing: .1em; text-transform: uppercase; }

.stream-panel { position: fixed; z-index: 10; right: 18px; bottom: 112px; width: 310px; padding: 15px; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: var(--panel); backdrop-filter: blur(18px); box-shadow: 0 20px 60px #000; }
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head > div { display: grid; gap: 2px; }
.panel-head small { color: var(--gold); font-size: 9px; letter-spacing: .15em; }
.panel-head button { border: 0; color: var(--muted); background: transparent; font-size: 22px; }
#stream-message { min-height: 35px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.panel-row { padding: 10px 0; display: flex; justify-content: space-between; border-top: 1px solid #2c3038; font-size: 11px; }
.panel-row b { color: #bcc4d0; }
#download-recording { margin-top: 10px; padding: 10px; display: block; border-radius: 8px; color: #bdf3d8; background: #18382a; text-align: center; text-decoration: none; font-size: 11px; font-weight: 800; }

.stream-dock { position: fixed; z-index: 9; left: 50%; bottom: 16px; transform: translateX(-50%); padding: 7px; display: flex; align-items: stretch; gap: 6px; border: 1px solid rgba(226, 182, 83, .38); border-radius: 14px; background: rgba(7, 9, 12, .91); backdrop-filter: blur(18px); box-shadow: 0 16px 50px rgba(0, 0, 0, .6); }
.macro-button { width: 94px; min-height: 68px; padding: 6px; display: grid; place-items: center; align-content: center; gap: 2px; border: 1px solid #353b45; border-radius: 9px; color: var(--muted); background: linear-gradient(#1e232b, #12151a); }
.macro-button .icon { font-size: 20px; filter: grayscale(1); }
.macro-button small { font-size: 10px; }
.macro-button i { color: #7c8491; font-size: 8px; font-style: normal; font-weight: 900; }
.macro-button[aria-pressed="true"] { border-color: #a47e31; color: var(--gold-soft); background: linear-gradient(#2b261c, #17150f); box-shadow: inset 0 0 0 1px rgba(226, 182, 83, .18); }
.macro-button[aria-pressed="true"] .icon { filter: none; }
.macro-button[aria-pressed="true"] i { color: var(--green); }
.macro-button:disabled { cursor: not-allowed; opacity: .58; }
.privacy-control:disabled { opacity: .42; }
.macro-button.locked::after { content: "🔒"; position: absolute; margin: -50px 0 0 68px; font-size: 9px; }
.macro-button.compact { width: 65px; }
.tutorial-trigger .icon { width: 21px; height: 21px; display: grid; place-items: center; border: 1px solid #747b87; border-radius: 50%; font: 800 13px Georgia; }
.live-button { min-width: 142px; border: 1px solid #823a3d; border-radius: 9px; color: #ffd8d9; background: linear-gradient(#4a2023, #2d1517); font-size: 12px; font-weight: 900; }
.live-button span { color: var(--red); }
.live-button.on { border-color: #b74348; background: linear-gradient(#6c272c, #3c171a); }
.prototype-note { position: fixed; z-index: 6; left: 13px; bottom: 9px; color: rgba(255, 255, 255, .38); font-size: 8px; letter-spacing: .12em; pointer-events: none; }
.camera-setup { display: none; }
.camera-viewer-guide { display: none; }
.tutorial-backdrop { position: fixed; z-index: 30; inset: 0; background: rgba(2, 4, 7, .76); backdrop-filter: blur(2px); }
.tutorial-card { position: fixed; z-index: 50; width: min(360px, calc(100% - 24px)); padding: 20px; border: 1px solid rgba(226, 182, 83, .64); border-radius: 15px; color: var(--text); background: #11151b; box-shadow: 0 24px 80px #000; }
.tutorial-card small { color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: .16em; }
.tutorial-card h2 { margin: 8px 28px 8px 0; color: var(--gold-soft); font: 700 20px Georgia, serif; }
.tutorial-card p { min-height: 58px; margin: 0 0 16px; color: #c3cad5; font-size: 12px; line-height: 1.55; }
.tutorial-close { position: absolute; top: 9px; right: 10px; width: 30px; height: 30px; border: 0; border-radius: 50%; color: #d8dde6; background: #242a33; font-size: 20px; }
.tutorial-actions { display: flex; justify-content: space-between; gap: 10px; }
.tutorial-actions button { min-width: 94px; padding: 10px 14px; border: 1px solid #4a515e; border-radius: 8px; color: #d7dde7; background: #222831; font-size: 11px; font-weight: 800; }
.tutorial-actions #tutorial-next { margin-left: auto; border-color: #9f7b35; color: #1a1408; background: var(--gold); }
.tutorial-zone { z-index: 40 !important; }
.tutorial-focus { position: relative; outline: 3px solid var(--gold) !important; outline-offset: 5px; box-shadow: 0 0 0 9px rgba(226, 182, 83, .18), 0 0 34px rgba(226, 182, 83, .55) !important; }
.tutorial-open .tutorial-zone, .tutorial-open .tutorial-focus { pointer-events: none; }
[hidden] { display: none !important; }

@media (max-width: 760px) {
  .stream-status { min-width: calc(100% - 16px); top: 8px; height: 50px; }
  #viewer-count { display: none; }
  .facecam { top: 70px; right: 9px; width: 150px; }
  .stream-dock { left: 8px; right: 8px; bottom: 8px; transform: none; overflow-x: auto; justify-content: flex-start; }
  .macro-button { min-width: 78px; width: 78px; }
  .macro-button.compact { min-width: 66px; width: 66px; }
  .live-button { min-width: 125px; }
  .stream-panel { left: 9px; right: 9px; bottom: 94px; width: auto; }
  .tutorial-card { left: 12px !important; right: 12px; top: 76px !important; width: auto; }
  .prototype-note { display: none; }
}

/* Pythera 23/10: ?camera=1, autorização simples em um toque ao lado do cliente streamer do PC */
body.camera-mode #canvas, body.camera-mode #start-game, body.camera-mode #status,
body.camera-mode .privacy-control, body.camera-mode .tutorial-trigger,
body.camera-mode .stream-dock, body.camera-mode .room-chip, body.camera-mode #viewer-count { display: none; }
body.camera-mode { background: radial-gradient(circle at 38% 28%, #1a2230, #07090c 72%); }
body.camera-mode .stream-status { max-width: 380px; min-width: min(380px, calc(100% - 24px)); }
body.camera-mode .camera-setup { position: fixed; z-index: 8; right: 24px; top: 50%; width: min(390px, calc(100% - 32px)); padding: 26px; display: grid; justify-items: center; gap: 13px; transform: translateY(-50%); border: 1px solid rgba(226, 182, 83, .45); border-radius: 18px; color: var(--text); background: rgba(10, 13, 18, .94); box-shadow: 0 24px 80px rgba(0, 0, 0, .65); text-align: center; }
.camera-setup-badge { color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .18em; }
.camera-setup h1 { margin: 0; color: var(--gold-soft); font: 700 25px Georgia, serif; }
.camera-setup p { max-width: 430px; margin: 0; color: #c3cad5; font-size: 13px; line-height: 1.55; }
.camera-setup p.error { color: #ff9da0; }
#camera-quick-start { width: min(360px, 100%); padding: 15px 20px; border: 1px solid #b9913f; border-radius: 10px; color: #171108; background: linear-gradient(#f0c764, #c99b3e); font-size: 14px; font-weight: 900; box-shadow: 0 10px 30px rgba(226, 182, 83, .18); }
#camera-quick-start:disabled { cursor: default; opacity: .82; }
body.camera-ready #camera-quick-start { border-color: #3fba7c; color: #092116; background: linear-gradient(#72e0a9, #43bd7e); }
.camera-game-commands { padding: 9px 12px; border-radius: 8px; background: #171c24; font-size: 11px !important; }
.camera-advanced-toggle { padding: 6px; border: 0; color: var(--muted); background: transparent; font-size: 11px; text-decoration: underline; }
body.camera-mode.camera-advanced .stream-dock { display: flex; }
body.camera-mode.camera-advanced .camera-setup { top: calc(50% - 55px); }
body.camera-mode .camera-viewer-guide { position: fixed; z-index: 7; left: 24px; top: 88px; width: min(860px, calc(100vw - 455px)); padding: 16px; display: flex; flex-direction: column; gap: 12px; border: 1px solid rgba(226, 182, 83, .34); border-radius: 18px; background: rgba(8, 11, 15, .9); box-shadow: 0 24px 80px rgba(0, 0, 0, .55); }
.viewer-guide-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.viewer-guide-head small { color: var(--gold); font-size: 9px; font-weight: 900; letter-spacing: .17em; }
.viewer-guide-head h2 { margin: 3px 0 0; color: var(--gold-soft); font: 700 20px Georgia, serif; }
.viewer-guide-head strong { padding: 7px 10px; border-radius: 999px; color: #c9d0da; background: #1b212a; font-size: 10px; white-space: nowrap; }
body.camera-guide-live .viewer-guide-head strong { color: #ffd7d8; background: #512124; }
.viewer-guide-screen { position: relative; aspect-ratio: 16/9; overflow: hidden; border: 1px solid #2f3742; border-radius: 12px; background: #000; }
.viewer-guide-screen iframe { width: 100%; height: 100%; display: block; border: 0; pointer-events: none; }
.viewer-guide-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 9px; padding: 24px; color: #cbd1da; background: radial-gradient(circle at 50% 30%, #17202b, #06080b 72%); text-align: center; }
.viewer-guide-empty span { color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .2em; }
.viewer-guide-empty strong { color: var(--gold-soft); font: 700 22px Georgia, serif; }
.viewer-guide-empty small { max-width: 430px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.viewer-guide-foot { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.viewer-guide-foot span { padding: 6px 9px; border-radius: 999px; color: #cce8db; background: #173126; font-size: 10px; font-weight: 800; white-space: nowrap; }
.viewer-guide-foot small { font-size: 10px; line-height: 1.4; }
body.camera-mode .viewer-guide-screen .facecam { position: absolute; z-index: 3; top: 10px !important; right: 10px !important; left: auto !important; width: 160px; border-width: 1px; border-radius: 8px; transform: none; }
body.camera-mode .viewer-guide-screen .facecam video { transform: none; }
body.camera-mode .viewer-guide-screen .facecam.off { display: none; }
body.camera-mode .viewer-guide-screen .facecam #hide-facecam,
body.camera-mode .viewer-guide-screen .facecam .drag-hint { display: none; }

@media (max-width: 980px) {
  body.camera-mode { min-height: 100%; padding: 72px 12px 24px; display: flex; flex-direction: column; gap: 14px; overflow: auto; }
  body.camera-mode .camera-viewer-guide { position: relative; inset: auto; order: 1; width: 100%; min-height: min(58vw, 520px); }
  body.camera-mode .camera-setup { position: relative; inset: auto; order: 2; width: 100%; transform: none; }
  body.camera-mode.camera-advanced .camera-setup { top: auto; }
  body.camera-mode.camera-advanced .stream-dock { display: flex; }
}

@media (max-width: 560px) {
  body.camera-mode .camera-viewer-guide { padding: 10px; min-height: 330px; }
  .viewer-guide-head h2 { font-size: 16px; }
  .viewer-guide-head strong { max-width: 44%; overflow: hidden; text-overflow: ellipsis; }
  .viewer-guide-foot { align-items: flex-start; flex-direction: column; gap: 6px; }
  body.camera-mode .viewer-guide-screen .facecam { width: 112px; }
}
