:root {
  --bg: #f3f0ea;
  --surface: #fffdf8;
  --surface-2: #f8f5ee;
  --chip: #efebe3;
  --ink: #17231f;
  --text: #24302c;
  --muted: #8a918b;
  --line: #e6e0d6;
  --line-strong: #d8d0c4;
  --green: #2f8f72;
  --green-dark: #206a55;
  --green-soft: #e6f4ee;
  --danger: #b85a4f;
  --nav: #737c78;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Hiragino Sans", Meiryo, sans-serif;
  letter-spacing: 0;
}
button, input, select, textarea { font: inherit; }
button {
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

.shell {
  position: relative;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px rgba(32, 28, 22, .06);
}
.side { display: none; }
.main {
  min-width: 0;
  padding: 0 12px 74px;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  min-height: 52px;
  margin: 0 -12px 10px;
  padding: 8px 12px 7px;
  background: rgba(255, 253, 248, .98);
  border-bottom: 1px solid var(--line);
}
.topbar h2 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.left-actions,
.topbar .actions {
  display: flex;
  align-items: center;
}
.left-actions { justify-content: flex-start; }
.topbar .actions { justify-content: flex-end; }

.icon-btn,
.back-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: var(--ink);
  font-size: 23px;
  font-weight: 500;
  line-height: 1;
}
.back-btn { font-size: 28px; }
.icon-btn.gear {
  font-size: 0;
}
.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
}
.btn.primary {
  color: #fff;
  border-color: var(--green);
  background: var(--green);
}
.btn.ghost {
  color: #6f706c;
  border-color: transparent;
  background: var(--chip);
}
.btn.danger {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}
.btn.publish {
  color: #fff;
  border-color: #315c9b;
  background: #315c9b;
}
.btn.unpublish {
  color: #fff;
  border-color: #8f5b20;
  background: #8f5b20;
}
.actions, .row, .chips, .card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.grid { display: grid; gap: 10px; }
.stats,
.stat-strip {
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.stat,
.stat-strip div {
  min-height: 72px;
  padding: 10px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-2);
  text-align: center;
}
.stat span,
.stat-strip span,
.stat-strip small {
  display: block;
  color: #7f8781;
  font-size: 10px;
  font-weight: 700;
}
.stat strong,
.stat-strip strong {
  display: block;
  margin: 4px 0 2px;
  color: var(--ink);
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
}

