/* Playnesta shell stylesheet for Water Sort Puzzle (Playnesta-original MIT).
   Glasses and liquid are drawn with CSS — no sprites, fonts or network assets.
   Layout is viewport-relative so the same page fits the two production stages
   (894x670 desktop and 348x261 phone) with no overflow in either axis: the shelf
   is a flex row that wraps, and glass width/height clamp with the viewport. */

* { box-sizing: border-box; }

:root {
  --bg: #0e1620;
  --panel: #16222e;
  --panel2: #1d2c3a;
  --ink: #eaf2f8;
  --muted: #93a6b6;
  --accent: #4fc3f7;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-edge: rgba(255, 255, 255, 0.28);
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px;
  min-height: 0;
}

.topbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.title { font-weight: 700; font-size: 15px; }
.title small { font-weight: 500; color: var(--muted); font-size: 11px; }
.spacer { flex: 1; }
.hud {
  display: flex; align-items: baseline; gap: 5px; font-size: 12px;
  background: var(--panel); padding: 4px 10px; border-radius: 8px; flex-wrap: wrap;
}
.hud b { font-size: 14px; color: var(--accent); }
.hud .opt { color: var(--muted); }

/* ---- glasses ---- */
#board {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
#shelf {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: clamp(4px, 1.6vw, 16px);
  width: 100%;
}
.tube {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 4px 0 0;
  cursor: pointer;
  transition: transform 0.1s ease;
}
.tube .glass {
  position: relative;
  width: clamp(28px, 8.5vw, 58px);
  height: clamp(96px, 40vh, 260px);
  border: 2px solid var(--glass-edge);
  border-top: 0;
  border-radius: 6px 6px 14px 14px;
  background: var(--glass);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tube .rim {
  position: absolute;
  top: -6px;
  left: -4px;
  right: -4px;
  height: 6px;
  border: 2px solid var(--glass-edge);
  border-radius: 4px;
  background: var(--panel2);
}
.tube .stack { flex: 1; display: flex; flex-direction: column; }
.tube .slot { flex: 1; display: flex; }
.tube .unit { flex: 1; margin: 1px; border-radius: 2px; }
.tube.selected { transform: translateY(-8px); }
.tube.selected .glass {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(79, 195, 247, 0.5), 0 10px 18px rgba(0, 0, 0, 0.4);
}
.tube.invalid { animation: shake 0.25s; }
.tube.invalid .glass { border-color: #e8563f; }
.tube.done .unit { opacity: 0.95; }
.tube.done .glass::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ---- win card ---- */
#win { flex: 0 0 auto; display: flex; justify-content: center; }
.win-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid rgba(79, 195, 247, 0.4);
  border-radius: 10px; padding: 10px 18px; width: 100%; max-width: 420px;
}
.win-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.win-body { font-size: 15px; }

/* ---- status bar ---- */
#statusbar { flex: 0 0 auto; display: flex; flex-direction: column; gap: 6px; }
#status {
  font-size: 13px; color: var(--muted); min-height: 1.2em;
  background: var(--panel); border-radius: 8px; padding: 6px 10px;
}
#status[data-mode="win"] { color: #7de08a; }
#status[data-mode="sel"] { color: var(--accent); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.btn {
  font: inherit; font-size: 13px; color: var(--ink);
  background: var(--panel2); border: 1px solid var(--glass-edge);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: #05202e; border-color: var(--accent); font-weight: 600; }

.hidden { display: none !important; }

/* ---- rules modal ---- */
#modal-root { position: fixed; inset: 0; pointer-events: none; }
.modal-backdrop {
  position: fixed; inset: 0; pointer-events: auto;
  background: rgba(0, 0, 0, 0.6); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--panel); border: 1px solid var(--glass-edge); border-radius: 12px;
  max-width: 520px; width: 100%; padding: 16px 18px;
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.rules-body { font-size: 14px; line-height: 1.5; }
.rules-body h3 { margin: 12px 0 4px; font-size: 14px; color: var(--accent); }
.rules-body p { margin: 0 0 4px; }
.modal-buttons { display: flex; justify-content: flex-end; margin-top: 12px; }
