*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f5f5f5;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 16px;
}

.site-header {
  margin-bottom: 20px;
}

.site-header h1 {
  margin: 0 0 10px;
  font-size: 1.875rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: 0.02em;
  color: #1976d2;
}

.site-brand a {
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  letter-spacing: inherit;
  text-decoration: none;
}

.site-brand a:hover {
  opacity: 0.85;
  text-decoration: none;
}

.site-tagline {
  margin: 0;
  color: #666;
  font-size: 0.875rem;
  line-height: 1.65;
  max-width: 42em;
}

.breadcrumb {
  margin-bottom: 12px;
}

.breadcrumb-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
  color: #777;
}

.breadcrumb-item + .breadcrumb-item::before {
  content: "/";
  margin-right: 6px;
  color: #bbb;
}

.breadcrumb-item a {
  color: #1976d2;
  text-decoration: none;
}

.breadcrumb-item a:hover {
  text-decoration: underline;
}

.seo-intro {
  margin-top: 20px;
  padding: 18px 20px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid #e8e8e8;
}

.seo-intro-title {
  margin: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #444;
}

.seo-intro p {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.7;
  color: #666;
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  font-weight: 700;
}

.tool-index {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.tool-index-heading {
  margin: 0 0 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #888;
  letter-spacing: 0.04em;
}

.tool-index-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.tool-index-card {
  display: block;
  padding: 16px 18px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  background: #fff;
  border: 1px solid #e0e0e0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.tool-index-card:hover {
  border-color: #1976d2;
  box-shadow: 0 4px 12px rgba(25, 118, 210, 0.12);
  transform: translateY(-1px);
}

.tool-index-card-title {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 700;
  color: #1976d2;
}

.tool-index-card-desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.55;
  color: #666;
}

.tool-note {
  margin: -8px 0 16px;
  color: #666;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.tool-nav-wrap {
  margin-bottom: 20px;
}

.tool-nav-group + .tool-nav-group {
  margin-top: 16px;
}

.tool-nav-heading {
  margin: 0 0 8px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #888;
  letter-spacing: 0.04em;
}

.tool-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tool-nav a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #555;
  background: #fff;
  border: 1px solid #ddd;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tool-nav a:hover {
  border-color: #999;
  color: #222;
}

.tool-nav a.is-active {
  background: #1976d2;
  border-color: #1976d2;
  color: #fff;
}

.tool-nav a.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

.card {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.card h2 {
  margin: 0 0 16px;
  font-size: 1.125rem;
  font-weight: 600;
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #444;
}

.field-row {
  margin-bottom: 16px;
}

.select-input {
  width: 100%;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  color: #333;
  background: #fff;
  cursor: pointer;
}

.select-input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.15);
}

textarea,
.output-pre {
  width: 100%;
  margin: 0;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.5;
  background: #fafafa;
}

textarea {
  min-height: 200px;
  resize: vertical;
}

textarea:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.15);
}

.text-input {
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 0.875rem;
  line-height: 1.5;
  background: #fafafa;
}

.text-input:focus {
  outline: none;
  border-color: #1976d2;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.15);
}

.text-input.is-error {
  border-color: #c62828;
  background: #fff8f8;
}

.text-input.is-valid {
  border-color: #2e7d32;
}

.field-grow {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.barcode-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.barcode-item {
  position: relative;
  padding: 16px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: #fff;
  overflow-x: auto;
}

.barcode-item.is-error {
  border-color: #ffcdd2;
  background: #fff8f8;
}

.barcode-item-name {
  margin: 0 0 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #333;
  text-align: left;
}

.barcode-item-body {
  display: flex;
  justify-content: center;
  align-items: center;
}

.barcode-item-body svg {
  max-width: 100%;
  height: auto;
}

.barcode-item-error {
  font-size: 0.875rem;
  color: #b71c1c;
  text-align: left;
}

.fortune-result {
  padding: 4px 0;
}

.fortune-date {
  margin: 0 0 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #666;
}

.fortune-rank {
  display: inline-block;
  margin-bottom: 16px;
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.fortune-rank-大吉,
.fortune-rank-吉 {
  background: #e8f5e9;
  color: #1b5e20;
}

.fortune-rank-中吉,
.fortune-rank-小吉 {
  background: #e3f2fd;
  color: #0d47a1;
}

.fortune-rank-末吉 {
  background: #fff8e1;
  color: #f57f17;
}

.fortune-rank-凶 {
  background: #ffebee;
  color: #b71c1c;
}

.fortune-table {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 8px 12px;
  margin: 0 0 16px;
  font-size: 0.875rem;
}

.fortune-table dt {
  margin: 0;
  color: #666;
  font-weight: 600;
}

.fortune-table dd {
  margin: 0;
  color: #222;
}

.fortune-summary {
  margin: 0 0 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #333;
}

.fortune-detail {
  margin: 0;
  font-size: 0.875rem;
  color: #555;
  line-height: 1.6;
}

.select-input {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-bottom: 16px;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
  color: #333;
}

.othello-board-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.othello-status {
  min-height: 1.5em;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #333;
}

.othello-score {
  display: flex;
  gap: 16px;
  font-size: 0.9375rem;
  font-weight: 600;
}

.othello-score-black {
  color: #1a1a1a;
}

.othello-score-white {
  color: #666;
}

.othello-board-wrap {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  aspect-ratio: 1;
}

.othello-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  gap: 2px;
  width: 100%;
  height: 100%;
  padding: 6px;
  background: #1b5e20;
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px #0d3d14;
}

.othello-cell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: #2e7d32;
  cursor: default;
}