.panel, .form-card {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}
.panel + .panel,
.form-card + .panel { margin-top: 12px; }
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 32px;
  margin: 0;
  padding: 2px 0 8px;
}
.panel h3,
.form-card h3,
.section-title h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
}
.panel > h3 {
  margin: 14px 0 7px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.panel p {
  margin: 0 0 6px;
  color: #414b47;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.65;
}
.quiet-lead {
  margin: 4px 0 8px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
}
.dashboard { grid-template-columns: 1fr; }

.search-field {
  position: relative;
  margin-bottom: 8px;
}
.search-field span {
  position: absolute;
  left: 13px;
  top: 50%;
  color: #8a918b;
  transform: translateY(-50%);
}
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  font-size: 16px;
  font-weight: 600;
}
input[type="date"],
input[type="number"] {
  text-align: left;
}
.readonly-field {
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface-2);
  font-size: 16px;
  font-weight: 800;
}
.stepper-field {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.stepper-field button {
  width: 44px;
  min-height: 44px;
  color: var(--green);
  background: #f4f0ea;
  font-size: 22px;
  font-weight: 900;
}
.stepper-field input {
  min-height: 44px;
  border: 0;
  border-radius: 0;
  text-align: center;
}
.search-field input {
  height: 38px;
  padding-left: 34px;
  border-color: transparent;
  border-radius: 999px;
  background: #f2eee7;
}
.filter-strip {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 0 0 8px;
}
.filter-strip select,
.filter-clear {
  flex: 1 1 auto;
  width: auto;
  min-width: 54px;
  max-width: 100%;
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 999px;
  color: #53605b;
  background: var(--chip);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}
.filter-strip select {
  padding-right: 24px;
}
.filter-clear {
  color: var(--green-dark);
  background: var(--green-soft);
}

.cards {
  display: grid;
  gap: 0;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.game-card,
.list-card {
  position: relative;
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 12px;
  min-height: 96px;
  padding: 10px 26px 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: none;
}
.game-card::after,
.list-card::after {
  content: "›";
  position: absolute;
  right: 4px;
  top: 50%;
  color: #b3aaa1;
  font-size: 30px;
  line-height: 1;
  transform: translateY(-50%);
}
.cover {
  display: grid;
  place-items: center;
  width: 66px;
  height: 76px;
  overflow: hidden;
  border-radius: 5px;
  color: #fff;
  background: linear-gradient(150deg, #b4372b, #e2a12e 74%);
  text-align: center;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.18;
  box-shadow: 0 1px 0 rgba(255,255,255,.85), 0 5px 10px rgba(39, 30, 20, .13);
}
.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #f4efe6;
}
.game-card h4,
.list-card h4 {
  margin: 2px 22px 5px 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.meta {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
  color: #5f6964;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
.meta span {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
}
.small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.45;
}
.game-card .small,
.list-card .small {
  margin: 6px 0 0;
}
.detail-head {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 14px;
  padding: 0 0 12px;
}
.detail-head .cover {
  width: 112px;
  height: 126px;
}
.detail-head h3 {
  margin: 2px 0 2px;
  color: var(--ink);
  font-size: 18px;
  font-weight: 900;
  line-height: 1.25;
}
.detail-primary-action {
  display: flex;
  justify-content: flex-end;
  margin: 3px 0 8px;
}
.detail-primary-action .btn {
  min-height: 36px;
}
.detail-secondary-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin: 0 0 10px;
}
.detail-secondary-actions .btn.primary {
  min-height: 44px;
}
.detail-publish-action {
  display: flex;
  justify-content: flex-end;
  margin: 14px 0 10px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.detail-danger-action {
  display: flex;
  justify-content: flex-end;
  margin: 16px 0 6px;
}
.detail-danger-action .btn {
  min-height: 34px;
  padding-inline: 16px;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  margin-left: 7px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #7a6a5e;
  background: #eee9e2;
  font-size: 10px;
  font-weight: 900;
  vertical-align: 2px;
  white-space: nowrap;
}
.status-badge.large {
  margin-left: 8px;
  vertical-align: 3px;
}
.tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  margin: 8px 0 10px;
  border-bottom: 1px solid var(--line);
}
.tabs button {
  min-height: 38px;
  padding: 9px 4px 8px;
  border-bottom: 3px solid transparent;
  color: #7b837e;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}
.tabs button.active {
  color: var(--green);
  border-color: var(--green);
}
.settings-tabs {
  margin-top: 0;
}

textarea {
  min-height: 86px;
  resize: vertical;
}
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(29, 34, 31, 0.48);
}
.modal-panel {
  width: min(720px, 100%);
  max-height: min(86vh, 760px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(28, 31, 29, 0.28);
}
.modal-header {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line);
}
.modal-header h3 {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.modal-body {
  max-height: calc(min(86vh, 760px) - 58px);
  overflow: auto;
  padding: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.form-grid .full { grid-column: 1 / -1; }
label span {
  display: block;
  margin-bottom: 6px;
  color: #6f7772;
  font-size: 12px;
  font-weight: 800;
}
fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}
.option-group legend {
  margin-bottom: 7px;
  color: #6f7772;
  font-size: 12px;
  font-weight: 800;
}
.option-grid {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}
.check-chip {
  display: inline-flex;
}
.check-chip input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}
.check-chip span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  margin: 0;
  padding: 7px 11px;
  border-radius: 999px;
  color: #53605b;
  background: var(--chip);
  font-size: 12px;
  font-weight: 900;
}
.check-chip input:checked + span {
  color: #fff;
  background: var(--green);
}
.compact-form {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.genre-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.genre-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.genre-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 54px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.genre-name {
  overflow: hidden;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.genre-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.genre-row-edit {
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 7px;
  padding: 10px 0;
}
.genre-row-edit .genre-actions {
  justify-content: flex-end;
}
.genre-row input {
  min-height: 38px;
  padding: 8px 10px;
  border-color: var(--line);
  background: #fff;
  font-size: 16px;
  font-weight: 900;
}
.genre-row .btn {
  min-height: 34px;
  padding-inline: 12px;
}
.settings-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.6;
}
.admin-shell {
  width: min(720px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 16px 32px;
  background: var(--bg);
}
.admin-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.admin-header span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}
.admin-header h1 {
  margin: 0;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
  line-height: 1.2;
}
.play-picker {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
}
.picker-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.picker-row input {
  min-height: 42px;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
}
.today-strip { margin-top: 10px; }

.master-list {
  display: grid;
  gap: 0;
  max-height: 340px;
  overflow: auto;
  margin-top: 8px;
  border-top: 1px solid var(--line);
}
.master-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
}
.master-item strong {
  font-size: 13px;
  font-weight: 900;
}
.master-admin-list {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
}
.master-admin-row {
  display: grid;
  gap: 7px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.master-admin-main {
  display: grid;
  gap: 3px;
}
.master-admin-main strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.master-admin-main span,
.master-admin-row p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}
.master-admin-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.master-admin-meta span {
  min-height: 24px;
  padding: 5px 8px;
  border-radius: 999px;
  color: #53605b;
  background: var(--chip);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
}
.master-admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.master-admin-tools {
  display: grid;
  gap: 10px;
  margin: 0 0 12px;
}
.admin-tool-actions {
  justify-content: flex-start;
}
.master-admin-edit {
  padding: 14px 0;
}
.master-edit-form {
  display: grid;
  gap: 10px;
}
.master-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.btn.danger {
  border-color: #f1c6bd;
  color: #a93624;
  background: #fff5f2;
}
.btn.danger:hover {
  border-color: #d76d59;
  background: #ffe7df;
}
@media (min-width: 640px) {
  .master-edit-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
.bars {
  display: grid;
  gap: 10px;
}
.bar {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 26px;
  gap: 8px;
  align-items: center;
}
.bar-fill {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dcefe6;
}
.bar-fill i {
  display: block;
  height: 100%;
  background: var(--green);
}
.empty {
  padding: 22px 12px;
  color: var(--muted);
  text-align: center;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(248, 245, 238, .7);
  font-size: 12px;
  font-weight: 700;
}
.money-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  padding: 12px 0 0;
  border-top: 1px solid var(--line);
}
.money-panel strong {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  font-weight: 900;
}

.mobile-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  max-width: 430px;
  margin: 0 auto;
  padding: 5px 6px calc(5px + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, .985);
  border-top: 1px solid var(--line-strong);
  box-shadow: 0 -2px 10px rgba(40, 32, 24, .04);
}
.mobile-nav button {
  display: grid;
  grid-template-rows: 24px 15px;
  place-items: center;
  min-width: 0;
  min-height: 48px;
  color: var(--nav);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}
