:root {
  color-scheme: dark;
  --bg: #090e18;
  --bg-gradient: radial-gradient(circle at 10% 10%, #18243b 0%, #090e18 42%, #060912 100%);
  --panel: #151d2f;
  --panel-alt: #202c45;
  --panel-raised: #23314e;
  --border: #304764;
  --text: #e9f0ff;
  --muted: #a3b6d4;
  --accent: #64c4ff;
  --accent-soft: rgba(100, 196, 255, 0.18);
  --danger: #ff6f6f;
  --success: #54d6a1;
  --shadow: 0 14px 34px rgba(4, 8, 18, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg-gradient);
  color: var(--text);
  font-family: Inter, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100%;
}

body {
  overflow-x: hidden;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #0b1424 0%, #09101d 100%);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 0.8rem 1rem;
}

.top-bar h1 {
  margin: 0 0 0.6rem 0;
  font-size: 1.16rem;
  letter-spacing: 0.02em;
  font-weight: 700;
}

.setup-controls,
.multiplayer-controls {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.multiplayer-controls {
  margin-top: 0.5rem;
}

.setup-controls label,
.multiplayer-controls label {
  color: var(--muted);
  font-size: 0.83rem;
}

button,
select,
input {
  background: linear-gradient(180deg, #24314b 0%, #1b273d 100%);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 0.44rem 0.6rem;
  font-size: 0.86rem;
  transition: border-color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

input {
  min-width: 92px;
}

#session-password-input {
  min-width: 170px;
}

button:hover:not(:disabled),
select:hover,
input:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

#status-line,
#session-meta {
  font-size: 0.8rem;
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 400px;
  gap: 0.9rem;
  padding: 0.9rem;
}

.board-wrap {
  background: linear-gradient(180deg, #0f1728 0%, #0a1323 100%);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.6rem;
  box-shadow: var(--shadow);
}

#board-canvas {
  width: 100%;
  max-width: 100%;
  display: block;
  min-height: 62vh;
  background: radial-gradient(circle at 40% 16%, #11203a 0%, #0b1426 40%, #090f1d 100%);
  border: 1px solid #2b3f5d;
  border-radius: 0.62rem;
  touch-action: manipulation;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.72rem;
  max-height: calc(100vh - 1.2rem);
  overflow-y: auto;
  padding-right: 0.22rem;
}

.card {
  background: linear-gradient(180deg, #182235 0%, #121b2c 100%);
  border: 1px solid var(--border);
  border-radius: 0.72rem;
  padding: 0.68rem 0.78rem;
  box-shadow: var(--shadow);
}

.card h2 {
  margin: 0 0 0.42rem 0;
  font-size: 0.98rem;
  letter-spacing: 0.01em;
}

.card h3 {
  margin: 0.6rem 0 0.4rem;
  font-size: 0.86rem;
  color: var(--muted);
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.button-column {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fight-subcontrols {
  margin-top: 0.52rem;
}

.fight-subcontrols button {
  grid-column: span 2;
}

.inline-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.55rem;
}

.inline-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.21rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.hint {
  margin: 0.35rem 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.bilateral-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.bilateral-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.76rem;
  color: var(--muted);
}

#turn-info,
#current-player-summary {
  font-size: 0.84rem;
  line-height: 1.35;
}

#current-player-summary {
  margin-top: 0.42rem;
}

#selected-tile-info {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  white-space: pre-wrap;
  font-size: 0.74rem;
  line-height: 1.26;
  color: #dbe5f4;
}

#log-view {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.78rem;
  line-height: 1.31;
}

.log-entry {
  padding: 0.26rem 0.36rem;
  border-left: 2px solid #4b7fb8;
  background: #1a2840;
  border-radius: 0.28rem;
}

.log-entry.warn {
  border-left-color: var(--danger);
}

.log-entry.ok {
  border-left-color: var(--success);
}

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

  .sidebar {
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 860px) {
  .top-bar {
    padding: 0.7rem 0.75rem;
  }

  .top-bar h1 {
    font-size: 1.02rem;
  }

  .layout {
    padding: 0.55rem;
    gap: 0.58rem;
  }

  #board-canvas {
    min-height: 54vh;
  }

  button,
  select,
  input {
    font-size: 0.96rem;
    padding: 0.54rem 0.62rem;
  }

  .button-grid,
  .inline-controls,
  .bilateral-grid {
    grid-template-columns: 1fr;
  }

  .fight-subcontrols button {
    grid-column: span 1;
  }

  .card {
    padding: 0.65rem;
  }
}
