:root {
  color-scheme: light;
  --ink: #231f1a;
  --muted: #6b5f54;
  --paper: #fff6e4;
  --panel: #fffaf0;
  --line: #d8c4a0;
  --charcoal: #292823;
  --red: #ba342d;
  --red-dark: #872722;
  --gold: #e7a843;
  --green: #477a46;
  --cream: #f2e0ba;
  --shadow: rgba(35, 31, 26, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  min-height: 100%;
}

body {
  align-items: center;
  background:
    linear-gradient(135deg, rgba(186, 52, 45, 0.12), rgba(71, 122, 70, 0.14)),
    #e8dfcd;
  color: var(--ink);
  display: flex;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  justify-content: center;
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  touch-action: manipulation;
}

button {
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  min-height: 42px;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    filter 120ms ease;
}

button:active {
  filter: brightness(0.96);
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.6);
  opacity: 0.56;
}

.phone-shell {
  background: var(--paper);
  border: 2px solid var(--charcoal);
  box-shadow: 0 10px 0 var(--charcoal);
  height: min(100dvh - 16px, 460px);
  max-height: 460px;
  max-width: 940px;
  min-height: 390px;
  min-width: min(100vw - 16px, 740px);
  overflow: hidden;
  position: relative;
  width: min(100vw - 16px, 940px);
}

.screen {
  height: 100%;
  overflow: hidden;
  padding: 10px;
}

.select-screen {
  display: grid;
  gap: 10px;
  grid-template-columns: 255px minmax(0, 1fr);
  grid-template-rows: 1fr auto;
}

.brand-head {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0)),
    var(--red);
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  color: #fffaf0;
  min-height: 0;
  padding: 14px;
}

.select-screen .brand-head {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.brand-head.compact {
  min-height: 0;
  padding: 12px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 3.1rem);
  letter-spacing: 0;
  line-height: 0.92;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0;
  line-height: 1.08;
}

h3 {
  font-size: 0.9rem;
  letter-spacing: 0;
}

.eyebrow {
  color: inherit;
  font-size: 0.66rem;
  font-weight: 950;
  letter-spacing: 0;
  margin-bottom: 6px;
  opacity: 0.84;
  text-transform: uppercase;
}

.subcopy {
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.3;
  margin-top: 8px;
  opacity: 0.9;
}

.character-grid {
  display: grid;
  gap: 8px;
  grid-column: 2;
  grid-row: 1 / 3;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  min-height: 0;
}

.character-card {
  background: var(--panel);
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  position: relative;
  text-align: left;
}

.character-card.is-selected {
  background: #fff2d0;
  box-shadow: 0 0 0 3px var(--gold) inset;
}

.character-portrait {
  align-items: end;
  background: linear-gradient(180deg, var(--card-bg), #fffaf0);
  display: flex;
  height: 112px;
  justify-content: center;
  overflow: hidden;
}

.character-portrait img {
  display: block;
  height: 120px;
  object-fit: contain;
  object-position: center bottom;
  width: 100%;
}

.character-meta {
  border-top: 2px solid var(--charcoal);
  padding: 7px;
}

.character-meta strong {
  display: block;
  font-size: 0.78rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.character-meta span {
  color: var(--muted);
  display: block;
  font-size: 0.62rem;
  font-weight: 850;
  line-height: 1.08;
  margin-top: 3px;
}

.selected-panel,
.summary-card,
.shop-panel {
  background: var(--panel);
  border: 2px solid var(--charcoal);
  border-radius: 8px;
}

.selected-panel {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-column: 1;
  grid-template-columns: 58px minmax(0, 1fr);
  min-height: 82px;
  padding: 8px;
}

.selected-panel img {
  background: #f3e0ba;
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  height: 56px;
  object-fit: contain;
  width: 56px;
}

.selected-panel strong {
  display: block;
  font-size: 0.9rem;
}

.selected-panel p {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.22;
  margin-top: 3px;
}

.primary-button {
  background: var(--gold);
  box-shadow: 0 4px 0 var(--charcoal);
}

.start-button {
  align-self: end;
  font-size: 0.95rem;
  grid-column: 1;
  min-height: 50px;
  width: 100%;
}

.game-screen {
  display: grid;
  gap: 8px;
  grid-template-rows: 62px minmax(0, 1fr);
}

.game-hud {
  align-items: center;
  background: var(--red);
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  color: #fffaf0;
  display: flex;
  justify-content: space-between;
  min-height: 0;
  padding: 9px 12px;
}

.money-pill {
  background: #fffaf0;
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  box-shadow: 0 3px 0 var(--charcoal);
  color: var(--ink);
  font-size: 1rem;
  font-weight: 950;
  min-width: 94px;
  padding: 7px 10px;
  text-align: center;
}

.service-layout {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1.18fr) minmax(310px, 0.82fr);
  min-height: 0;
}

.kitchen-panel,
.service-panel {
  min-height: 0;
}

.kitchen-panel {
  display: grid;
  gap: 8px;
  grid-template-rows: auto minmax(0, 1fr);
}

.service-panel {
  display: grid;
  gap: 8px;
  grid-template-rows: minmax(136px, 1.18fr) minmax(74px, 0.72fr) auto;
}

.meter-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.meter-row div,
.summary-card div {
  background: var(--panel);
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  min-height: 52px;
  padding: 7px 9px;
}

.meter-row span,
.summary-card span {
  display: block;
  font-size: 1.25rem;
  font-weight: 950;
  line-height: 1;
}

.meter-row p,
.summary-card p {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 900;
  margin-top: 4px;
  text-transform: uppercase;
}

#gameCanvas {
  background: #b88d64;
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  display: block;
  height: 100%;
  image-rendering: pixelated;
  min-height: 0;
  width: 100%;
}

