:root {
  --bg-1: #f2f0e8;
  --bg-2: #d8e6e7;
  --bg-3: #f3c086;
  --ink: #1b2329;
  --ink-soft: #42535f;
  --card: rgba(255, 255, 255, 0.82);
  --card-border: rgba(34, 49, 62, 0.13);
  --accent: #0d8a7f;
  --accent-2: #d66f2c;
  --danger: #b24535;
  --square-light: #f3e7cf;
  --square-dark: #c59167;
  --select: rgba(13, 138, 127, 0.25);
  --target: rgba(214, 111, 44, 0.32);
  --ring: rgba(13, 138, 127, 0.42);
  --radius: 20px;
  --shadow: 0 18px 45px rgba(20, 33, 45, 0.16);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, var(--bg-1), var(--bg-2));
}

.bg-layer {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 15% 12%, rgba(214, 111, 44, 0.35), transparent 30%),
    radial-gradient(circle at 90% 22%, rgba(13, 138, 127, 0.24), transparent 34%),
    radial-gradient(circle at 52% 86%, rgba(46, 86, 145, 0.18), transparent 36%);
  pointer-events: none;
  z-index: -2;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(25, 38, 51, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(25, 38, 51, 0.05) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(circle at 50% 50%, black, transparent 80%);
  pointer-events: none;
  z-index: -1;
}

.shell {
  width: min(1180px, 94vw);
  margin: 24px auto 48px;
}

.hero {
  padding: 26px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

.kicker {
  margin: 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 10px 0 8px;
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.12;
}

.hero-subtitle {
  margin: 0;
  max-width: 68ch;
  color: var(--ink-soft);
}

.mode-switch {
  margin-top: 18px;
  display: inline-flex;
  gap: 10px;
  padding: 8px;
  border-radius: 16px;
  background: rgba(15, 32, 49, 0.07);
}

.mode-btn {
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  color: var(--ink-soft);
  background: transparent;
  transition: transform 160ms ease, background-color 160ms ease, color 160ms ease;
}

.mode-btn:hover {
  transform: translateY(-1px);
}

.mode-btn.is-active {
  background: linear-gradient(135deg, var(--accent), #0b6f67);
  color: #f4fffc;
}

.view {
  display: none;
  margin-top: 20px;
  animation: rise 280ms ease;
}

.view.is-active {
  display: block;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(290px, 390px);
  gap: 18px;
  align-items: start;
}

.card {
  border-radius: var(--radius);
  border: 1px solid var(--card-border);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
  padding: 18px;
}

.card h2,
.card h3 {
  margin: 0;
}

.board-card {
  display: grid;
  gap: 14px;
}

.card-head {
  display: grid;
  gap: 6px;
}

.status-text {
  margin: 0;
  color: var(--ink-soft);
}

.board {
  width: 100%;
  max-width: 620px;
  aspect-ratio: 1 / 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(27, 35, 41, 0.2);
  background: #f0dcc3;
  margin-inline: auto;
}

.square {
  border: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  font-size: clamp(1.45rem, 5.1vw, 2.55rem);
  line-height: 1;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols2", sans-serif;
  transition: filter 110ms ease;
}

.square:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: -3px;
  z-index: 2;
}

.square:hover {
  filter: brightness(0.97);
}

.square.light {
  background: var(--square-light);
}

.square.dark {
  background: var(--square-dark);
}

.square.selected {
  box-shadow: inset 0 0 0 999px var(--select);
}

.square.target {
  box-shadow: inset 0 0 0 999px var(--target);
}

.square .coord-file,
.square .coord-rank {
  position: absolute;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.62rem;
  color: rgba(22, 30, 36, 0.62);
  pointer-events: none;
}

.square .coord-file {
  right: 5px;
  bottom: 3px;
}

.square .coord-rank {
  left: 5px;
  top: 3px;
}

.controls-card {
  display: grid;
  gap: 14px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--ink-soft);
}

input,
select,
button {
  font-family: inherit;
}

input,
select {
  border-radius: 10px;
  border: 1px solid rgba(19, 35, 47, 0.18);
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 11px;
  font-size: 0.95rem;
  color: var(--ink);
}

input:focus,
select:focus {
  outline: 2px solid var(--ring);
  border-color: transparent;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-btn,
.ghost-btn {
  border-radius: 10px;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
}

.action-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.action-btn {
  color: #f6fffd;
  background: linear-gradient(135deg, var(--accent), #0b746d);
  box-shadow: 0 8px 24px rgba(11, 116, 109, 0.3);
}

.ghost-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(19, 35, 47, 0.18);
}

.ghost-btn.danger {
  color: var(--danger);
  border-color: rgba(178, 69, 53, 0.35);
}

.group {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(19, 35, 47, 0.1);
}

.meta-block {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(19, 35, 47, 0.1);
}

.moves {
  margin: 0;
  padding-left: 1.35rem;
  max-height: 220px;
  overflow: auto;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.moves li {
  margin-bottom: 3px;
}

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

.clock-box {
  border-radius: 10px;
  border: 1px solid rgba(20, 33, 45, 0.16);
  padding: 10px;
  background: rgba(255, 255, 255, 0.74);
}

.clock-box p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.clock-box strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 1.18rem;
}

.room-meta p {
  margin: 0;
}

.room-meta a {
  color: var(--accent);
  font-weight: 600;
  word-break: break-all;
}

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

  .board {
    max-width: 100%;
  }
}

@media (max-width: 700px) {
  .shell {
    width: min(96vw, 640px);
    margin-top: 12px;
  }

  .hero,
  .card {
    border-radius: 14px;
    padding: 14px;
  }

  .mode-switch {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .action-row {
    display: grid;
    grid-template-columns: 1fr;
  }
}
