:root {
  --bg-deep: #0f1419;
  --bg-meet: #1a222d;
  --bg-panel: #243041;
  --bg-cheat: #121820;
  --line: rgba(255, 255, 255, 0.08);
  --text: #e8eef6;
  --text-dim: #8b9bb0;
  --accent: #2fd4a1;
  --accent-dim: #1a8f6c;
  --danger: #ff5c6c;
  --warn: #f0b429;
  --peek: #3d8bfd;
  --speak: #2fd4a1;
  --font: "IBM Plex Sans JP", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --radius: 12px;
  --suspicion: 0;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

#app {
  min-height: 100dvh;
  display: grid;
}

.screen {
  display: none;
  min-height: 100dvh;
}

.screen.screen-active {
  display: grid;
}

/* —— Title —— */
#screen-title {
  place-items: center;
  padding: 2rem;
  position: relative;
  overflow: hidden;
}

.title-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(47, 212, 161, 0.18), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(61, 139, 253, 0.12), transparent 50%),
    linear-gradient(165deg, #0c1016 0%, #15202b 45%, #0f1419 100%);
}

.title-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 20%, transparent 75%);
  animation: grid-drift 28s linear infinite;
}

@keyframes grid-drift {
  from { background-position: 0 0, 0 0; }
  to { background-position: 48px 48px, 48px 48px; }
}

.title-panel {
  position: relative;
  z-index: 1;
  max-width: 34rem;
  text-align: center;
  animation: rise-in 0.7s ease both;
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}

.title-eyebrow {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  color: var(--accent);
}

.title-brand {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.title-brand span {
  display: inline-block;
  color: var(--accent);
}

.title-lead {
  margin: 1rem 0 1.5rem;
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.7;
}

.title-ops {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
  margin-bottom: 1.75rem;
}

.title-ops span {
  font-size: 0.85rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
}

.btn-primary {
  appearance: none;
  background: linear-gradient(180deg, #3aefb8, var(--accent));
  color: #062419;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.9rem 1.8rem;
  border-radius: 999px;
  box-shadow: 0 0 0 1px rgba(47, 212, 161, 0.35), 0 12px 32px rgba(47, 212, 161, 0.2);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(47, 212, 161, 0.5), 0 16px 36px rgba(47, 212, 161, 0.28);
}

.btn-primary:active {
  transform: translateY(0);
}

.title-hint {
  margin: 1.25rem 0 0;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.7;
}

.title-hint kbd {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
}

/* —— Interview —— */
#screen-interview {
  grid-template-rows: auto 1fr auto auto;
  background: var(--bg-meet);
}

.meet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.1rem;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
}

.meet-header-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.meet-header-left span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meet-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
  flex-shrink: 0;
}

.meet-header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

#question-badge {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}

.rec-badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: #fff;
  background: var(--danger);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  animation: rec-blink 1.6s ease infinite;
}

@keyframes rec-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.meet-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: 1rem 1rem 0.5rem;
  min-height: 0;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(61, 139, 253, 0.08), transparent 50%),
    linear-gradient(180deg, #1e2836, #151c26);
}

.suspicion-meter {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  z-index: 5;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 0.2rem 0.55rem;
  align-items: center;
  min-width: 9.5rem;
  padding: 0.55rem 0.7rem;
  background: rgba(10, 14, 20, 0.82);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

.suspicion-meter.hot {
  border-color: rgba(255, 92, 108, 0.55);
  box-shadow: 0 0 20px rgba(255, 92, 108, 0.2);
}

.suspicion-icon {
  grid-row: 1 / 3;
  font-size: 1.25rem;
}

.suspicion-body {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.78rem;
}

.suspicion-label {
  color: var(--text-dim);
}

#suspicion-value {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text);
}

.suspicion-bar {
  grid-column: 2;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

#suspicion-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--warn), var(--danger));
  border-radius: inherit;
  transition: width 0.08s linear;
}

.interviewer-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.65rem;
  margin-top: 1.5rem;
}

.face {
  width: min(42vw, 180px);
  aspect-ratio: 3 / 3.4;
  position: relative;
  transition: transform 0.35s ease;
}

.face-head {
  position: absolute;
  inset: 8% 12% 28%;
  background: linear-gradient(180deg, #f3d5b5, #e8c09a);
  border-radius: 48% 48% 45% 45%;
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, 0.08);
}

.face-hair {
  position: absolute;
  top: -6%;
  left: 5%;
  right: 5%;
  height: 38%;
  background: #2a3340;
  border-radius: 50% 50% 30% 30% / 70% 70% 30% 30%;
}

.face-eyes {
  position: absolute;
  top: 42%;
  left: 18%;
  right: 18%;
  display: flex;
  justify-content: space-between;
}

