:root {
  --tile-size: 48px;
  --cols: 14;
  --rows: 12;
  --bg-1: #f7d78b;
  --bg-2: #f2b96b;
  --panel-line: #6b4525;
  --text: #2d1d14;
  --floor-a: #d6b07b;
  --floor-b: #c99b63;
  --wall: #7b5336;
  --table: #98633d;
  --chair: #5d3a24;
  --buffet: #c55a45;
  --player-a: #52a7f9;
  --player-b: #216fb7;
  --accent: #b44c2c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", Verdana, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top, #fff7d4 0%, transparent 30%),
    linear-gradient(180deg, var(--bg-1), var(--bg-2));
  min-height: 100vh;
}

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

button {
  font: inherit;
}

.game-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px;
  padding-right: 320px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.72rem;
  color: var(--accent);
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 3.1rem);
  line-height: 1;
}

.instructions,
.status-panel,
.plate-hud,
.cup-hud {
  background: rgba(255, 248, 230, 0.94);
  border: 4px solid var(--panel-line);
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(91, 54, 25, 0.15);
}

.instructions {
  min-width: 270px;
  padding: 14px 16px;
}

.instructions p {
  margin-bottom: 7px;
}

.game-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 18px;
  align-items: start;
}

.status-panel {
  padding: 16px;
}

.status-panel p {
  line-height: 1.4;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  border: 2px solid rgba(0, 0, 0, 0.2);
}

.player-dot {
  background: #2a8ce7;
}

.buffet-dot {
  background: var(--buffet);
}

.table-dot {
  background: var(--table);
}

.hud-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  width: min(280px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  display: grid;
  gap: 12px;
  z-index: 15;
  overflow: auto;
}

.plate-hud,
.cup-hud {
  padding: 14px;
}

.meter-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.meter {
  height: 14px;
  border-radius: 999px;
  background: #ead8b8;
  overflow: hidden;
  border: 2px solid rgba(101, 64, 31, 0.2);
}

.meter-fill {
  width: 0;
  height: 100%;
  transition: width 220ms ease;
}

.plate-fill {
  background: linear-gradient(90deg, #f3be4a, #db7d38, #c75132);
}

.cup-fill {
  background: linear-gradient(90deg, #97d4ff, #53acee, #1b7bc0);
}

.plate-visual {
  position: relative;
  margin-top: 10px;
  min-height: 180px;
  padding: 12px 10px 20px;
}

.plate-base {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 18px;
  bottom: 20px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 35%, #ffffff, #f0e8d8 70%, #d9cab0 100%);
  box-shadow:
    inset 0 -12px 16px rgba(122, 103, 77, 0.14),
    0 10px 14px rgba(82, 55, 25, 0.12);
}

.plate-items {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-content: flex-start;
  justify-content: center;
  min-height: 138px;
  max-height: 138px;
  overflow: auto;
  padding: 18px 18px;
  z-index: 1;
}

.cup-visual {
  position: relative;
  height: 170px;
  margin-top: 10px;
}

.cup-straw {
  position: absolute;
  top: 8px;
  left: 58%;
  width: 10px;
  height: 70px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f46a7f, #ffb25d);
  transform: rotate(12deg);
  z-index: 2;
}

.cup-body {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 132px;
  height: 132px;
  transform: translateX(-50%);
  border-radius: 18px 18px 28px 28px;
  border: 4px solid rgba(112, 74, 41, 0.22);
  background: linear-gradient(180deg, rgba(255,255,255,0.75), rgba(255,255,255,0.28));
  overflow: hidden;
  box-shadow: inset 0 -10px 16px rgba(150, 184, 205, 0.14);
}

.cup-liquid {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background: linear-gradient(180deg, rgba(120, 210, 255, 0.82), rgba(48, 143, 212, 0.95));
  transition: height 220ms ease, background 220ms ease;
}

.cup-items {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: center;
  align-content: flex-end;
  max-height: 76px;
  overflow: hidden;
  z-index: 1;
}

.plate-token,
.cup-token {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  border-radius: 999px;
  background: rgba(255, 250, 238, 0.95);
  border: 2px solid rgba(112, 74, 41, 0.12);
  font-size: 0.75rem;
  line-height: 1;
  box-shadow: 0 4px 8px rgba(89, 52, 23, 0.08);
}

.cup-token {
  background: rgba(255, 255, 255, 0.8);
}

.token-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.hud-message {
  margin: 6px 0 0;
  font-size: 0.88rem;
  line-height: 1.35;
}

.game-board-wrap {
  background: rgba(255, 240, 211, 0.75);
  border: 4px solid var(--panel-line);
  border-radius: 22px;
  padding: 16px;
  overflow: auto;
  box-shadow: 0 12px 28px rgba(91, 54, 25, 0.18);
}

.game-board {
  position: relative;
  width: calc(var(--cols) * var(--tile-size));
  height: calc(var(--rows) * var(--tile-size));
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--tile-size));
  grid-template-rows: repeat(var(--rows), var(--tile-size));
  border: 4px solid #5e3922;
  border-radius: 14px;
  overflow: hidden;
}

