.ghost-wrap {
  width: min(36rem, calc(100% - 2 * var(--gutter)));
  margin-top: 1.125rem;
}

.ghost-cabinet {
  --ghost-night: #10152d;
  --ghost-text: #f0f1ff;
  --ghost-muted: #abb7e3;
  --ghost-line: #35416b;
  --ghost-cyan: #5df7eb;
  --ghost-gold: #ffdf70;
  background: var(--ghost-night);
  border-color: var(--ghost-line);
  color: var(--ghost-text);
}

.ghost-scorebar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: .25rem;
  padding: .7rem .55rem .55rem;
  text-align: center;
  font: 700 .65rem var(--mono);
  letter-spacing: .045em;
}

.ghost-scorebar span { display: block; color: var(--ghost-muted); }
.ghost-scorebar output { display: block; margin-top: .18rem; font-size: clamp(.8rem, 2.4vw, 1.12rem); }
.ghost-scorebar #lives { color: var(--ghost-cyan); letter-spacing: .035em; }

.ghost-room, .ghost-invite {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .4rem .65rem;
  flex-wrap: wrap;
  padding: .4rem .55rem;
  border-bottom: 1px solid var(--ghost-line);
  font: 700 .71rem var(--mono);
}
.ghost-room strong { color: var(--ghost-cyan); letter-spacing: .05em; }
.ghost-room button, .ghost-room-menu button {
  min-height: 2.35rem;
  padding: .2rem .5rem;
  border: 1px solid #5c77dc;
  border-radius: .4rem;
  background: #212c53;
  color: var(--ghost-text);
  font: 750 .74rem var(--mono);
}
.ghost-room button:hover, .ghost-room-menu button:hover { background: #304176; }
.ghost-invite input, .ghost-room-menu input {
  min-width: 0;
  padding: .4rem .55rem;
  border: 1px solid #5c77dc;
  border-radius: .4rem;
  background: #0c122c;
  color: var(--ghost-text);
  font: .85rem var(--mono);
}
.ghost-invite input { flex: 1 1 13rem; }
.ghost-team {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0;
  padding: .28rem .3rem .55rem;
  list-style: none;
  color: var(--ghost-muted);
  font: 700 .65rem var(--mono);
}
.ghost-team li { display: flex; align-items: center; justify-content: center; gap: .25rem; white-space: nowrap; }
.ghost-team i { width: .6rem; height: .6rem; border-radius: .25rem .25rem .1rem .1rem; background: var(--team-color, #5df7eb); }
.ghost-team [data-you="true"] { color: var(--ghost-text); }
.ghost-team [data-eaten="true"] i { opacity: .35; }
.ghost-team [data-eaten="true"] span { text-decoration: line-through; }

.ghost-phase {
  min-height: 1.8rem;
  padding: .4rem .5rem;
  border-block: 1px solid var(--ghost-line);
  background: #182746;
  color: var(--ghost-cyan);
  font: 800 .71rem/1.25 var(--mono);
  letter-spacing: .075em;
  text-align: center;
}

.ghost-phase[data-powered="true"] { background: #573523; color: #fff0a7; }

.ghost-field {
  position: relative;
  aspect-ratio: 21 / 19;
  background: #090d21;
  touch-action: none;
}

.ghost-field canvas { display: block; width: 100%; height: 100%; }
.ghost-field:focus-visible { outline: 2px solid var(--ghost-cyan); outline-offset: -3px; }
.ghost-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: #0b10255e;
}

.ghost-message {
  width: min(100%, 22rem);
  padding: 1.15rem 1rem;
  border: 1px solid #5c77dc;
  border-radius: .8rem;
  background: #141b37;
  box-shadow: 0 0 0 .25rem #0e132dbb, 0 .75rem 2rem #0008;
  text-align: center;
}

#message-kicker { color: var(--ghost-gold); font: 750 .65rem var(--mono); letter-spacing: .08em; }
.ghost-message h2 { margin: .35rem 0; font-size: clamp(1.3rem, 4vw, 1.85rem); letter-spacing: -.04em; }
.ghost-message #message-detail { color: var(--ghost-muted); font: .875rem/1.45 system-ui, sans-serif; }
.ghost-action { margin-top: .85rem; border: 1px solid #a4fff8; border-radius: .45rem; background: var(--ghost-cyan); color: #081b28; }
.ghost-action:hover { background: #a4fff8; }
.ghost-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; margin-top: .7rem; }
.ghost-actions .action { margin: 0; min-width: 0; }
.ghost-secondary { border: 1px solid #5c77dc; border-radius: .45rem; background: #212c53; color: var(--ghost-text); }
.ghost-secondary:hover { background: #304176; }
.ghost-room-menu { display: grid; gap: .45rem; margin-top: .7rem; }
.ghost-room-menu form { display: grid; grid-template-columns: 1fr auto; gap: .35rem; }
.ghost-room-menu input { text-transform: uppercase; }
.ghost-notice { margin: 0; padding: .55rem .7rem; color: #ffdf70; font-size: .84rem; text-align: center; }
.ghost-controls { border-color: var(--ghost-line); }
.ghost-controls .key-hint, .ghost-controls .touch-hint, .ghost-controls .tool { color: var(--ghost-muted); }
.ghost-controls kbd { background: #20294c; border-color: #516397; color: var(--ghost-text); }
.ghost-controls .tool:hover:not(:disabled) { background: #242f55; }
.ghost-pad { display: none; }

@media (pointer: coarse) {
  .ghost-controls .key-hint { display: none; }
  .ghost-controls .touch-hint { display: inline; }
  .ghost-pad { display: grid; grid-template-columns: repeat(4, minmax(2.75rem, 3.5rem)); justify-content: center; gap: .35rem; padding: 0 .65rem .65rem; }
  .ghost-pad button { min-height: 2.75rem; border: 1px solid #566bab; border-radius: .45rem; background: #20294c; color: var(--ghost-text); font: 750 1.15rem var(--mono); touch-action: manipulation; }
  .ghost-pad button:active:not(:disabled) { background: var(--ghost-cyan); color: #081b28; }
}

@media (max-width: 385px) {
  .ghost-overlay { padding: .45rem; }
  .ghost-message { padding: .65rem; }
  .ghost-message h2 { margin-block: .2rem; }
  .ghost-message #message-detail { font-size: .8rem; }
}