.eye {
  width: 22%;
  aspect-ratio: 1;
  background: #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  transition: transform 0.2s ease;
}

.pupil {
  width: 42%;
  aspect-ratio: 1;
  background: #1a1f28;
  border-radius: 50%;
  transition: transform 0.15s ease;
  position: relative;
}

.pupil::after {
  content: "";
  position: absolute;
  top: 18%;
  left: 22%;
  width: 35%;
  height: 35%;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
}

.face-brows {
  position: absolute;
  top: 34%;
  left: 16%;
  right: 16%;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}

.brow {
  width: 24%;
  height: 4px;
  background: #2a3340;
  border-radius: 4px;
  transition: transform 0.25s ease;
}

.face-mouth {
  position: absolute;
  bottom: 22%;
  left: 50%;
  width: 22%;
  height: 6px;
  margin-left: -11%;
  border-radius: 0 0 12px 12px;
  border: 2.5px solid #c47a6a;
  border-top: none;
  transition: all 0.25s ease;
}

.face-shoulders {
  position: absolute;
  bottom: 0;
  left: 5%;
  right: 5%;
  height: 30%;
  background: linear-gradient(180deg, #2c3a4d, #1e2a38);
  border-radius: 40% 40% 0 0 / 60% 60% 0 0;
}

/* Face states via class on #interviewer-face */
.face-neutral .pupil { transform: translate(0, 0); }
.face-neutral .brow { transform: none; }

.face-mild .pupil { transform: translate(0, 2px); }
.face-mild .brow.left { transform: rotate(-8deg) translateY(1px); }
.face-mild .brow.right { transform: rotate(8deg) translateY(1px); }
.face-mild .face-mouth {
  width: 16%;
  margin-left: -8%;
  height: 3px;
  border-radius: 2px;
  border: none;
  background: #c47a6a;
}

.face-suspicious .pupil { transform: translate(4px, 3px); }
.face-suspicious .brow.left { transform: rotate(-18deg) translateY(3px); }
.face-suspicious .brow.right { transform: rotate(18deg) translateY(3px); }
.face-suspicious .eye { transform: scaleY(0.85); }
.face-suspicious .face-mouth {
  width: 18%;
  margin-left: -9%;
  height: 10px;
  border-radius: 50%;
  border: 2px solid #c47a6a;
  background: transparent;
}

.face-stare .pupil { transform: translate(8px, 6px) scale(1.15); }
.face-stare .brow.left { transform: rotate(-25deg) translateY(4px); }
.face-stare .brow.right { transform: rotate(25deg) translateY(4px); }
.face-stare .eye {
  transform: scale(1.08);
  box-shadow: 0 0 0 2px rgba(255, 92, 108, 0.25);
}
.face-stare .face-mouth {
  width: 14%;
  margin-left: -7%;
  height: 3px;
  border: none;
  border-radius: 2px;
  background: #c47a6a;
}
.face-stare {
  animation: stare-pulse 0.9s ease infinite;
}

@keyframes stare-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* Looking down at cheat sheet while peeking */
.face-looking-down .pupil {
  transform: translate(0, 10px) !important;
}
.face.face-looking-down {
  /* interviewer looking at YOUR eyes shifting - actually player looks down */
}

.participant-name {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.4);
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
}

.self-cam {
  position: absolute;
  right: 0.85rem;
  bottom: 0.85rem;
  width: 88px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  align-items: stretch;
}

.self-cam-inner {
  aspect-ratio: 4 / 3;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #2a3545, #1a222e);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.self-cam > span {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
}

