:root {
  color-scheme: light;
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-soft: #eef2ec;
  --text: #15201c;
  --muted: #65716b;
  --border: #d9e1dc;
  --accent: #176b55;
  --accent-strong: #0e4f3d;
  --danger: #a6423a;
  --shadow: 0 18px 50px rgba(31, 44, 38, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.1;
  font-weight: 750;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.panel-head p {
  color: var(--muted);
  margin-top: 4px;
  font-size: 13px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 440px);
  gap: 16px;
  align-items: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.capture-panel,
.board-panel {
  grid-column: 1;
}

.rack-panel,
.result-panel {
  grid-column: 2;
}

.row-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

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

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 210px;
  overflow: hidden;
  border: 1px dashed #aeb9b3;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 650;
  cursor: pointer;
}

.dropzone input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.dropzone img {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dropzone.has-image span {
  position: absolute;
  left: 10px;
  top: 10px;
  z-index: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 12px;
}

.dropzone.has-image img {
  display: block;
}

.tile-form {
  display: grid;
  grid-template-columns: 1fr 76px auto auto;
  gap: 8px;
  margin: 14px 0;
}

select,
input {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 0 10px;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  background: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.secondary:hover {
  border-color: #aeb9b3;
}

.tile-list,
.meld-tiles {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
}

.tile {
  width: 50px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: 2px solid currentColor;
  background: #fff;
  font-weight: 800;
}

.tile.red {
  color: #b73b35;
}

.tile.blue {
  color: #245eb8;
}

.tile.black {
  color: #1b1f24;
}

.tile.orange {
  color: #c96b1f;
}

.tile.joker {
  width: 70px;
  color: #6b3fa0;
}

.melds {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.meld {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfb;
}

.meld-tools {
  display: flex;
  gap: 8px;
}

.mini-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.mini-form select,
.mini-form input {
  min-height: 36px;
}

.mini-form input {
  width: 72px;
}

.mini-form button,
.meld-tools button {
  min-height: 36px;
}

.results {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.results.empty {
  color: var(--muted);
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fbfcfb;
}

.move-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.move-card strong {
  display: block;
  font-size: 15px;
  margin-bottom: 8px;
}

.move-card ol {
  margin: 0;
  padding-left: 20px;
  color: #2b3832;
}

.move-card li + li {
  margin-top: 6px;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e5eee8;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 750;
}

@media (max-width: 920px) {
  .shell {
    width: min(100vw - 20px, 680px);
    padding-top: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .capture-panel,
  .board-panel,
  .rack-panel,
  .result-panel {
    grid-column: 1;
  }

  .photo-grid {
    grid-template-columns: 1fr;
  }

  .tile-form {
    grid-template-columns: 1fr 72px;
  }
}
