/* W4: phase UI, chat panel, rotation timer. Complements the page shell. */

:root {
  --ui-bg: rgba(20, 20, 20, 0.92);
  --ui-border: #3a3a3a;
  --ui-fg: #e6e6e6;
  --ui-muted: #9aa0a6;
  --ui-accent: #c62828;
  --ui-ok: #66bb6a;
  --ui-warn: #ffb74d;
}

.phase-ui {
  margin-top: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  display: grid;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.phase-ui-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: baseline;
}

.phase-ui-label {
  color: var(--ui-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.phase-ui-value {
  color: var(--ui-fg);
  text-align: right;
  word-break: break-word;
}

#phase-status[data-phase="ready"] .phase-ui-value,
.phase-ready { color: var(--ui-ok); }
#phase-status[data-phase="error"] .phase-ui-value,
.phase-error { color: var(--ui-accent); }
#phase-status[data-phase="waiting-rotation"] .phase-ui-value,
.phase-waiting { color: var(--ui-warn); }

.phase-tic-progress {
  font-variant-numeric: tabular-nums;
}

/* Chat panel */
.chat-panel {
  margin-top: 0.75rem;
  border: 1px solid var(--ui-border);
  background: var(--ui-bg);
  display: flex;
  flex-direction: column;
  min-height: 10rem;
  max-height: 16rem;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--ui-border);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ui-muted);
}

.chat-unread {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--ui-accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
}
.chat-unread[hidden] { display: none; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  min-height: 5rem;
}

.chat-line { color: var(--ui-fg); white-space: pre-wrap; word-break: break-word; }
.chat-line-self { color: #b3d4fc; }

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid var(--ui-border);
}

.chat-input {
  flex: 1;
  min-width: 0;
  background: #111;
  color: var(--ui-fg);
  border: 1px solid var(--ui-border);
  padding: 0.4rem 0.5rem;
  font: inherit;
  font-size: 0.85rem;
}
.chat-input:focus { outline: 1px solid var(--ui-muted); border-color: var(--ui-muted); }

.chat-panel.chat-closed .chat-input-row { display: none; }
.chat-panel.chat-closed .chat-messages { opacity: 0.8; }

.chat-hint {
  font-size: 0.75rem;
  color: var(--ui-muted);
  padding: 0 0.75rem 0.5rem;
}
.chat-panel.chat-open .chat-hint { display: none; }

@media (max-width: 600px) {
  .phase-ui-row { flex-direction: column; align-items: flex-start; }
  .phase-ui-value { text-align: left; }
}

/* V1: the game surface. Fixed 4:3 aspect, black letterbox, nearest-neighbour
   scaling so the playsim's low-resolution frame stays pixel-crisp. */
.game-container {
  margin-top: 0.75rem;
  aspect-ratio: 4 / 3;
  background: #000;
  border: 1px solid var(--ui-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.game-container > canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  image-rendering: pixelated;
  outline: none;
}
