:root {
  --bg: #f6f8fb;
  --panel: #ffffff;
  --ink: #1f2937;
  --muted: #5f6b7a;
  --line: #c7ced8;
  --site-primary: #0d6b8f;
  --site-primary-dark: #09506b;
  --closed: #9da9b8;
  --closed-dark: #667385;
  --open: #f9fafb;
  --open-line: #d7dde5;
  --neighbor-closed: #e2b928;
  --neighbor-open: #fff3a3;
  --hover: #f7a01f;
  --mine: #c0392b;
  --flag: #c2410c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 8%, rgba(13, 107, 143, 0.12), transparent 28rem),
    linear-gradient(180deg, #eef5fa 0%, var(--bg) 38%, #ffffff 100%);
  color: var(--ink);
  font-family: "Segoe UI", "Yu Gothic UI", Meiryo, sans-serif;
}

/* 研究所トップと同じ戻り導線にして、ゲーム操作の邪魔にならない位置に置きます。 */
.site-header,
.site-footer {
  width: min(100% - 32px, 1200px);
  margin: 0 auto;
}

.site-header {
  padding: 22px 0 8px;
}

.site-footer {
  padding: 22px 0 32px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--site-primary);
  font-weight: 700;
  text-decoration: none;
}

.back-link::before {
  content: "←";
  font-size: 1.05em;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--site-primary-dark);
}

.app {
  width: min(100% - 32px, 1200px);
  margin: 0 auto;
  padding: 14px 0 18px;
}

.app-header {
  margin-bottom: 16px;
  padding: 18px 20px;
  border: 1px solid rgba(217, 225, 236, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 28px rgba(22, 32, 51, 0.07);
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  letter-spacing: 0;
}

.torus-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.control-panel,
.status-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(199, 206, 216, 0.92);
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(31, 41, 55, 0.05);
}

.field,
.debug-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.field {
  flex-direction: column;
  align-items: flex-start;
  color: var(--muted);
  font-size: 13px;
}

.field input {
  width: 88px;
  height: 34px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 16px;
}

.debug-field {
  min-height: 34px;
  color: var(--muted);
  user-select: none;
}

button {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--site-primary-dark);
  border-radius: 6px;
  background: var(--site-primary);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

button:hover {
  background: var(--site-primary-dark);
}

.status-panel {
  align-items: stretch;
}

.status-panel>div {
  min-width: 112px;
  padding-right: 12px;
  border-right: 1px solid var(--line);
}

.status-panel>div:last-child {
  border-right: 0;
}

.status-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.message {
  min-height: 22px;
  margin: 0 0 8px;
  color: #b45309;
  font-size: 14px;
}

.board-shell {
  display: grid;
  grid-template-columns: 32px max-content 32px;
  grid-template-rows: 32px max-content 32px;
  width: max-content;
  max-width: 100%;
  overflow: auto;
  padding: 8px;
  border: 2px solid #596579;
  border-radius: 8px;
  background: #596579;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.12);
}

.board,
.ghost-row,
.ghost-column,
.ghost-corner {
  display: grid;
  background: #596579;
}

.board {
  width: max-content;
  border: 2px solid #2f3b4c;
}

.cell {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #6f7a8a;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  user-select: none;
  cursor: pointer;
}

.cell-closed {
  background: linear-gradient(135deg, #c8d0dc 0%, var(--closed) 42%, var(--closed-dark) 100%);
  box-shadow: inset 1px 1px 0 #e8edf3, inset -1px -1px 0 #4f5b6c;
}

.cell-open {
  background: var(--open);
  border-color: var(--open-line);
  box-shadow: none;
  cursor: default;
}

.cell-flagged {
  color: var(--flag);
}

.cell-mine {
  color: var(--mine);
}

.cell-debug-mine {
  color: rgba(192, 57, 43, 0.4);
}

.cell-closed.cell-neighbor {
  background: linear-gradient(135deg, #f7db66 0%, var(--neighbor-closed) 52%, #a97d12 100%);
}

.cell-open.cell-neighbor {
  background: var(--neighbor-open);
}

.cell-hover {
  outline: 3px solid var(--hover);
  outline-offset: -3px;
  z-index: 1;
}

.ghost-cell {
  pointer-events: none;
  opacity: 0.48;
  filter: saturate(0.85);
}

.ghost-corner {
  width: 32px;
  height: 32px;
}

.num-1 {
  color: #2563eb;
}

.num-2 {
  color: #15803d;
}

.num-3 {
  color: #dc2626;
}

.num-4 {
  color: #4338ca;
}

.num-5 {
  color: #b45309;
}

.num-6 {
  color: #0f766e;
}

.num-7 {
  color: #111827;
}

.num-8 {
  color: #6b7280;
}

@media (max-width: 700px) {

  .site-header,
  .site-footer {
    width: min(100% - 20px, 1200px);
  }

  .app {
    width: min(100% - 20px, 1200px);
    padding-top: 8px;
  }

  .app-header {
    padding: 14px;
  }

  .status-panel>div {
    min-width: 96px;
  }
}

#version-history {
  width: 100%
}