:root {
  color-scheme: dark;
  font-family: Arial, Helvetica, sans-serif;
  color: #F5EFE6;
  background: #0B0B0B;
}

* { box-sizing: border-box; }
html, body { width: 100%; min-height: 100%; margin: 0; }
button { font: inherit; }
button:focus-visible, canvas:focus-visible { outline: 2px solid #F2CE9E; outline-offset: -4px; }

.game {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 300px;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #32251c, #100d0b 65%);
}
#room-canvas {
  display: block;
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  touch-action: none;
  cursor: grab;
}
#room-canvas:active { cursor: grabbing; }
.canvas-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(4,3,3,.58), transparent 23%, transparent 63%, rgba(4,3,3,.76));
}
.game-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) 0 max(1.25rem, env(safe-area-inset-left));
  pointer-events: none;
}
.wordmark {
  margin: 0;
  font: normal clamp(1rem, 1.5vw, 1.25rem) Georgia, 'Times New Roman', serif;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-shadow: 0 1px 8px #000;
}
.room-name { color: #e1c4a6; font-size: .875rem; text-shadow: 0 1px 8px #000; }
.room-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.25rem max(1.25rem, env(safe-area-inset-right)) max(1.25rem, env(safe-area-inset-bottom)) max(1.25rem, env(safe-area-inset-left));
  pointer-events: none;
}
.room-caption { display: flex; align-items: flex-start; gap: .85rem; max-width: 24rem; text-shadow: 0 1px 8px #000; }
.caption-mark { width: 20px; height: 20px; flex: none; border: 1px solid #D8A35A; border-radius: 50%; box-shadow: 3px 0 8px rgba(245,178,96,.45); }
.caption-label { margin: 0 0 .45rem; font: normal 1.1rem Georgia, 'Times New Roman', serif; }
.room-caption p:last-child { margin: 0; color: #f1e4d7; font-size: .875rem; line-height: 1.55; }
.room-tools { pointer-events: auto; display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; }
.room-tools[hidden] { display: none; }
.room-tools button {
  color: #F5EFE6;
  background: rgba(18,14,12,.88);
  border: 1px solid rgba(226,184,131,.55);
  cursor: pointer;
}
.room-tools button:hover { background: rgba(77,53,35,.96); }
.room-tools button:active, .room-tools button.is-pressed { background: #8A5A3C; }
.reset-button { min-height: 44px; padding: .6rem .9rem; font-size: .875rem; }
.direction-pad { display: grid; grid-template-columns: repeat(3, 48px); gap: 4px; }
.direction-pad button { height: 48px; display: grid; place-items: center; font-size: 1.2rem; touch-action: none; user-select: none; }
.visually-hidden, .room-status:not(.status-error) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}
.room-status.status-error, .no-script {
  position: absolute;
  top: 5rem;
  left: 1.25rem;
  max-width: min(28rem, calc(100% - 2.5rem));
  margin: 0;
  padding: .8rem 1rem;
  color: #F5EFE6;
  background: rgba(15,10,8,.95);
  border: 1px solid rgba(216,163,90,.5);
  font-size: .9rem;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .room-caption { max-width: min(100%, 22rem); }
  .room-overlay { flex-direction: column; align-items: stretch; gap: 1rem; }
  .room-tools { align-self: flex-end; }
  .direction-pad { grid-template-columns: repeat(3, 46px); }
  .direction-pad button { height: 46px; }
}
@media (max-width: 360px) {
  .caption-mark { display: none; }
  .room-name { font-size: .8rem; }
}
@media (max-height: 460px) {
  .room-overlay { flex-direction: row; align-items: flex-end; }
  .room-caption { max-width: 50%; }
  .caption-label { margin-bottom: .2rem; }
  .room-caption p:last-child { font-size: .8rem; line-height: 1.3; }
  .direction-pad { grid-template-columns: repeat(3, 44px); gap: 2px; }
  .direction-pad button { height: 44px; }
  .reset-button { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto; }
}
