:root {
  --blue: #6288c4;
  --ink: #344567;
  --pink: #f59db7;
  --blue-dark: #45689f;
  --blue-light: #c5ddfb;
  --bg-start: #f5f9ff;
  --bg-end: #fff9fb;
}

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

body {
  background: linear-gradient(135deg, var(--bg-start), var(--bg-end));
  font-family: system-ui, "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--ink);
  min-height: 100vh;
}

main {
  max-width: 1280px;
  margin: auto;
  padding: 24px;
}

/* ===== Header ===== */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

h1 {
  font-size: clamp(25px, 3vw, 38px);
  margin: 0;
  color: #3d5785;
  letter-spacing: 1px;
}

.sub {
  margin-top: 6px;
  color: #7890b5;
  font-size: 14px;
}

.pill {
  background: var(--blue);
  color: #fff;
  border-radius: 999px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 700;
}

/* ===== Layout ===== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
}

/* ===== Game Area ===== */
.game-wrap {
  position: relative;
  border: 3px solid var(--blue-light);
  border-radius: 22px;
  overflow: hidden;
  background: #dff3ff;
  box-shadow: 0 12px 32px rgba(143, 174, 219, 0.2);
}

#gameCanvas {
  width: 100%;
  height: auto;
  display: block;
}

/* ===== Overlay (Start Screen) ===== */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 250, 255, 0.85);
  backdrop-filter: blur(4px);
  padding: 20px;
  text-align: center;
  z-index: 20;
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  max-width: 470px;
  background: rgba(255, 255, 255, 0.93);
  border: 2px solid #d6e4fb;
  border-radius: 22px;
  padding: 26px;
  box-shadow: 0 12px 36px rgba(91, 120, 165, 0.13);
}

.overlay h2 {
  margin: 0 0 10px;
  font-size: 28px;
  color: #45669b;
}

.overlay p {
  line-height: 1.8;
  color: #657b9d;
  margin: 8px 0 18px;
  font-size: 15px;
}

/* ===== Buttons ===== */
button {
  border: 0;
  background: var(--blue);
  color: white;
  border-radius: 13px;
  padding: 12px 20px;
  font-weight: 750;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--blue-dark);
  transition: transform 0.1s, box-shadow 0.1s;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--blue-dark);
}

button.secondary {
  background: #edf4ff;
  color: #45669b;
  box-shadow: none;
  border: 1px solid #cbdcf5;
}

button.secondary:active {
  box-shadow: none;
}

/* ===== Side Panel ===== */
.panel {
  background: #fff;
  border: 1px solid #e1eaf8;
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 8px 24px rgba(123, 155, 192, 0.11);
  align-self: start;
}

.panel h3 {
  margin: 0 0 12px;
  color: #4b6797;
  font-size: 17px;
}

.stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #edf2fa;
  font-size: 14px;
  color: #657b9d;
}

.stat strong {
  font-size: 20px;
  color: #4c70a8;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #6d84a8;
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #e6a3b6;
  display: inline-block;
  transition: background 0.3s;
}

.dot.live {
  background: #68b8a7;
}

/* ===== Camera Preview ===== */
.camera {
  margin-top: 14px;
  aspect-ratio: 4 / 3;
  background: #edf4fb;
  border-radius: 14px;
  overflow: hidden;
  position: relative;
}

.camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(-1);
}

.help {
  font-size: 12px;
  line-height: 1.75;
  color: #7488a8;
  margin: 10px 0 0;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.controls button {
  flex: 1;
  min-width: 100px;
}

/* ===== Tips ===== */
.tips {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.tip {
  background: #fff;
  border: 1px solid #e4edf9;
  border-radius: 15px;
  padding: 12px;
  font-size: 13px;
  color: #6e82a3;
  line-height: 1.6;
}

.tip b {
  display: block;
  color: #4d6b9c;
  margin-bottom: 3px;
  font-size: 14px;
}

/* ===== Footer ===== */
footer {
  text-align: center;
  color: #91a2bd;
  font-size: 12px;
  padding: 18px 0 4px;
  margin-top: 18px;
}

/* ===== Responsive ===== */
@media (max-width: 900px) {
  main {
    padding: 12px;
  }
  .layout {
    grid-template-columns: 1fr;
  }
  .tips {
    grid-template-columns: 1fr;
  }
  .panel {
    order: 2;
  }
}
