/* Mochi & Mallow — a cozy co-op puzzle */

:root {
  --pink: #ff8fb8;
  --pink-deep: #f26ba4;
  --mint: #6fe0bf;
  --mint-deep: #3fc9a2;
  --cream: #fffaf3;
  --ink: #5b4a63;
  --ink-soft: #8f7d98;
  --card: rgba(255, 255, 255, 0.82);
  --shadow: 0 18px 40px -18px rgba(173, 120, 160, 0.45);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: "Quicksand", "Comic Sans MS", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #ffe9f2 0%, #ffe4ef 28%, #e9f4ff 68%, #e6fbf1 100%);
  user-select: none;
}

.hidden {
  display: none !important;
}

/* ---------- screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 16px;
  z-index: 1;
}

.card {
  background: var(--card);
  backdrop-filter: blur(14px);
  border: 3px solid rgba(255, 255, 255, 0.9);
  border-radius: 30px;
  box-shadow: var(--shadow);
  padding: 34px 40px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}

/* ---------- home ---------- */

.home-card .bunnies {
  font-size: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 6px;
}

.bunny {
  display: inline-block;
  animation: bob 3.2s ease-in-out infinite;
}
.bunny-2 {
  animation-delay: 0.8s;
  transform: scaleX(-1);
}
.heart {
  animation: heartbeat 1.4s ease-in-out infinite;
  display: inline-block;
  font-size: 34px;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-9px); }
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  25% { transform: scale(1.22); }
  40% { transform: scale(1); }
  60% { transform: scale(1.14); }
}

.logo {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-weight: 800;
  font-size: 42px;
  margin: 4px 0 2px;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--pink-deep), #b07ce8, var(--mint-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo .amp {
  font-weight: 700;
}

.tagline {
  margin: 0 0 22px;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 600;
}

.field {
  display: block;
  text-align: left;
  margin-bottom: 14px;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink-soft);
}
.field span {
  display: block;
  margin-bottom: 6px;
}

input {
  font-family: inherit;
  font-size: 16px;
  padding: 12px 16px;
  border-radius: 16px;
  border: 2.5px solid #e8d9ee;
  background: #fff;
  color: var(--ink);
  outline: none;
  width: 100%;
  transition: border-color 0.2s;
}
input:focus {
  border-color: var(--pink);
}

.home-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 6px;
}

.join-row {
  display: flex;
  gap: 10px;
}
.join-row input {
  flex: 1;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 3px;
  text-align: center;
}

.btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
  border: none;
  border-radius: 18px;
  padding: 14px 22px;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
  box-shadow: 0 8px 18px -8px rgba(120, 80, 130, 0.45);
}
.btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
}
.btn:active {
  transform: translateY(1px) scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--pink), #e6a5f2);
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}
.btn-soft {
  background: #f1e8f7;
  color: var(--ink);
}
.btn-ghost {
  background: transparent;
  box-shadow: none;
  color: var(--ink-soft);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
}

.footnote {
  margin: 22px 0 0;
  font-size: 13.5px;
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ---------- lobby ---------- */

.lobby-emoji {
  font-size: 44px;
  animation: bob 2.6s ease-in-out infinite;
}

.lobby-code-label {
  margin: 8px 0 10px;
  color: var(--ink-soft);
  font-weight: 700;
}

.lobby-code {
  font-family: "Baloo 2", "Quicksand", sans-serif;
  font-size: 58px;
  font-weight: 800;
  letter-spacing: 14px;
  padding-left: 14px;
  margin: 6px 0 18px;
  background: linear-gradient(135deg, var(--pink-deep), #b07ce8, var(--mint-deep));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 10px rgba(210, 140, 190, 0.35));
}

.waiting {
  margin: 24px 0 10px;
  color: var(--ink-soft);
  font-weight: 600;
  line-height: 1.5;
}
.waiting small {
  color: var(--ink-soft);
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 4px solid #eedef4;
  border-top-color: var(--pink);
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- game layout ---------- */

#screen-game {
  display: none;
  padding: 0;
}
#screen-game.show {
  display: flex;
}

#hud {
  width: 100%;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px 6px;
  flex-wrap: wrap;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.chip {
  font-size: 12px;
  font-weight: 800;
  padding: 6px 12px;
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  box-shadow: 0 4px 10px -6px rgba(120, 80, 130, 0.35);
  white-space: nowrap;
}

.hud-level {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-middle {
  display: flex;
  gap: 14px;
  align-items: center;
  color: var(--ink-soft);
  font-weight: 800;
  font-size: 14px;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  background: rgba(255, 255, 255, 0.75);
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: 0 4px 10px -6px rgba(120, 80, 130, 0.3);
  white-space: nowrap;
}

.hud-right {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.85);
  font-size: 18px;
  cursor: pointer;
  box-shadow: 0 4px 10px -6px rgba(120, 80, 130, 0.35);
  transition: transform 0.12s;
}
.icon-btn:hover {
  transform: translateY(-2px);
}
.icon-btn:active {
  transform: scale(0.94);
}

#board-wrap {
  position: relative;
  width: min(98vw, 1100px);
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#player-tags {
  position: absolute;
  top: 8px;
  left: 10px;
  display: flex;
  gap: 8px;
  z-index: 3;
}

