:root {
  --bg: #262421;
  --panel: #33302c;
  --panel2: #3d3934;
  --text: #eeeae4;
  --muted: #a29b90;
  --accent: #7fb04d;
  --accent-h: #91c45c;
  --danger: #d0533f;
  --light: #eeeed2;
  --dark: #769656;
  --sel: rgba(255, 221, 60, .65);
  --last: rgba(255, 221, 60, .35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a {
  color: var(--accent-h);
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--panel2);
  color: var(--text);
}

button:hover {
  background: #4a453f;
}

button.primary {
  background: var(--accent);
  color: #10200a;
  font-weight: 700;
}

button.primary:hover {
  background: var(--accent-h);
}

button.danger:hover {
  background: var(--danger);
}

button:disabled {
  opacity: .5;
  cursor: default;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  max-width: 1200px;
  margin: 0 auto;
}

.logo {
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  text-decoration: none;
  letter-spacing: .5px;
}

.logo span {
  color: var(--accent-h);
}

/* Home */
.home {
  max-width: 760px;
  margin: 0 auto;
  padding: 8px 16px 60px;
}

.hero h1 {
  font-size: 40px;
  margin: 12px 0 4px;
}

.hero p {
  color: var(--muted);
  font-size: 17px;
  margin: 0 0 20px;
}

.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}

.row label.lbl {
  width: 100%;
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.seg {
  display: inline-flex;
  background: var(--bg);
  border-radius: 8px;
  overflow: hidden;
}

.seg input {
  display: none;
}

.seg label {
  padding: 8px 14px;
  cursor: pointer;
}

.seg input:checked+label {
  background: var(--accent);
  color: #10200a;
  font-weight: 700;
}

.rules h3 {
  margin: 18px 0 6px;
  font-size: 15px;
  color: var(--accent-h);
}

.rules ul {
  margin: 0;
  padding-left: 20px;
}

.rules li {
  margin: 3px 0;
}

.rules .pc-ico {
  display: inline-block;
  width: 1.5em;
  text-align: center;
}

/* Game layout */
.game {
  display: grid;
  gap: 16px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 12px 30px;
  grid-template-columns: minmax(0, auto) minmax(260px, 1fr);
  align-items: start;
}

.left {
  --bs: min(calc(100vw - 24px), calc(100vh - 150px), 780px);
  width: var(--bs);
}

.bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px;
  min-height: 40px;
}

.who {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #666;
}

.dot.on {
  background: #6cc24a;
}

.sw {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #000;
}

.sw.w {
  background: #fff;
}

.sw.b {
  background: #111;
  border-color: #888;
}

.clock {
  font: 700 20px ui-monospace, Menlo, monospace;
  background: var(--panel);
  padding: 3px 10px;
  border-radius: 6px;
  min-width: 76px;
  text-align: center;
}

.clock.run {
  background: var(--accent);
  color: #10200a;
}

.clock.low {
  background: var(--danger);
  color: #fff;
}

#board {
  width: var(--bs);
  height: var(--bs);
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 1fr;
  font-size: calc(var(--bs) / 12);
  user-select: none;
  -webkit-user-select: none;
  border-radius: 4px;
  overflow: hidden;
}

.sq {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
}

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

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

.sq.last::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--last);
}

.sq.sel::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--sel);
}

.sq.check {
  background: radial-gradient(circle, #ff3b30 0%, #ff3b30 30%, transparent 75%), var(--dark);
}

.sq.check.light {
  background: radial-gradient(circle, #ff3b30 0%, #ff3b30 30%, transparent 75%), var(--light);
}

.sq.mine {
  cursor: pointer;
}

.sq.tgt {
  cursor: pointer;
}

.sq.tgt::after {
  content: "";
  position: absolute;
  width: 26%;
  height: 26%;
  border-radius: 50%;
  background: rgba(20, 20, 20, .28);
}

.sq.tgt.cap::after {
  width: 92%;
  height: 92%;
  background: transparent;
  border: .09em solid rgba(220, 50, 40, .75);
}

.sq.tgt.castle::after {
  width: 60%;
  height: 60%;
  background: transparent;
  border: .08em dashed rgba(30, 90, 200, .9);
}

.co {
  position: absolute;
  font-size: .17em;
  font-weight: 700;
  opacity: .75;
  pointer-events: none;
}

.co.file {
  right: 4px;
  bottom: 2px;
}

.co.rank {
  left: 4px;
  top: 2px;
}

.sq.light .co {
  color: var(--dark);
}

.sq.dark .co {
  color: var(--light);
}

.pc {
  position: relative;
  z-index: 1;
  line-height: 1;
  pointer-events: none;
}

.pc.g {
  font-size: .84em;
}

.pc.g.w {
  color: #fff;
  text-shadow: -1px 0 #222, 1px 0 #222, 0 -1px #222, 0 1px #222, 0 2px 3px rgba(0, 0, 0, .35);
}

.pc.g.b {
  color: #1b1b1b;
  text-shadow: 0 0 2px rgba(255, 255, 255, .35);
}

.pc.e {
  width: .8em;
  height: .8em;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: .05em solid;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .4);
}

.pc.e.w {
  background: #fafafa;
  border-color: #333;
}

.pc.e.b {
  background: #3b3b3b;
  border-color: #e8e8e8;
}

.pc.e span {
  font-size: .5em;
}

.pc.e i {
  position: absolute;
  bottom: -.02em;
  right: -.02em;
  font: 800 .2em system-ui;
  background: #000;
  color: #fff;
  border-radius: 50%;
  width: 1.4em;
  height: 1.4em;
  display: flex;
  align-items: center;
  justify-content: center;
}

aside {
  background: var(--panel);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.status {
  font-weight: 700;
  font-size: 17px;
}

.status.over {
  color: #ffd45c;
}

.note {
  color: var(--muted);
  font-size: 13px;
}

.invite {
  background: var(--bg);
  border-radius: 8px;
  padding: 10px;
}

.invite input {
  width: 100%;
  background: var(--panel2);
  color: var(--text);
  border: 0;
  padding: 8px;
  border-radius: 6px;
  margin: 8px 0;
  font: inherit;
}

.moves {
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
  height: 220px;
  overflow: auto;
  font: 13px ui-monospace, Menlo, monospace;
}

.moves div {
  display: grid;
  grid-template-columns: 34px 1fr 1fr;
  gap: 4px;
  padding: 1px 0;
}

.moves .n {
  color: var(--muted);
}

.moves .cur {
  background: rgba(255, 221, 60, .25);
  border-radius: 3px;
}

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

.offer {
  background: #4b3f22;
  border-radius: 8px;
  padding: 10px;
}

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
}

.modal {
  background: var(--panel);
  border-radius: 12px;
  padding: 18px;
  max-width: 640px;
  max-height: 88vh;
  overflow: auto;
  width: 100%;
}

.modal h2 {
  margin-top: 0;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choices button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 76px;
}

.choices .ico {
  font-size: 30px;
  line-height: 1.1;
}

@media (max-width: 860px) {
  .game {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .left {
    --bs: min(calc(100vw - 16px), 780px);
  }

  aside {
    width: 100%;
  }

  .hero h1 {
    font-size: 32px;
  }
}