.tile {
  position: relative;
  width: var(--tile-size);
  height: var(--tile-size);
  font-size: 0.62rem;
}

.tile.floor {
  background: linear-gradient(135deg, var(--floor-a), var(--floor-b));
  box-shadow: inset 0 0 0 1px rgba(255, 245, 221, 0.12);
}

.tile.wall {
  background: linear-gradient(180deg, #8d5e3c, var(--wall));
}

.tile.table {
  background: linear-gradient(180deg, #b37849, var(--table));
}

.tile.table::before {
  content: "";
  position: absolute;
  inset: 8px;
  border: 3px solid rgba(255, 234, 210, 0.35);
  border-radius: 8px;
}

.tile.chair {
  background: linear-gradient(180deg, #7a4b2d, var(--chair));
}

.tile.buffet {
  background: linear-gradient(180deg, #d76d57, var(--buffet));
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.tile.buffet::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px dashed rgba(255, 242, 193, 0.42);
  border-radius: 8px;
}

.tile.buffet.nearby {
  z-index: 1;
  box-shadow:
    inset 0 0 0 4px rgba(255, 243, 166, 0.92),
    0 0 20px rgba(255, 228, 135, 0.88);
  transform: scale(1.04);
}

.tile-label {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: 4px;
  text-align: center;
  background: rgba(53, 28, 15, 0.76);
  color: #fff6e5;
  padding: 2px 4px;
  border-radius: 6px;
  line-height: 1.1;
  font-size: 0.58rem;
}

.station-pip {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff6b5;
  box-shadow: 0 0 10px rgba(255, 239, 143, 0.8);
}

.player {
  position: absolute;
  inset: 0 auto auto 0;
  width: calc(var(--tile-size) - 12px);
  height: calc(var(--tile-size) - 12px);
  margin: 6px;
  border: 3px solid #dff0ff;
  border-radius: 12px;
  z-index: 3;
  transition: transform 110ms ease;
  box-shadow:
    0 8px 12px rgba(28, 49, 83, 0.28),
    inset 0 -7px 0 rgba(10, 39, 79, 0.18);
  background:
    radial-gradient(circle at 35% 30%, #17304b 0 3px, transparent 4px),
    radial-gradient(circle at 65% 30%, #17304b 0 3px, transparent 4px),
    radial-gradient(circle at 50% 68%, transparent 0 11px, #17304b 12px 14px, transparent 15px),
    linear-gradient(180deg, var(--player-a), var(--player-b));
  background-repeat: no-repeat;
  background-size: auto, auto, 28px 16px, auto;
  background-position: 0 0, 0 0, center 18px, 0 0;
}

.detail-overlay {
  position: fixed;
  inset: 0;
  background: rgba(49, 27, 16, 0.58);
  display: grid;
  place-items: center;
  padding: 16px 312px 16px 16px;
  overflow: auto;
  z-index: 10;
  transition: opacity 180ms ease;
}

.detail-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.detail-card {
  width: min(860px, 100%);
  max-height: calc(100vh - 32px);
  min-height: min(640px, calc(100vh - 32px));
  overflow: auto;
  background:
    linear-gradient(180deg, rgba(255, 251, 241, 0.98), rgba(255, 240, 220, 0.98));
  border: 5px solid #754727;
  border-radius: 28px;
  box-shadow: 0 28px 48px rgba(63, 34, 17, 0.28);
  padding: 24px;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.back-button,
.add-button,
.clear-button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(180deg, #bc6744, #964627);
  color: #fff8ee;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 10px 18px rgba(104, 49, 23, 0.2);
}

.add-button {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
}

.clear-button {
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
  background: linear-gradient(180deg, #8a5b42, #6d3f2b);
}

.back-button:hover,
.add-button:hover,
.clear-button:hover {
  transform: translateY(-1px);
}

.detail-hint {
  margin: 14px 0 20px;
  background: #fff8eb;
  border: 2px solid rgba(129, 77, 37, 0.18);
  border-radius: 14px;
  padding: 12px 14px;
}

.detail-foods {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.food-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(250, 239, 220, 0.98));
  border: 3px solid rgba(122, 76, 44, 0.14);
  border-radius: 22px;
  box-shadow: 0 12px 20px rgba(100, 58, 25, 0.12);
  padding: 12px;
  min-height: 220px;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.food-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 24px rgba(100, 58, 25, 0.16);
}

.food-art {
  position: relative;
  height: 108px;
  border-radius: 18px;
  margin-bottom: 12px;
  overflow: hidden;
  background: linear-gradient(180deg, #f7eede, #ebd9bc);
}

.food-card.cheese .food-art {
  background:
    radial-gradient(circle at 50% 15%, rgba(255, 255, 255, 0.8), transparent 35%),
    linear-gradient(180deg, #ead8c2, #cfb89d);
}

.food-card.meat .food-art {
  background: linear-gradient(180deg, #f7ece3, #e1c2ad);
}

.food-card.fruit .food-art {
  background: linear-gradient(180deg, #fff0e2, #f9d5b9);
}

.food-card.veg .food-art {
  background: linear-gradient(180deg, #f1f9e6, #d9e9bf);
}

.food-card.drink .food-art {
  background: linear-gradient(180deg, #ebf8ff, #cde8f8);
}

.food-card.dessert .food-art {
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.72), transparent 30%),
    linear-gradient(180deg, #fff1f4, #f5d1db);
}

.plate {
  position: absolute;
  inset: 10px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 50% 35%, #ffffff, #f0e8d8 70%, #d9cab0 100%);
  box-shadow:
    inset 0 -10px 12px rgba(122, 103, 77, 0.12),
    0 10px 14px rgba(82, 55, 25, 0.12);
}

.food-piece {
  position: absolute;
  border-radius: 14px;
}

.food-card.cheese .food-piece {
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.45),
    inset 0 -6px 8px rgba(101, 57, 15, 0.18),
    0 7px 12px rgba(71, 42, 18, 0.18);
}

.warning-badge {
  display: inline-block;
  margin-top: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: bold;
  color: #fff7ec;
  background: linear-gradient(180deg, #ca6841, #a9462a);
}

.food-title {
  margin: 0 0 6px;
  font-size: 1rem;
}

.food-label {
  margin: 0;
  color: #784f33;
  font-size: 0.9rem;
  line-height: 1.35;
}

.animation-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
}

.flying-food {
  position: fixed;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 14px 24px rgba(67, 38, 17, 0.18);
  transition:
    transform 620ms cubic-bezier(0.2, 0.8, 0.2, 1),
    opacity 620ms ease;
}

.flying-food .food-art {
  margin: 0;
  width: 100%;
  height: 100%;
}

@media (max-width: 1200px) {
  .game-shell {
    padding-right: 18px;
  }

  .hud-stack {
    position: static;
    width: auto;
    max-height: none;
    margin: 18px;
    margin-bottom: 0;
    overflow: visible;
  }

  .detail-overlay {
    padding: 16px;
  }

  .detail-card {
    width: min(920px, 100%);
    max-height: calc(100vh - 32px);
  }
}

@media (max-width: 920px) {
  .topbar,
  .game-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .detail-header {
    align-items: start;
  }

  .detail-foods {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }
}

@media (max-width: 700px) {
  :root {
    --tile-size: 34px;
  }

  .game-shell {
    padding: 12px;
  }

  .topbar {
    gap: 12px;
  }

  .instructions {
    min-width: 0;
  }

  .detail-overlay {
    padding: 12px;
    place-items: start center;
  }

  .detail-card {
    padding: 16px;
    min-height: auto;
    border-radius: 20px;
  }

  .detail-header {
    grid-template-columns: 1fr;
    display: grid;
  }

  .detail-foods {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .food-card {
    min-height: 0;
  }

  .plate-items {
    max-height: 110px;
    min-height: 110px;
  }
}
