* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  background: #eef1f5;
  color: #1d2430;
}

.stage {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  position: relative;
}

.play {
  position: relative;
  flex: 1 1 auto;
  min-height: 200px;
  overflow: hidden;
  border-radius: 12px;
  background: #10151c;
}

.cam {
  position: absolute;
  inset: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.view {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  flex-wrap: wrap;
  pointer-events: none;
}

.chips { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  background: rgba(16, 21, 28, 0.6);
  color: #fff;
  font-size: 13px;
  padding: 4px 9px;
  border-radius: 999px;
}

.chip b { font-weight: 700; }

.flags { display: flex; gap: 6px; }

.flag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(16, 21, 28, 0.55);
  color: #cdd6e2;
}

.flag .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
}

.flag-blue.on { background: #2563eb; border-color: #bfdbfe; color: #fff; }
.flag-white.on { background: #f8fafc; border-color: #ffffff; color: #1d2430; }
.flag.on .dot { opacity: 1; }

.command {
  position: absolute;
  left: 50%;
  bottom: 46px;
  transform: translateX(-50%);
  width: min(92%, 640px);
  text-align: center;
  font-size: clamp(1.1rem, 4.6vw, 2rem);
  font-weight: 800;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75);
  word-break: keep-all;
}

.command.ok { color: #86efac; }
.command.bad { color: #fca5a5; }

.notice {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  background: rgba(16, 21, 28, 0.82);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
}

.timer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 6px;
  background: rgba(255, 255, 255, 0.18);
}

.timer-fill {
  height: 100%;
  width: 0;
  background: #38bdf8;
}

.panel {
  flex: 0 0 auto;
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(16, 21, 28, 0.12);
}

.guide {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.45;
  color: #445065;
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  font: inherit;
  font-weight: 700;
  padding: 8px 18px;
  border-radius: 8px;
  border: 1px solid #c8d1e0;
  background: #f7f9fc;
  color: #1d2430;
  cursor: pointer;
}

button#startBtn { background: #2563eb; border-color: #2563eb; color: #fff; }
button:disabled { opacity: 0.45; cursor: default; }

.status { font-size: 12px; color: #5a6478; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 16, 22, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.overlay[hidden] { display: none; }

.overlay-box {
  background: #fff;
  border-radius: 14px;
  padding: 18px 22px;
  text-align: center;
  max-width: 320px;
}

.overlay-box h2 { margin: 0 0 6px; font-size: 20px; }
.overlay-box p { margin: 0 0 14px; font-size: 14px; color: #445065; }

.overlay-box .ranking-status {
  margin: -4px 0 14px;
  font-size: 13px;
  font-weight: 700;
  color: #2563eb;
  word-break: keep-all;
}

.overlay-box .ranking-status:empty { display: none; }
