:root {
  color-scheme: dark;
  --bg: #14110f;
  --bg-soft: #1f1b18;
  --panel: #2a2520;
  --panel-2: #342d27;
  --line: #5a4b3f;
  --line-soft: #433930;
  --text: #f7eee3;
  --muted: #c9b8a4;
  --dim: #8d7f72;
  --gold: #e5b85b;
  --teal: #65c7bd;
  --rose: #d87a8d;
  --green: #82bd65;
  --bad: #e16c61;
  --good: #9dd77a;
  --shadow: rgba(0, 0, 0, 0.28);
  --radius: 8px;
  --font: "Yu Gothic UI", "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(229, 184, 91, 0.05) 1px, transparent 1px),
    linear-gradient(0deg, rgba(101, 199, 189, 0.04) 1px, transparent 1px),
    linear-gradient(180deg, #18130f 0%, #14110f 52%, #1a1613 100%);
  background-size: 36px 36px, 36px 36px, auto;
  color: var(--text);
  font-family: var(--font);
  letter-spacing: 0;
}

button,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #3a3129;
  color: var(--text);
  cursor: pointer;
}

a {
  color: inherit;
}

button:hover:not(:disabled) {
  border-color: var(--gold);
  background: #453a30;
}

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

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1d1916;
  color: var(--text);
  padding: 8px 10px;
}

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

.top-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.title-block h1 {
  margin: 0;
  font-size: 1.4rem;
  font-weight: 800;
}

.night-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.94rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(42, 37, 32, 0.78);
  white-space: nowrap;
}

.pill.ideal {
  border-color: rgba(101, 199, 189, 0.55);
  color: #bdeee8;
}

.pill.danger {
  border-color: rgba(225, 108, 97, 0.55);
  color: #ffc4bf;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.reset-button {
  min-height: 40px;
  padding: 0 14px;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.reset-button.active {
  border-color: rgba(101, 199, 189, 0.78);
  background: #31413c;
  color: #d5fbf6;
}

.result-banner.compact {
  padding: 10px 14px;
}

.online-join-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.join-panel {
  width: min(520px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 37, 32, 0.94);
  padding: 22px;
  box-shadow: 0 18px 44px var(--shadow);
}

.join-panel h1 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.join-panel p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.55;
}

.join-form {
  display: grid;
  gap: 12px;
}

.join-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.join-form input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1d1916;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
}

.join-error {
  margin-top: 14px;
  color: #ffc4bf;
}

.text-link {
  display: inline-flex;
  margin-top: 16px;
  color: #bdeee8;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.result-banner {
  margin-bottom: 14px;
  border: 1px solid rgba(229, 184, 91, 0.62);
  border-radius: var(--radius);
  background: rgba(65, 49, 27, 0.84);
  padding: 14px 16px;
  box-shadow: 0 8px 24px var(--shadow);
}

.result-banner h2 {
  margin: 0 0 6px;
  font-size: 1.16rem;
}

.result-banner p {
  margin: 0;
  color: #ffe1a3;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.master-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 37, 32, 0.9);
  padding: 12px;
}

.master-panel.active {
  border-color: rgba(101, 199, 189, 0.78);
  box-shadow: inset 0 0 0 1px rgba(101, 199, 189, 0.18);
}

.master-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.master-name {
  margin: 0;
  font-size: 1rem;
}

.submit-state {
  min-width: 72px;
  text-align: right;
  color: var(--muted);
  font-size: 0.86rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  min-height: 66px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgba(31, 27, 24, 0.82);
  padding: 8px;
}

.stat-label {
  color: var(--dim);
  font-size: 0.78rem;
}

.stat-value {
  display: block;
  margin-top: 4px;
  font-size: 1.24rem;
  font-weight: 800;
}

.stat-value.good {
  color: var(--good);
}

.stat-value.bad {
  color: var(--bad);
}

.good {
  color: var(--good);
}