.othello-cell:disabled {
  cursor: default;
  opacity: 1;
}

.othello-cell.is-valid:not(:disabled) {
  cursor: pointer;
}

.othello-cell.is-valid:not(:disabled):hover {
  background: #388e3c;
}

.othello-cell.is-valid::after {
  content: "";
  position: absolute;
  inset: 30%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  pointer-events: none;
}

.othello-cell.is-last {
  box-shadow: inset 0 0 0 2px #ffeb3b;
}

.othello-cell.is-black::before,
.othello-cell.is-white::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  pointer-events: none;
}

.othello-cell.is-black::before {
  background: radial-gradient(circle at 30% 30%, #555, #111);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.4);
}

.othello-cell.is-white::before {
  background: radial-gradient(circle at 30% 30%, #fff, #ddd);
  box-shadow: inset 0 -2px 4px rgba(0, 0, 0, 0.15);
}

.othello-side .label {
  margin-top: 4px;
}

.othello-actions {
  margin-bottom: 16px;
  align-items: center;
}

.othello-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8125rem;
  color: #555;
  cursor: pointer;
}

.othello-json {
  width: 100%;
  min-height: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  resize: vertical;
}

.game-layout,
.othello-layout {
  display: grid;
  gap: 24px;
}

@media (min-width: 768px) {
  .game-layout,
  .othello-layout {
    grid-template-columns: minmax(280px, 420px) 1fr;
    align-items: start;
  }
}

.game-side .label,
.othello-side .label {
  margin-top: 4px;
}

.game-actions,
.othello-actions {
  margin-bottom: 16px;
  align-items: center;
}

.game-json,
.othello-json {
  width: 100%;
  min-height: 200px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  resize: vertical;
}

textarea.is-error {
  border-color: #c62828;
  background: #fff8f8;
}

textarea.is-valid {
  border-color: #2e7d32;
}

.message {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.875rem;
}

.message-error {
  background: #ffebee;
  color: #b71c1c;
  border: 1px solid #ffcdd2;
}

.message-ok {
  background: #e8f5e9;
  color: #1b5e20;
  border: 1px solid #c8e6c9;
}

.message-info {
  background: #e3f2fd;
  color: #0d47a1;
  border: 1px solid #bbdefb;
}

.is-hidden {
  display: none;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

button {
  padding: 10px 18px;
  border: none;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

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

.btn-primary {
  background: #1976d2;
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: #1565c0;
}

.btn-secondary {
  background: #eee;
  color: #333;
  border: 1px solid #ccc;
}

.btn-secondary:hover:not(:disabled) {
  background: #e0e0e0;
}

.output-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #eee;
}

.output-section.is-hidden {
  display: none;
}

.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.output-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.download-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.label-inline {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.select-input-compact {
  width: auto;
  min-width: 120px;
  padding: 8px 10px;
}

.output-pre {
  min-height: 120px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.placeholder-page {
  text-align: center;
  padding: 40px 20px;
  color: #666;
}

.field-row-inline {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.checkbox-field {
  padding-bottom: 10px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  color: #444;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.table-meta {
  font-size: 0.8125rem;
  color: #666;
  font-weight: 500;
}

.sheet-wrap {
  overflow: auto;
  max-height: 480px;
  border: 1px solid #b0b0b0;
  border-radius: 4px;
  background: #fff;
  box-shadow: inset 0 0 0 1px #e8e8e8;
}

.sheet-table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  line-height: 1.4;
}

.sheet-table th,
.sheet-table td {
  border: 1px solid #d4d4d4;
  padding: 4px 8px;
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

.sheet-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f3f3f3;
  font-weight: 600;
  color: #555;
  text-align: center;
}

.sheet-table thead tr:nth-child(2) th {
  top: 29px;
  z-index: 2;
}

.sheet-corner {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 42px;
  background: #ececec;
}

.sheet-col-head {
  min-width: 80px;
}

.sheet-row-head {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 42px;
  background: #ececec;
  font-weight: 600;
  color: #555;
  text-align: center;
}

.sheet-header-cell {
  background: #e8f0fe;
  color: #1a237e;
  text-align: left;
  font-weight: 600;
}

.sheet-table tbody tr:nth-child(even) td {
  background: #fafafa;
}

.sheet-table tbody tr:hover td {
  background: #fff9c4;
}

.sheet-table tbody td {
  background: #fff;
  color: #222;
  font-family: ui-monospace, "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.sheet-editable {
  cursor: text;
}

.sheet-editable:focus {
  outline: 2px solid #1976d2;
  outline-offset: -2px;
  background: #fff !important;
  white-space: pre-wrap;
  overflow: visible;
  text-overflow: unset;
  max-width: none;
}

@media (max-width: 480px) {
  .container {
    padding: 16px 12px;
  }

  .card {
    padding: 16px;
  }

  textarea {
    min-height: 160px;
  }
}
