* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #071017;
  color: #f9fbf0;
  font-family: "Segoe UI", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  width: 100vw;
  height: 100vh;
  background: #0c2734;
}

.map-area {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #0c55bf;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  touch-action: none;
}

.topbar,
.actionbar {
  position: absolute;
  z-index: 5;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.topbar {
  top: 14px;
}

.actionbar {
  bottom: 16px;
  align-items: end;
}

.topbar > *,
.actionbar > *,
.controls,
.side-panel {
  pointer-events: auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: #ffe16a;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.55);
  font-size: 28px;
  line-height: 1.05;
}

h2 {
  font-size: 17px;
  line-height: 1.35;
}

.status-strip,
.player-switch,
.panel-block,
.toast {
  border: 2px solid rgba(255, 255, 255, 0.64);
  border-radius: 8px;
  background: rgba(6, 14, 19, 0.78);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.32);
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px;
  font-weight: 800;
}

.status-strip span {
  min-width: 78px;
  padding: 6px 8px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.12);
  text-align: center;
}

.player-switch {
  display: flex;
  max-width: min(560px, 55vw);
  gap: 6px;
  padding: 8px;
  overflow-x: auto;
}

.player-tab {
  display: grid;
  min-width: 92px;
  grid-template-columns: 18px 1fr;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 6px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  text-align: left;
}

.player-tab.is-active {
  background: #ffe16a;
  color: #1c1a08;
}

.dot {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(0, 0, 0, 0.38);
  border-radius: 50%;
}

#inspectBtn,
#activateBtn,
#pingBtn,
.chat-form button {
  border: 0;
  border-radius: 8px;
  background: #ffe16a;
  box-shadow: 0 4px 0 #9d6d1f;
  color: #211803;
  cursor: pointer;
  font-weight: 900;
}

#inspectBtn,
#activateBtn {
  min-width: 112px;
  height: 48px;
  margin-left: 8px;
}

#activateBtn {
  background: #ff9d5a;
}

button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.42);
}

.controls {
  position: absolute;
  right: 18px;
  bottom: 88px;
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(3, 58px);
  gap: 8px;
  user-select: none;
}

.dir {
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background: rgba(8, 18, 24, 0.76);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.42);
  color: #fff8c9;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.dir.is-held {
  background: rgba(72, 92, 39, 0.9);
}

.up {
  grid-column: 2;
  grid-row: 1;
}

.left {
  grid-column: 1;
  grid-row: 2;
}

.down {
  grid-column: 2;
  grid-row: 3;
}

.right {
  grid-column: 3;
  grid-row: 2;
}

.side-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
  padding: 14px;
  overflow: hidden;
  background: #142026;
}

.panel-block {
  padding: 14px;
}

.objective ol {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.objective li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: #dbe8e6;
}

.objective li.is-done {
  background: rgba(123, 210, 116, 0.2);
  color: #efffed;
}

.role-card {
  display: grid;
  gap: 10px;
}

.role-card p:not(.eyebrow) {
  color: #c8d6d4;
  line-height: 1.55;
}

.hint-list {
  display: grid;
  gap: 8px;
}

.hint {
  padding: 9px;
  border-left: 4px solid #ffe16a;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  line-height: 1.45;
}

.log-card {
  display: grid;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
}

.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

#pingBtn {
  min-width: 92px;
  height: 36px;
  padding: 0 10px;
  font-size: 13px;
}

.chat-log {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  padding-right: 4px;
}

.message {
  padding: 8px 10px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  line-height: 1.45;
}

.message strong {
  color: #ffe16a;
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 8px;
}

.chat-form input {
  min-width: 0;
  border: 2px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  padding: 10px;
  background: #091217;
  color: #fff;
}

.chat-form button {
  height: 43px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 24px;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
  text-align: center;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .map-area {
    height: 68vh;
    min-height: 520px;
  }

  .side-panel {
    min-height: 520px;
  }
}

@media (max-width: 640px) {
  .topbar,
  .actionbar {
    left: 10px;
    right: 10px;
  }

  h1 {
    font-size: 21px;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .status-strip {
    width: 100%;
  }

  .controls {
    right: 10px;
    bottom: 86px;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
  }

  .dir {
    width: 50px;
    height: 50px;
  }

  .actionbar {
    flex-direction: column;
  }

  .player-switch {
    width: 100%;
    max-width: none;
  }
}
