:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  color: #e7edf5;
  background: #0b1018;
  font-size: 15px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
header,
main {
  max-width: 1350px;
  margin: auto;
  padding: 20px;
}
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  border-bottom: 1px solid #29384d;
}
h1 {
  font-size: 22px;
  letter-spacing: 1px;
  margin: 0;
}
h1 span {
  color: #92a5bf;
}
h2 {
  font-size: 17px;
}
p {
  color: #92a5bf;
  line-height: 1.5;
}
header p {
  margin: 5px 0;
}
button,
input,
select {
  font: inherit;
  padding: 10px 13px;
  border: 1px solid #334760;
  border-radius: 6px;
  background: #1d2a3c;
  color: #e7edf5;
}
button {
  cursor: pointer;
}
button:hover {
  border-color: #65d6bc;
  background: #26384d;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid #65d6bc;
  outline-offset: 2px;
}
.accent {
  background: #65d6bc;
  color: #0b1018;
  font-weight: 600;
}
.panel {
  background: #141d2b;
  border: 1px solid #29384d;
  border-radius: 10px;
  padding: 20px;
}
.row,
.room-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.row {
  margin: 12px 0;
}
label {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}
.room-bar {
  margin-bottom: 18px;
}
.room-bar strong {
  margin-right: auto;
}
#lobby {
  max-width: 760px;
  margin: 20px auto;
}
#notice {
  min-height: 24px;
  color: #f8cb7a;
  margin: 10px 0;
}
.layout {
  display: grid;
  grid-template-columns: minmax(300px, 720px) minmax(300px, 1fr);
  gap: 24px;
  align-items: start;
}
.player-bar {
  display: flex;
  justify-content: space-between;
  padding: 10px 2px;
}
#board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  aspect-ratio: 1;
  isolation: isolate;
  border: 2px solid #334760;
  touch-action: none;
  user-select: none;
}
.square {
  position: relative;
  aspect-ratio: 1;
  border: 0;
  border-radius: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #47617a;
  color: #172232;
  overflow: visible;
}
.square.light {
  background: #aabccc;
}
.square:hover {
  background-color: #d1c697;
}
.square img {
  width: 90%;
  height: 90%;
  object-fit: contain;
  pointer-events: none;
  z-index: 2;
}
.square .coordinate {
  position: absolute;
  left: 3px;
  top: 1px;
  font-size: 10px;
  z-index: 5;
}
.square .badge {
  position: absolute;
  bottom: 2px;
  left: 1px;
  right: 1px;
  font-size: clamp(8px, 1vw, 11px);
  line-height: 1.1;
  background: #102034d9;
  color: white;
  z-index: 5;
  pointer-events: none;
}
.square .terrain {
  position: absolute;
  inset: 8%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  color: white;
  background: #57534e;
  z-index: 1;
  border: 3px solid #e7e5e4;
}
.square .terrain.teleport_pad {
  border-radius: 50%;
  background: #0e7490;
  border-color: #67e8f9;
}
.square .terrain.gate {
  background: repeating-linear-gradient(
    90deg,
    #1e3a8a 0px,
    #1e3a8a 5px,
    transparent 5px,
    transparent 12px
  );
}
.square .terrain.mining_rig {
  background: #78350f;
  border-color: #fbbf24;
}
.square .effect {
  position: absolute;
  inset: 2px;
  background: var(--effect);
  opacity: 0.55;
  border: 3px solid white;
  z-index: 1;
}
.square.center {
  box-shadow: inset 0 0 0 2px #22d3ee;
}
.square.last {
  background-image: linear-gradient(#c8ce5870, #c8ce5870);
}
.square.selected {
  outline: 4px solid #f6f669;
  outline-offset: -4px;
}
.square.legal:after {
  content: "";
  position: absolute;
  width: 22%;
  height: 22%;
  border-radius: 50%;
  background: #103c27aa;
  border: 2px solid #a9f6bd;
  z-index: 7;
}
.square.bounty:before {
  content: "★";
  position: absolute;
  right: 2px;
  top: 1px;
  color: #ffd460;
  text-shadow: 0 1px black;
  z-index: 7;
}
.square.area {
  outline: 3px solid #ff6c70;
  outline-offset: -3px;
}
.square.castle {
  background-image: linear-gradient(#7c3aed55, #7c3aed55);
}
.square.castle-n {
  border-top: 5px solid #fde68a;
}
.square.castle-s {
  border-bottom: 5px solid #fde68a;
}
.square.castle-w {
  border-left: 5px solid #fde68a;
}
.square.castle-e {
  border-right: 5px solid #fde68a;
}
#turn {
  margin-bottom: 0;
}
#hint {
  min-height: 24px;
}
#director {
  padding: 12px;
  background: #141d2b;
  border-left: 3px solid #65d6bc;
}
nav {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
}
nav button {
  flex: 1;
  padding: 9px 5px;
}
nav button.active {
  border-color: #65d6bc;
  color: #65d6bc;
}
.tiles {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.tiles button {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 8px;
  font-size: 13px;
}
.tiles img {
  height: 32px;
  width: 32px;
}
.tiles button.active {
  outline: 2px solid #65d6bc;
}
.craft-row {
  display: flex;
  gap: 18px;
  align-items: center;
  margin: 15px 0;
}
.craft-row > div:last-child {
  flex: 1;
}
.craft-row p {
  font-size: 12px;
}
.craft-row button {
  margin: 3px;
}
#craft-grid,
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
#craft-grid {
  width: 156px;
  flex-shrink: 0;
}
#craft-grid button {
  width: 48px;
  height: 48px;
  padding: 0;
  margin: 0;
}
.material-wood {
  background: #9a6a3a !important;
}
.material-stone {
  background: #71717a !important;
}
.material-iron {
  background: #cbd5e1 !important;
  color: #101821;
}
.material-diamond {
  background: #22d3ee !important;
  color: #101821;
}
.material-piece_essence {
  background: #c084fc !important;
  color: #101821;
}
#inventory {
  max-height: 380px;
  overflow: auto;
}
#events {
  padding-left: 20px;
  max-height: 650px;
  overflow: auto;
  font-size: 13px;
}
#events li {
  margin: 8px 0;
}
pre {
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
  font-size: 13px;
  max-height: 650px;
  overflow: auto;
  line-height: 1.5;
}
dialog {
  border: 1px solid #334760;
  border-radius: 12px;
  background: #141d2b;
  color: #e7edf5;
  max-width: min(750px, 95vw);
  max-height: 90dvh;
}
dialog::backdrop {
  background: #000b;
}
#recipe-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 18px;
}
.recipe-card {
  background: #1d2a3c;
  padding: 12px;
  border-radius: 8px;
}
.recipe-grid {
  width: 120px;
  margin: 12px 0;
}
.recipe-grid span {
  height: 35px;
  text-align: center;
  padding: 7px;
  background: #0b1018;
  border-radius: 3px;
}
.recipe-card p {
  font-size: 12px;
}
#choice-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}
#cutscene {
  padding: 0;
  max-width: 100vw;
  width: 100vw;
  max-height: 100dvh;
  background: black;
  text-align: center;
}
#movie,
#titlecard {
  max-width: 100%;
  max-height: 88dvh;
}
#skip {
  position: absolute;
  right: 15px;
  top: 15px;
  z-index: 2;
}
.reaction {
  position: fixed;
  z-index: 50;
  background: #e1264d;
  color: white;
  border: 3px solid white;
  font-weight: bold;
}
.reaction.parry {
  background: #337dc4;
}
.flash {
  animation: flash 0.25s;
}
@keyframes flash {
  50% {
    filter: brightness(3);
  }
}
[hidden] {
  display: none !important;
}
#connection {
  color: #65d6bc;
  font-size: 13px;
}
#opponent-inventory {
  font-size: 12px;
}
@media (max-width: 850px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .board-panel {
    max-width: 700px;
    width: 100%;
    margin: auto;
  }
  header,
  main {
    padding: 12px;
  }
  h1 {
    font-size: 17px;
  }
  header {
    align-items: flex-start;
  }
  header p {
    font-size: 12px;
  }
  .panel {
    padding: 14px;
  }
  .square .coordinate {
    font-size: 8px;
  }
  .square .badge {
    font-size: 9px;
  }
  .room-bar button {
    font-size: 12px;
    padding: 8px;
  }
  .craft-row {
    justify-content: flex-start;
  }
  #inventory {
    max-height: none;
  }
  .reaction {
    padding: 12px;
  }
  input {
    max-width: 100%;
    min-width: 0;
  }
  #join-form label {
    flex-wrap: wrap;
  }
  .square.castle-n {
    border-top-width: 3px;
  }
  .square.castle-s {
    border-bottom-width: 3px;
  }
  .square.castle-w {
    border-left-width: 3px;
  }
  .square.castle-e {
    border-right-width: 3px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
  }
}

.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 40;
  transform: translate(-50%, -50%);
  opacity: 0.85;
  filter: drop-shadow(0 5px 5px #0008);
}