.mobile-nav .nav-ico {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  font-size: 22px;
  font-weight: 400;
  line-height: 1;
}
.mobile-nav .nav-label {
  overflow: hidden;
  max-width: 100%;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-nav button.active {
  color: var(--green);
}
.toast {
  position: fixed;
  right: 18px;
  bottom: calc(68px + env(safe-area-inset-bottom));
  left: 18px;
  z-index: 20;
  max-width: 394px;
  margin: 0 auto;
  padding: 11px 14px;
  border-radius: 999px;
  color: #fff;
  background: rgba(23, 35, 31, .92);
  box-shadow: 0 10px 26px rgba(23, 35, 31, .22);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

@media (min-width: 700px) {
  body { padding: 18px 0; }
  .shell {
    min-height: calc(100vh - 36px);
    min-height: calc(100dvh - 36px);
    border-radius: 8px;
  }
  .mobile-nav {
    bottom: 18px;
    border-radius: 0 0 8px 8px;
  }
}

@media (max-width: 360px) {
  .main { padding-inline: 10px; }
  .topbar { margin-inline: -10px; padding-inline: 10px; }
  .detail-head { grid-template-columns: 96px minmax(0, 1fr); }
  .detail-head .cover { width: 96px; height: 112px; }
  .form-grid,
  .picker-row { grid-template-columns: 1fr; }
  .stats,
  .stat-strip { grid-template-columns: repeat(3, 1fr); }
  .filter-strip select,
  .filter-clear { flex: 1 1 calc(33.333% - 7px); }
}