.bad {
  color: var(--bad);
}

.board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.dream-zone {
  min-height: 246px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(101, 199, 189, 0.08), transparent 34%),
    linear-gradient(225deg, rgba(216, 122, 141, 0.07), transparent 36%),
    rgba(31, 27, 24, 0.92);
  padding: 12px;
}

.zone-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.zone-head h2 {
  margin: 0;
  font-size: 1.02rem;
}

.zone-total {
  color: var(--muted);
  font-size: 0.9rem;
}

.object-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(142px, 1fr));
  gap: 10px;
}

.empty-dream {
  min-height: 172px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-soft);
  border-radius: 6px;
  color: var(--dim);
}

.object-token {
  min-height: 132px;
  display: grid;
  grid-template-rows: 50px auto auto;
  gap: 6px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(52, 45, 39, 0.9);
  padding: 10px;
}

.object-art {
  width: 48px;
  height: 48px;
}

.object-name {
  margin: 0;
  font-weight: 800;
}

.object-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.planning {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(340px, 0.88fr);
  gap: 12px;
  margin-bottom: 14px;
}

.play-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(42, 37, 32, 0.9);
  padding: 12px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.04rem;
}

.cost-line {
  color: var(--muted);
  font-size: 0.9rem;
}

.hand-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 10px;
}

.hand-card {
  width: 100%;
  min-height: 190px;
  display: grid;
  grid-template-rows: auto 58px auto 1fr auto;
  gap: 7px;
  text-align: left;
  padding: 10px;
  border-radius: var(--radius);
  border-color: var(--line);
  background: linear-gradient(180deg, #41362d 0%, #2b2520 100%);
}

.hand-card.selected {
  border-color: var(--teal);
  box-shadow: inset 0 0 0 1px rgba(101, 199, 189, 0.34);
}

.card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.card-name {
  font-weight: 800;
  line-height: 1.25;
}

.card-cost {
  min-width: 28px;
  height: 28px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #22180b;
  font-weight: 900;
}

.card-art {
  width: 58px;
  height: 58px;
  justify-self: center;
}

.card-kind {
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 700;
}

.card-text {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.card-action {
  color: var(--gold);
  font-size: 0.82rem;
  font-weight: 800;
}

.draft-list {
  display: grid;
  gap: 10px;
}

.empty-draft,
.empty-hand {
  min-height: 112px;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-soft);
  border-radius: 6px;
  color: var(--dim);
  text-align: center;
}

.draft-card {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(31, 27, 24, 0.82);
  padding: 10px;
}

.draft-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  margin-bottom: 8px;
}

.draft-title {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 800;
}

.remove-button {
  width: 34px;
  height: 34px;
}

.submit-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.submit-button {
  min-width: 148px;
  min-height: 42px;
  padding: 0 16px;
  background: #31413c;
  border-color: rgba(101, 199, 189, 0.54);
}

.submit-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.log-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(31, 27, 24, 0.92);
  padding: 12px;
}

.log-panel h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.log-list {
  display: grid;
  gap: 6px;
  max-height: 280px;
  overflow: auto;
  padding-right: 4px;
}

.log-entry {
  border-left: 3px solid var(--line);
  padding: 5px 0 5px 9px;
  color: var(--muted);
  line-height: 1.45;
}

.log-entry.important {
  border-color: var(--gold);
  color: var(--text);
}

.log-entry.bad {
  border-color: var(--bad);
  color: #ffd0cc;
}

.svg-line {
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (max-width: 960px) {
  .top-bar,
  .scoreboard,
  .board,
  .planning {
    grid-template-columns: 1fr;
  }

  .top-actions {
    justify-content: stretch;
  }

  .reset-button {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 12px;
  }

  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hand-grid,
  .object-grid {
    grid-template-columns: 1fr;
  }

  .submit-row {
    grid-template-columns: 1fr;
  }

  .submit-button {
    width: 100%;
  }
}
