:root {
  --font-display: "Bree Serif", Georgia, serif;
  --font-ui: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --espresso: #2a1207;
  --dark-roast: #3d1b08;
  --mocha: #6d3511;
  --caramel: #d9822b;
  --cream: #fff3d7;
  --foam: #fffaf0;
  --blue: #7896aa;
  --line: rgba(86, 42, 13, 0.18);
  --shadow: 0 10px 22px rgba(67, 31, 8, 0.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #f4cf97; }
body {
  color: var(--espresso);
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at 14% 0%, rgba(255, 250, 240, 0.80), transparent 18rem),
    radial-gradient(circle at 92% 8%, rgba(120, 150, 170, 0.22), transparent 20rem),
    linear-gradient(180deg, #f8dfb1 0%, #f4cf97 48%, #edc181 100%);
  overscroll-behavior: none;
}
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:active { transform: scale(.985); }
.app-screen {
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto auto auto auto auto;
  gap: 7px;
  overflow: hidden;
}
.app-top {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 56px;
}
.app-icon {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 16px;
  box-shadow: 0 6px 14px rgba(67, 31, 8, .12);
}
.app-title { min-width: 0; }
.eyebrow {
  color: var(--mocha);
  font-size: .65rem;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .12em;
  white-space: nowrap;
}
h1 {
  margin-top: 1px;
  color: var(--dark-roast);
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 5vw, 2rem);
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.top-chip {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(255,250,240,.7);
  border: 1px solid var(--line);
  color: var(--mocha);
  font-weight: 950;
  font-size: .86rem;
}
.score-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.score-card {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  min-height: 43px;
  padding: 8px 11px;
  border-radius: 15px;
  background: rgba(255, 250, 240, .78);
  border: 1px solid var(--line);
}
.score-card.active { background: #fff2cf; }
.score-card span { color: #7a614d; font-weight: 900; font-size: .82rem; }
.score-card strong { font-family: var(--font-display); font-size: 1.22rem; color: var(--mocha); }
.board-panel {
  min-height: 0;
  display: grid;
  place-items: center;
}
.board-stage {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border-radius: 0;
  background: #fbf4e7;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 8px 20px rgba(67,31,8,.10);
}
#boardCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.message {
  min-height: 42px;
  max-height: 52px;
  overflow: hidden;
  padding: 9px 11px;
  border-radius: 14px;
  background: rgba(255,250,240,.80);
  border: 1px solid var(--line);
  color: var(--espresso);
  font-weight: 800;
  font-size: .9rem;
  line-height: 1.22;
}
.message.good { color: #355f3b; background: #edf7e8; }
.message.warn { color: #7c4b18; background: #fff2cf; }
.rack-zone {
  padding: 9px;
  border-radius: 18px;
  background: rgba(255,250,240,.78);
  border: 1px solid var(--line);
}
.rack-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.rack-header strong { font-family: var(--font-display); font-size: 1.08rem; font-weight: 400; }
.rack {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}
.rack-tile {
  position: relative;
  aspect-ratio: 1 / 1.02;
  border: 2.5px solid #7d5422;
  border-radius: 10px;
  background: linear-gradient(180deg, #f7d85e, #efc64b);
  color: #2a1207;
  box-shadow: 0 2px 0 rgba(67,31,8,.22), 0 6px 10px rgba(67,31,8,.12);
  font-weight: 950;
  font-size: clamp(1rem, 5.4vw, 1.65rem);
}
.rack-tile.selected { outline: 3px solid var(--blue); outline-offset: 2px; transform: translateY(-2px); }
.rack-tile small {
  position: absolute;
  right: 6px;
  bottom: 4px;
  font-size: .52rem;
  font-weight: 950;
}
.primary-btn, .secondary-btn, .ghost-btn {
  min-height: 39px;
  padding: 8px 10px;
  border-radius: 13px;
  font-weight: 950;
  border: 0;
}
.primary-btn { color: var(--foam); background: linear-gradient(180deg, var(--mocha), var(--dark-roast)); }
.secondary-btn { color: var(--dark-roast); background: #f8e4cc; border: 1px solid rgba(217, 130, 43, .22); }
.ghost-btn { color: var(--dark-roast); background: rgba(255,255,255,.58); border: 1px solid var(--line); }
.bottom-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}
@media (min-width: 720px) {
  .app-screen { padding-left: 14px; padding-right: 14px; gap: 9px; }
  .board-stage { border-radius: 10px; }
}
@media (max-height: 720px) {
  .app-top { grid-template-columns: 44px 1fr auto; min-height: 46px; }
  .app-icon { width: 44px; height: 44px; border-radius: 13px; }
  h1 { font-size: 1.25rem; }
  .message { display: none; }
  .rack-zone { padding: 7px; }
  .rack-header { margin-bottom: 6px; }
  .primary-btn, .secondary-btn, .ghost-btn { min-height: 36px; padding: 7px 8px; font-size: .86rem; }
}
