/* Warehouse Rush — UI chrome around the canvas.
   Thick ink outlines, hard offset shadows and saturated flat colour, so the
   menus feel like the same world as the game. */

:root {
  --ink: #2a2733;
  --harbor: #1b2735;
  --harbor-2: #22334a;
  --cream: #fff6e5;
  --cream-2: #f3e6cf;
  --yellow: #ffc93c;
  --yellow-2: #e0a92a;
  --coral: #ff6a5c;
  --sky: #5bb7ff;
  --mint: #6fe09a;
  --cardboard: #d9a86b;
  --wrap: #a6dcef;
  --tape: #7d8aa3;
  --font: "Fredoka", "Nunito", "Segoe UI Rounded", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--harbor);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.03) 0 18px, transparent 18px 36px);
  overflow: hidden;
}

#stage {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
}

#game {
  display: block;
  border: 4px solid var(--ink);
  border-radius: 14px;
  box-shadow: 0 10px 0 rgba(0,0,0,0.35);
  image-rendering: auto;
}

/* Screens ----------------------------------------------------------------- */
.screen {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(16, 24, 36, 0.62);
  overflow: auto;
}
.hidden { display: none !important; }

.panel {
  background: var(--cream);
  border: 4px solid var(--ink);
  border-radius: 22px;
  box-shadow: 10px 10px 0 rgba(0,0,0,0.35);
  padding: 28px 30px;
  max-width: 560px;
  width: 100%;
}

.masthead h1 {
  margin: 0;
  font-size: clamp(38px, 6vw, 56px);
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--ink);
  transform: rotate(-2deg);
  display: inline-block;
  padding: 6px 14px;
  background: var(--yellow);
  border: 4px solid var(--ink);
  border-radius: 14px;
  box-shadow: 5px 5px 0 var(--ink);
}
.masthead p {
  margin: 18px 0 0;
  font-size: 17px;
  line-height: 1.35;
  max-width: 42ch;
}

.actions { margin-top: 22px; display: grid; gap: 12px; }

.field { display: grid; gap: 6px; font-size: 14px; font-weight: 600; }
.field span { padding-left: 2px; }

input {
  font: 600 17px var(--font);
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 10px 14px;
  width: 100%;
  outline: none;
}
input:focus-visible { box-shadow: 0 0 0 4px rgba(91,183,255,0.55); }
input::placeholder { color: #a39b8a; font-weight: 500; }

.btn {
  font: 700 18px var(--font);
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 12px 20px;
  cursor: pointer;
  box-shadow: 0 5px 0 var(--ink);
  transition: transform 80ms ease, box-shadow 80ms ease;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 0 var(--ink); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn:focus-visible { outline: 4px solid rgba(91,183,255,0.7); outline-offset: 2px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; box-shadow: 0 5px 0 var(--ink); }
.btn-primary { background: var(--yellow); font-size: 21px; padding: 14px 22px; }
.btn-quiet { background: transparent; box-shadow: none; border-color: transparent; }
.btn-quiet:hover { box-shadow: none; background: rgba(0,0,0,0.06); transform: none; }
.btn-quiet:active { box-shadow: none; }

.check { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; accent-color: var(--ink); }

.divider {
  display: flex; align-items: center; gap: 12px;
  margin-top: 8px;
  font-size: 14px; font-weight: 600; color: #6d6456;
}
.divider::before, .divider::after { content: ""; flex: 1; height: 3px; background: var(--ink); opacity: 0.18; border-radius: 2px; }

.joinrow { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.joinrow input { text-transform: uppercase; letter-spacing: 0.25em; font-weight: 700; font-size: 20px; text-align: center; }

.note { margin: 0; font-size: 14px; color: #a13a2f; min-height: 0; }
.note:empty { display: none; }

.howto {
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
  counter-reset: step;
}
.howto li {
  display: grid;
  grid-template-columns: 84px 1fr;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  line-height: 1.3;
}
.chip {
  display: inline-block;
  text-align: center;
  font-weight: 700;
  font-size: 13px;
  padding: 6px 0;
  border: 3px solid var(--ink);
  border-radius: 10px;
  box-shadow: 3px 3px 0 var(--ink);
}
.chip-box { background: var(--cardboard); }
.chip-shelf { background: #c58b4a; color: #fff6e5; }
.chip-wrap { background: var(--wrap); }
.chip-tape { background: var(--tape); color: #fff; }

.controls {
  margin: 22px 0 0;
  font-size: 13px;
  line-height: 2.1;
  color: #4b4457;
}
.controls .p2 { display: block; }
kbd {
  font: 700 12px var(--font);
  background: #fff;
  border: 2px solid var(--ink);
  border-bottom-width: 4px;
  border-radius: 7px;
  padding: 1px 7px;
  margin: 0 2px 0 6px;
  color: var(--ink);
}
kbd + kbd { margin-left: 0; }

/* Lobby --------------------------------------------------------------------- */
.panel-lobby, .panel-end { max-width: 440px; text-align: center; }
.panel h2 { margin: 0; font-size: 28px; }

.code {
  margin: 14px auto 18px;
  display: inline-block;
  font-size: 54px;
  font-weight: 700;
  letter-spacing: 0.3em;
  padding: 6px 10px 6px 24px;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: 16px;
  box-shadow: 6px 6px 0 var(--ink);
  user-select: all;
}

.players {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  text-align: left;
}
.players li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  font-weight: 600;
  font-size: 17px;
}
.players li.empty { background: transparent; border-style: dashed; color: #8c8475; }
.players .dot { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--ink); background: transparent; }
.players li.empty .dot { border-style: dashed; }
.players .role { font-size: 13px; color: #6d6456; }

.status { margin: 16px 0 0; font-size: 15px; color: #4b4457; min-height: 1.4em; }
.row { margin-top: 18px; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }

/* End screen ------------------------------------------------------------------ */
.stars { margin: 14px 0 4px; font-size: 52px; line-height: 1; letter-spacing: 0.08em; }
.star { color: #cfc6b3; -webkit-text-stroke: 2px var(--ink); }
.star.on { color: var(--yellow); }
.bigscore { font-size: 64px; font-weight: 700; line-height: 1; }
.stats {
  margin: 18px auto 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  max-width: 380px;
}
.stats div {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 600;
  display: grid;
  gap: 2px;
}
.stats b { font-size: 22px; }

/* Toast ----------------------------------------------------------------------- */
.toast {
  position: absolute;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--cream);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 4px 4px 0 var(--ink);
  pointer-events: none;
}

/* Performance overlay ------------------------------------------------------- */
.perf {
  position: fixed;
  top: 10px;
  right: 10px;
  z-index: 10;
  font: 500 12px ui-monospace, Menlo, Consolas, monospace;
  color: #dfe7f0;
}
.perf-pill {
  display: inline-block;
  background: rgba(16, 24, 36, 0.8);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 999px;
  padding: 4px 10px;
  float: right;
}
.perf-body {
  display: none;
  clear: both;
  margin: 6px 0 0;
  background: rgba(16, 24, 36, 0.92);
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 10px;
  padding: 10px 12px;
  white-space: pre;
  line-height: 1.5;
}
.perf.expanded .perf-body { display: block; }

@media (max-width: 640px) {
  .panel { padding: 20px 18px; border-radius: 18px; }
  .howto li { grid-template-columns: 70px 1fr; font-size: 14px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  .btn { transition: none; }
}