.self-cam.peeking .self-cam-inner {
  background: linear-gradient(160deg, #1e2a3a, #0f1520);
}
.self-cam.peeking .self-cam-inner::after {
  content: "👀↓";
  font-size: 1rem;
}

.dialogue-stack {
  position: absolute;
  left: 1rem;
  right: 6.5rem;
  bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  max-width: 420px;
  pointer-events: none;
}

.question-box,
.answer-box {
  position: relative;
  left: auto;
  bottom: auto;
  max-width: 100%;
  animation: bubble-in 0.35s ease both;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.speaker {
  margin: 0 0 0.25rem;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.speaker.you {
  color: var(--accent);
}

.bubble {
  margin: 0;
  padding: 0.7rem 0.9rem;
  background: rgba(12, 16, 22, 0.88);
  border: 1px solid var(--line);
  border-radius: 10px 10px 10px 4px;
  font-size: 0.95rem;
  line-height: 1.55;
  backdrop-filter: blur(6px);
}

.bubble.you {
  border-color: rgba(47, 212, 161, 0.25);
  border-radius: 10px 10px 4px 10px;
}

/* Cheat dock */
.cheat-dock {
  background: var(--bg-cheat);
  border-top: 1px solid var(--line);
  padding: 0.65rem 1rem 0.85rem;
  min-height: 5.5rem;
}

.cheat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.45rem;
}

.cheat-ai {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.14em;
  color: var(--peek);
}

.cheat-status {
  font-size: 0.7rem;
  color: var(--text-dim);
}

.cheat-status.active {
  color: var(--peek);
}

.cheat-loading {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  padding: 0.5rem 0;
}

.loading-dots::after {
  content: "";
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  0% { content: ""; }
  25% { content: "."; }
  50% { content: ".."; }
  75% { content: "..."; }
}

.cheat-text {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.7;
  letter-spacing: 0.01em;
  word-break: break-all;
  min-height: 2.8em;
}

.cheat-text .read {
  color: var(--accent);
  background: rgba(47, 212, 161, 0.1);
}

.cheat-text .unread {
  color: rgba(232, 238, 246, 0.28);
}

.cheat-text .spoken-mark {
  /* optional cursor at speak position via border */
}

.cheat-text.blurred .read,
.cheat-text.blurred .unread {
  filter: blur(3.5px);
  user-select: none;
}

.cheat-text.hidden-cheat {
  visibility: hidden;
}

/* Controls */
.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  padding: 0.75rem 1rem calc(0.85rem + env(safe-area-inset-bottom));
  background: #0c1016;
  border-top: 1px solid var(--line);
}

.btn-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.85rem 0.5rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.1s ease, filter 0.1s ease, box-shadow 0.15s ease;
}

.btn-emoji {
  font-size: 1.35rem;
  line-height: 1;
}

.btn-hint {
  font-size: 0.68rem;
  font-weight: 500;
  opacity: 0.7;
}

.btn-peek {
  background: linear-gradient(180deg, #5aa0ff, var(--peek));
  box-shadow: 0 4px 0 #1f5bb8;
}

.btn-speak {
  background: linear-gradient(180deg, #4aefc0, var(--speak));
  color: #062419;
  box-shadow: 0 4px 0 var(--accent-dim);
}

.btn-action:not(:disabled):active,
.btn-action.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 transparent;
  filter: brightness(1.05);
}

.btn-peek.pressed {
  box-shadow: 0 0 24px rgba(61, 139, 253, 0.45);
}

.btn-speak.pressed {
  box-shadow: 0 0 24px rgba(47, 212, 161, 0.4);
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: rgba(6, 10, 16, 0.72);
  backdrop-filter: blur(4px);
  animation: fade-in 0.25s ease;
}

.overlay[hidden] {
  display: none !important;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-card {
  width: min(100%, 420px);
  padding: 1.5rem 1.35rem;
  background: var(--bg-panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  text-align: center;
  animation: rise-in 0.3s ease both;
}

.overlay-speaker {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.overlay-text {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  line-height: 1.65;
}

/* Result */
#screen-result {
  place-items: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(47, 212, 161, 0.15), transparent 45%),
    var(--bg-deep);
}

#screen-result.fail {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 92, 108, 0.18), transparent 45%),
    var(--bg-deep);
}

.result-panel {
  width: min(100%, 420px);
  text-align: center;
  animation: rise-in 0.5s ease both;
}

.result-eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  color: var(--text-dim);
}

.result-title {
  margin: 0.5rem 0 0.75rem;
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 700;
}

#screen-result:not(.fail) .result-title {
  color: var(--accent);
}

#screen-result.fail .result-title {
  color: var(--danger);
}

.result-message {
  margin: 0 0 1rem;
  color: var(--text-dim);
  line-height: 1.65;
}

.result-quote {
  margin: 0 0 1.5rem;
  padding: 0.9rem 1rem;
  border-left: 3px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  text-align: left;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

.result-stats {
  list-style: none;
  margin: 0 0 1.75rem;
  padding: 0;
  display: grid;
  gap: 0.5rem;
  text-align: left;
}

.result-stats li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem 0.8rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.9rem;
}

.result-stats li span:last-child {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--accent);
}

#screen-result.fail .result-stats li span:last-child {
  color: var(--warn);
}

@media (max-width: 520px) {
  .self-cam {
    width: 72px;
    right: 0.55rem;
    bottom: 0.55rem;
  }

  .dialogue-stack {
    right: 5.5rem;
  }

  .face {
    width: min(48vw, 150px);
  }

  .suspicion-meter {
    min-width: 8.2rem;
    top: 0.55rem;
    right: 0.55rem;
  }
}

@media (min-width: 720px) {
  #screen-interview {
    max-width: 720px;
    margin: 0 auto;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
}