.orders-wrap,
.grill-wrap,
.prep-wrap {
  background: var(--panel);
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  min-height: 0;
  padding: 8px;
}

.orders-wrap,
.grill-wrap {
  overflow: hidden;
}

.section-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 7px;
}

.section-title span {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
}

.orders-list {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  max-height: calc(100% - 27px);
  min-height: 0;
  overflow: hidden;
}

.order-card {
  background: #fff8ea;
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-height: 30px;
  padding: 4px;
}

.table-card {
  box-shadow: none;
  width: 100%;
}

.table-card.is-empty {
  background: #efe0bd;
}

.table-card.is-ready {
  background: #eaf7d9;
  box-shadow: 0 0 0 2px #6bc45c inset;
}

.order-top {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.order-top strong {
  font-size: 0.58rem;
  line-height: 1.05;
}

.order-top span {
  color: var(--muted);
  font-size: 0.52rem;
  font-weight: 900;
}

.patience-track,
.cook-track {
  background: #e4d2ad;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 6px;
  overflow: hidden;
}

.patience-fill,
.cook-fill {
  background: var(--green);
  height: 100%;
  width: 100%;
}

.grill-slots {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, 1fr);
  height: calc(100% - 27px);
}

.grill-slot {
  background: #332c27;
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  color: #fffaf0;
  display: grid;
  min-height: 32px;
  padding: 5px;
  text-align: left;
}

.grill-slot.is-empty {
  background: #efe0bd;
  color: var(--muted);
}

.grill-slot.is-perfect {
  background: #215c3d;
}

.grill-slot.is-burnt {
  background: #222;
}

.grill-slot strong {
  font-size: 0.62rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.grill-slot span {
  align-self: end;
  font-size: 0.54rem;
  font-weight: 900;
  opacity: 0.86;
}

.cook-track {
  align-self: end;
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.28);
}

.cook-fill {
  background: var(--gold);
}

.flavour-buttons {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(4, 1fr);
}

.flavour-button {
  background: var(--flavour);
  color: #fffaf0;
  display: grid;
  min-height: 30px;
  padding: 4px;
  place-items: center;
  text-align: center;
}

.flavour-button span {
  font-size: 0.58rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
  text-transform: uppercase;
}

.day-screen {
  display: grid;
  gap: 10px;
  grid-template-columns: 260px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
}

.day-screen .brand-head {
  grid-column: 1;
  grid-row: 1 / 3;
}

.summary-card {
  display: grid;
  gap: 8px;
  grid-column: 2;
  grid-template-columns: repeat(3, 1fr);
  padding: 8px;
}

.summary-card div {
  border-color: var(--line);
  min-height: 76px;
}

.shop-panel {
  grid-column: 2;
  min-height: 0;
  overflow: hidden;
  padding: 10px;
}

.upgrade-list {
  display: grid;
  gap: 7px;
  max-height: calc(100% - 28px);
  overflow: hidden;
}

.upgrade-button {
  align-items: center;
  background: #fff8ea;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-height: 52px;
  padding: 7px 9px;
  text-align: left;
  width: 100%;
}

.upgrade-button strong,
.upgrade-button span {
  display: block;
}

.upgrade-button strong {
  font-size: 0.8rem;
}

.upgrade-button span {
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.18;
  margin-top: 3px;
}

.upgrade-button em {
  background: var(--gold);
  border: 2px solid var(--charcoal);
  border-radius: 8px;
  color: var(--ink);
  flex: 0 0 auto;
  font-style: normal;
  font-weight: 950;
  padding: 5px 7px;
}

.day-screen .start-button {
  grid-column: 1;
  grid-row: 3;
}

.text-button {
  align-self: end;
  background: transparent;
  border: 0;
  color: var(--red-dark);
  grid-column: 2;
  min-height: 44px;
  text-decoration: underline;
}

.toast {
  background: var(--charcoal);
  border: 2px solid #000;
  border-radius: 8px;
  bottom: max(12px, env(safe-area-inset-bottom));
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.32);
  color: #fffaf0;
  font-size: 0.82rem;
  font-weight: 900;
  left: 50%;
  max-width: min(620px, calc(100vw - 28px));
  padding: 9px 12px;
  position: fixed;
  text-align: center;
  transform: translateX(-50%);
  z-index: 20;
}

[hidden] {
  display: none !important;
}

@media (orientation: portrait) and (max-width: 740px) {
  body::before {
    align-items: center;
    background: rgba(35, 31, 26, 0.9);
    color: #fffaf0;
    content: "Rotate phone to landscape";
    display: flex;
    font-size: 1.15rem;
    font-weight: 950;
    inset: 0;
    justify-content: center;
    padding: 24px;
    position: fixed;
    text-align: center;
    z-index: 99;
  }
}

@media (max-width: 760px), (max-height: 410px) {
  .phone-shell {
    border: 0;
    box-shadow: none;
    height: 100dvh;
    max-height: none;
    min-height: 0;
    min-width: 0;
    width: 100vw;
  }

  .screen {
    padding: 8px;
  }

  .select-screen {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .character-portrait {
    height: 88px;
  }

  .character-portrait img {
    height: 96px;
  }

  .character-meta {
    padding: 5px;
  }

  .service-layout {
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  }

  .game-screen {
    gap: 6px;
    grid-template-rows: 56px minmax(0, 1fr);
  }

  .game-hud {
    padding: 7px 9px;
  }

  .meter-row div {
    min-height: 46px;
    padding: 6px 8px;
  }

  .meter-row span {
    font-size: 1.08rem;
  }

  .flavour-button {
    min-height: 28px;
  }
}
