* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1c1626;
  --panel: #2a2138;
  --panel2: #362b48;
  --text: #f3edff;
  --muted: #a99cc4;
  --accent: #ff9046;
  --accent2: #ffcc4d;
  --good: #5cd65c;
  --bad: #ff5c5c;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  overflow: hidden;
}

.hidden { display: none !important; }

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid #453a5c;
  border-radius: 16px;
  padding: 28px 32px;
  max-width: 460px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,.45);
}

h1 { font-size: 2rem; margin-bottom: 6px; }
h2 { margin-bottom: 14px; }
.tagline { color: var(--muted); margin-bottom: 20px; }

label { display: block; text-align: left; color: var(--muted); font-size: .85rem; margin-bottom: 4px; }

input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #55487a;
  background: var(--panel2);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

button {
  cursor: pointer;
  border: none;
  border-radius: 10px;
  background: var(--panel2);
  color: var(--text);
  padding: 10px 16px;
  font-size: 1rem;
  transition: transform .08s, filter .15s;
}
button:hover { filter: brightness(1.2); }
button:active { transform: scale(.97); }

button.big {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), #ff5c8a);
  font-weight: 700;
  font-size: 1.1rem;
  padding: 14px;
  margin-top: 4px;
}

.join-row { display: flex; gap: 10px; margin-top: 14px; }
.join-row input { flex: 1; margin: 0; text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }
.join-row button { padding: 0 26px; background: #4d6dff; font-weight: 700; }

.error { color: var(--bad); min-height: 1.2em; margin-top: 10px; font-size: .9rem; }
.hint { color: var(--muted); font-size: .85rem; margin-top: 14px; }
.link-btn { background: none; color: var(--muted); margin-top: 12px; font-size: .9rem; }

/* lobby */
.code-box {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  background: var(--panel2); border-radius: 12px; padding: 12px; margin-bottom: 16px;
}
.code-box span { color: var(--muted); font-size: .85rem; }
.code-box strong { font-size: 1.8rem; letter-spacing: .25em; color: var(--accent2); }
#lobby-players { list-style: none; margin-bottom: 14px; }
#lobby-players li {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
  text-align: left; font-weight: 600;
}
#lobby-players .dot { width: 16px; height: 16px; border-radius: 50%; flex: none; }
#lobby-players .tag { margin-left: auto; font-size: .75rem; color: var(--muted); font-weight: 400; }
.diff-line { color: var(--accent2); font-size: .9rem; margin-bottom: 14px; min-height: 1.3em; }

/* game screen */
#screen-game { justify-content: flex-start; padding-top: 8px; gap: 6px; }

#hud-top {
  display: flex; gap: 14px; align-items: center;
  background: var(--panel); border-radius: 12px; padding: 8px 18px;
  border: 1px solid #453a5c;
}
.hud-item { font-size: 1.15rem; font-weight: 700; }
#hud-time.low { color: var(--bad); animation: pulse 1s infinite; }
#hud-combo-wrap { color: var(--accent2); }
#btn-help { border-radius: 50%; width: 32px; height: 32px; padding: 0; font-weight: 700; }

#orders-bar {
  display: flex; gap: 8px; min-height: 74px; align-items: stretch;
  max-width: 96vw; flex-wrap: wrap; justify-content: center;
}
.order-card {
  background: #fff7ea; color: #3a2b18; border-radius: 10px;
  padding: 6px 10px 8px; min-width: 96px; position: relative;
  box-shadow: 0 4px 10px rgba(0,0,0,.35);
  animation: slidein .25s ease-out;
}
.order-card .oname { font-size: .72rem; font-weight: 700; margin-bottom: 2px; white-space: nowrap; }
.order-card .oitems { font-size: 1.05rem; letter-spacing: 1px; }
.order-card .obar { height: 5px; border-radius: 3px; background: #e4d5bd; margin-top: 5px; overflow: hidden; }
.order-card .obar > div { height: 100%; border-radius: 3px; background: var(--good); }
.order-card.urgent { animation: shake .4s infinite; }
.order-card.urgent .obar > div { background: var(--bad); }

#canvas-wrap { position: relative; }
canvas#game {
  border-radius: 12px;
  box-shadow: 0 14px 44px rgba(0,0,0,.5);
  max-width: 96vw;
  height: auto;
}

#controls-hint { color: var(--muted); font-size: .82rem; }
#controls-hint b { color: var(--text); }

#toasts {
  position: fixed; top: 18%; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  pointer-events: none; z-index: 30;
}
.toast {
  background: rgba(20, 14, 32, .92); border: 1px solid #55487a;
  padding: 8px 18px; border-radius: 999px; font-weight: 700;
  animation: toastfade 2.2s forwards;
}
.toast.good { color: var(--good); }
.toast.bad { color: var(--bad); }

/* overlays */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 6, 18, .75);
  display: flex; align-items: center; justify-content: center; padding: 12px;
}
.help-panel { max-width: 560px; text-align: left; max-height: 92vh; overflow-y: auto; }
.help-panel h2, .help-panel h3 { text-align: center; }
.help-panel h3 { margin: 14px 0 8px; }
.help-list { padding-left: 20px; }
.help-list li { margin-bottom: 8px; line-height: 1.45; color: #ddd3f0; }
.recipe-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel2); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px;
}
.recipe-row .rname { font-weight: 700; min-width: 130px; text-align: left; }
.recipe-row .ritems { font-size: 1.1rem; }
.recipe-row .rpts { margin-left: auto; color: var(--accent2); font-weight: 700; }

.over-panel { max-width: 420px; }
.stars { font-size: 3rem; letter-spacing: .1em; margin: 6px 0; }
.final-score { font-size: 2.2rem; font-weight: 800; color: var(--accent2); margin-bottom: 10px; }
#over-stats { color: var(--muted); margin-bottom: 16px; line-height: 1.6; }
#over-stats b { color: var(--text); }

@keyframes pulse { 50% { opacity: .45; } }
@keyframes slidein { from { transform: translateY(-12px); opacity: 0; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-2px); } 75% { transform: translateX(2px); } }
@keyframes toastfade {
  0% { transform: translateY(8px); opacity: 0; }
  10%, 75% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(-10px); opacity: 0; }
}
