* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  background: #000;
  overflow: hidden;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
}

/* Canvas giữ tỉ lệ 16:9, co giãn vừa màn hình (letterbox) */
#game {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  touch-action: none;
  cursor: crosshair;
}

#preview-wrap {
  position: absolute;
  right: 16px; bottom: 16px;
  width: 240px; height: 180px;
  border: 2px solid rgba(255,255,255,.4);
  border-radius: 10px;
  overflow: hidden;
  background: #111;
  opacity: .85;
}
#preview-wrap video { display: none; }
#preview-wrap canvas { width: 100%; height: 100%; }
.hidden { display: none !important; }

#overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55);
}
.panel {
  background: rgba(30,20,10,.92);
  border: 2px solid #c98b3a;
  border-radius: 18px;
  padding: 32px 40px;
  max-width: 560px;
  text-align: center;
}
.panel h1 { font-size: 44px; margin-bottom: 8px; }
.panel p { opacity: .85; margin-bottom: 16px; }
.modes { text-align: left; margin: 16px 0 20px; display: grid; gap: 8px; }
.modes label { cursor: pointer; }
button {
  display: block; width: 100%;
  padding: 14px; margin-top: 10px;
  font-size: 20px; font-weight: 700;
  border: 0; border-radius: 12px;
  background: #ff7a2b; color: #fff;
  cursor: pointer;
}
button.secondary { background: #444; font-size: 16px; }
button:disabled { opacity: .5; cursor: wait; }
#status { margin-top: 14px; min-height: 1.2em; color: #ffd27a; }

#hud-tip {
  position: absolute; left: 50%; bottom: 8px;
  transform: translateX(-50%);
  font-size: 13px; opacity: .45;
  pointer-events: none;
}

/* ===================== TV ===================== */
.tv-lobby {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,6,2,.82);
}
.tv-lobby-box {
  background: rgba(30,20,10,.95);
  border: 3px solid #c98b3a;
  border-radius: 24px;
  padding: 3vh 4vw;
  text-align: center;
  max-width: 90vw;
}
.tv-lobby-box h1 { font-size: 6vh; margin-bottom: 2vh; }
.tv-lobby-row { display: flex; gap: 4vw; align-items: center; text-align: left; }
#qr { width: 38vh; height: 38vh; background: #fff; border-radius: 12px; }
.tv-lobby-steps .step { font-size: 2.6vh; margin: 1vh 0; opacity: .9; }
.tv-lobby-steps .url { font-size: 2.2vh; color: #7fd3ff; margin: 0 0 1vh 2vw; font-family: monospace; }
.tv-lobby-steps .code-label { margin-top: 2.5vh; font-size: 2.4vh; opacity: .7; }
.tv-lobby-steps .code { font-size: 10vh; font-weight: 900; letter-spacing: 2vh; color: #ffd23f; line-height: 1.1; }
.tv-status { margin-top: 2vh; font-size: 2.6vh; color: #ffd27a; }
.tv-banner {
  position: absolute; top: 2vh; left: 50%;
  transform: translateX(-50%);
  background: rgba(200,40,40,.9);
  padding: 1.2vh 3vw; border-radius: 12px;
  font-size: 3vh; font-weight: 700;
}