.tag {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 800;
  font-size: 13px;
  background: rgba(255, 255, 255, 0.82);
  padding: 6px 12px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot-0 { background: var(--pink); }
.dot-1 { background: var(--mint); }

#hud-bottom {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 2px 12px 12px;
  flex-wrap: wrap;
}

.you-banner {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.75);
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 10px -6px rgba(120, 80, 130, 0.3);
}

.peer-banner {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink-soft);
  background: rgba(255, 236, 244, 0.92);
  padding: 8px 16px;
  border-radius: 999px;
}

.skip-link {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  text-decoration: underline dotted;
  cursor: pointer;
  padding: 6px;
}
.skip-link:hover {
  color: var(--pink-deep);
}

/* ---------- touch d-pads ---------- */

#touch-ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}

.dpad {
  position: absolute;
  bottom: 20px;
  width: 150px;
  height: 150px;
  pointer-events: auto;
  opacity: 0.55;
}
.dpad-left { left: 14px; }
.dpad-right { right: 14px; }

.dpad::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.35));
  box-shadow: 0 6px 18px -8px rgba(120, 80, 130, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.85);
}

.dpad button {
  position: absolute;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  font-size: 19px;
  box-shadow: 0 4px 10px -4px rgba(120, 80, 130, 0.4);
  pointer-events: auto;
  touch-action: none;
}
.dpad-left button { background: #ffe3ee; }
.dpad-right button { background: #dffbed; }

.dpad .u { top: 2px; left: 52px; }
.dpad .d { bottom: 2px; left: 52px; }
.dpad .l { left: 2px; top: 52px; }
.dpad .r { right: 2px; top: 52px; }

/* ---------- done ---------- */

.done-title {
  font-family: "Baloo 2", sans-serif;
  font-size: 30px;
  margin: 10px 0 4px;
}
.done-sub {
  color: var(--ink-soft);
  font-weight: 600;
  margin: 0 0 18px;
}

.done-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.stat-big {
  background: #f7eefb;
  border-radius: 18px;
  padding: 10px 4px;
}
.stat-big b {
  display: block;
  font-family: "Baloo 2", sans-serif;
  font-size: 26px;
}
.stat-big span {
  font-size: 11.5px;
  font-weight: 800;
  color: var(--ink-soft);
}

.done-note {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.55;
  margin: 0 0 20px;
}

/* ---------- modals ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(90, 60, 100, 0.35);
  backdrop-filter: blur(4px);
  padding: 16px;
}

.modal-card {
  max-width: 420px;
  width: 100%;
}

.help-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: left;
  margin: 18px 0;
}

.help-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 14.5px;
  color: var(--ink);
}

.kbd {
  font-family: "Baloo 2", sans-serif;
  font-weight: 800;
  font-size: 13px;
  background: #fff;
  border: 2px solid #e8d9ee;
  border-bottom-width: 4px;
  border-radius: 10px;
  padding: 6px 10px;
  min-width: 58px;
  text-align: center;
  white-space: nowrap;
}

.modal-note {
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13.5px;
  line-height: 1.55;
}

.toast {
  background: rgba(70, 50, 80, 0.85);
  color: #fff;
  font-weight: 800;
  padding: 10px 18px;
  border-radius: 999px;
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  box-shadow: var(--shadow);
  animation: fadeup 2.4s ease forwards;
}
@keyframes fadeup {
  0% { opacity: 0; transform: translate(-50%, -14px); }
  12% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -10px); }
}

/* ---------- responsive ---------- */

@media (max-width: 620px) {
  .card { padding: 26px 22px; border-radius: 24px; }
  .logo { font-size: 34px; }
  .lobby-code { font-size: 46px; letter-spacing: 10px; }
  .hud-middle { order: 3; width: 100%; justify-content: center; }
  #hud { justify-content: center; }
  .done-stats { grid-template-columns: repeat(2, 1fr); }
}