body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  background: #f6f6f6;
  color: #222;
}

.container {
  width: min(1200px, 94%);
  margin: 0 auto;
}

header {
  padding: 12px 0 10px;
}

h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
}

h3 {
  margin: 0 0 6px;
  font-size: 0.95rem;
}

nav {
  display: flex;
  gap: 10px;
}

nav a {
  text-decoration: none;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 10px;
  color: #333;
}

.top-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.left-column,
.right-column {
  display: grid;
  gap: 10px;
}

.card {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  border: 1px solid #e3e3e3;
}

.compact-card {
  padding-top: 8px;
  padding-bottom: 8px;
}

.notice {
  background: #fff6d8;
  border: 1px solid #f2dd8a;
  padding: 8px;
  border-radius: 6px;
}

.board-title {
  margin-bottom: 6px;
}

.last-move {
  background: #f3f7ff;
  border: 1px solid #c8d9ff;
  border-radius: 7px;
  padding: 7px 9px;
  margin: 0 0 8px;
  font-weight: 600;
}

.status-grid {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
}

.status-grid p {
  margin: 0;
  font-size: 0.95rem;
}

.board-layout {
  display: grid;
  grid-template-columns: minmax(100px, 150px) auto minmax(100px, 150px);
  gap: 8px;
  align-items: start;
}

.hand-box {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 6px;
  background: #fafafa;
}

.hand-pieces {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.hand-piece {
  border: 1px solid #bbb;
  border-radius: 6px;
  background: #fff;
  color: #333;
  padding: 4px 6px;
  line-height: 1.2;
}

.hand-piece.selectable {
  cursor: pointer;
}

.hand-piece.selected-hand {
  border-color: #2f6feb;
  box-shadow: inset 0 0 0 2px #2f6feb;
}

.active-hand {
  background: #eef5ff;
  border-radius: 6px;
  padding: 3px;
}

.empty-hand {
  color: #777;
}

.board-wrap {
  overflow-x: auto;
}

.top-coord {
  margin-left: 2px;
}

.board-main {
  display: flex;
  align-items: stretch;
}

.board-coord {
  border-collapse: collapse;
}

.board-coord th {
  width: 34px;
  height: 18px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #444;
}

.side-coord th {
  width: 20px;
  height: 34px;
}

.board {
  border-collapse: collapse;
  margin-top: 0;
}

.board td {
  width: 34px;
  height: 34px;
  border: 1px solid #555;
  text-align: center;
  background: #f3cd7b;
  font-weight: 700;
  cursor: pointer;
}

.piece {
  display: inline-block;
  line-height: 1;
}

.piece-opponent {
  transform: rotate(180deg);
}

.board td.selected-from {
  box-shadow: inset 0 0 0 3px #2f6feb;
}

.board td.selected-to {
  box-shadow: inset 0 0 0 3px #2e9f5b;
}

.board.mini td {
  width: 24px;
  height: 24px;
  font-size: 0.75rem;
}

.vote-form {
  display: grid;
  gap: 6px;
}

.vote-guide {
  margin: 6px 0;
  font-size: 0.95rem;
}

select,
button,
input {
  font-size: 0.96rem;
  padding: 7px;
}

button {
  background: #2f6feb;
  border: none;
  color: #fff;
  border-radius: 6px;
}

button:disabled {
  opacity: 0.6;
}

.ranking {
  list-style: none;
  padding: 0;
  margin: 0;
}

.ranking li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #eee;
  padding: 5px 0;
  gap: 6px;
}

.ranking li span:first-child {
  flex: 1;
}

.ranking-more {
  margin-top: 6px;
}

.adopted-move {
  font-weight: 700;
  background: #eef7ff;
}

.view-controls {
  margin: 6px 0 2px;
}

.toggle-link {
  display: inline-block;
  text-decoration: none;
  background: #1f7a36;
  color: #fff;
  padding: 7px 10px;
  border-radius: 6px;
}

.compact-details summary {
  cursor: pointer;
  font-weight: 600;
}

.compact-details p {
  margin: 8px 0 0;
  font-size: 0.92rem;
}

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

.history-nav form {
  margin: 0;
}

.history-table {
  width: 100%;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  border-bottom: 1px solid #eaeaea;
  text-align: left;
  padding: 8px;
}

.history-board td {
  cursor: default;
}

form.inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

@media (min-width: 980px) {
  .top-layout {
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
    gap: 12px;
  }

  .right-column {
    position: sticky;
    top: 10px;
  }
}

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

  .hand-box {
    order: 2;
  }

  .board-wrap {
    order: 1;
  }
}

@media (max-width: 600px) {
  .board td,
  .board-coord th {
    width: 30px;
    height: 30px;
    font-size: 0.9rem;
  }

  .side-coord th {
    width: 20px;
    height: 30px;
  }
}

.share-prompt {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: min(320px, calc(100vw - 24px));
  padding: 12px 14px 14px;
  border: 1px solid #c8d9ff;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.18);
  z-index: 20;
}

.share-prompt.is-visible {
  animation: sharePromptFadeIn 0.2s ease-out;
}

.share-prompt-label {
  margin: 0 28px 6px 0;
  font-size: 0.86rem;
  font-weight: 700;
  color: #1d4ed8;
}

.share-prompt-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
}

.share-prompt-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}

.share-prompt-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 999px;
  background: transparent;
  color: #555;
  border: 1px solid #d1d5db;
  line-height: 1;
}

@keyframes sharePromptFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

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

@media (max-width: 600px) {
  .share-prompt {
    right: 12px;
    bottom: 12px;
    width: calc(100vw - 24px);
  }
}
