:root {
  --bg: #08151e;
  --bg2: #102535;
  --panel: rgba(12, 25, 37, 0.92);
  --text: #ecf6ff;
  --muted: #9bb3c9;
  --accent: #69d8ff;
  --accent-2: #9ef5b2;
  --danger: #ff7e7e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background:
    radial-gradient(circle at 20% -10%, #1f4666 0%, transparent 30%),
    radial-gradient(circle at 80% -20%, #193f54 0%, transparent 28%),
    linear-gradient(170deg, var(--bg), var(--bg2));
  color: var(--text);
}

.topbar {
  padding: 0.7rem 1rem;
  background: rgba(3, 8, 14, 0.85);
  border-bottom: 1px solid #2b4a63;
  backdrop-filter: blur(4px);
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  gap: 12px;
  height: calc(100vh - 47px);
  padding: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid #27435a;
  border-radius: 14px;
  padding: 12px;
  overflow: auto;
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.15);
}

.panel.left {
  background:
    radial-gradient(circle at 12% 0%, rgba(105, 216, 255, 0.14), transparent 40%),
    var(--panel);
}

.panel h2,
.panel h3 {
  margin: 0.35rem 0 0.6rem;
}

button {
  background: linear-gradient(180deg, #2f6e95, #214d6a);
  color: white;
  border: 1px solid #4f8bb1;
  border-radius: 10px;
  padding: 9px;
  cursor: pointer;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  filter: brightness(1.08);
}

button:active {
  transform: translateY(1px);
}

button.active {
  outline: 2px solid var(--accent-2);
  box-shadow: 0 0 0 3px rgba(158, 245, 178, 0.2);
}

#buildButtons button {
  text-align: left;
  font-size: 0.88rem;
}

#buildButtons {
  display: grid;
  gap: 7px;
}

.hint {
  margin-top: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.3;
}

.questList {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.45rem;
}

.questList li {
  color: var(--muted);
}

.questList li.done {
  color: var(--accent-2);
}

.statusList {
  margin: 0;
  padding-left: 1rem;
  display: grid;
  gap: 0.3rem;
  color: var(--muted);
}

.canvasWrap {
  background: #07131c;
  border-radius: 14px;
  overflow: hidden;
  min-height: 400px;
  border: 1px solid #214159;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.32);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.tileInfo {
  font-size: 0.92rem;
  color: var(--muted);
  background: #0a1924;
  border: 1px solid #2a4f66;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 10px;
  min-height: 60px;
}

.chatLog {
  background: #0b1623;
  border-radius: 10px;
  border: 1px solid #2a455b;
  padding: 8px;
  height: 220px;
  overflow-y: auto;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

#chatForm {
  display: flex;
  gap: 6px;
}

#chatInput {
  flex: 1;
}

input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #3a6078;
  background: #0f202f;
  color: white;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(1, 2, 5, 0.68);
  display: grid;
  place-items: center;
  z-index: 10;
}

.card {
  width: min(460px, 95vw);
  background: linear-gradient(180deg, #152739, #0e1c2a);
  border: 1px solid #315470;
  padding: 1rem;
  border-radius: 12px;
  display: grid;
  gap: 8px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

#toast {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--danger);
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  display: none;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }

  .canvasWrap {
    height: 62vh;
  }
}
