/* Playnesta shell stylesheet for Tower of Hanoi (Playnesta-original MIT).
   Disks are CSS bars sized by disk number — no sprites, fonts or network
   assets. The layout is viewport-relative so the same page fits the two
   production stages (894x670 desktop and 348x261 phone) with no overflow. */

* { box-sizing: border-box; }

:root {
  --disk-h: clamp(12px, 4.6vh, 26px);
  --rod: #b0793f;
  --base: #8a5a2b;
  --bg: #1b2430;
  --panel: #24303f;
  --ink: #f2f5f8;
  --muted: #a9b6c4;
  --accent: #e0a45a;
}

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: 4px;
  padding: 8px;
}

.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: 6px;
  font-size: 13px;
  background: var(--panel);
  padding: 4px 10px;
  border-radius: 8px;
}
.hud b { font-size: 16px; color: var(--accent); }
.hud .opt { color: var(--muted); }

/* ---- stage / pegs ---- */
#stage {
  flex: 1 1 auto;
  display: flex;
  align-items: stretch;
  gap: 6px;
  min-height: 0;
}

.peg {
  position: relative;
  flex: 1 1 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: flex-start;
  gap: 3px;
  margin: 0 4px 0;
  padding-bottom: 10px;
  cursor: pointer;
  border-radius: 8px 8px 6px 6px;
  transition: background 0.12s ease;
}
/* the vertical rod sits behind the disks */
.peg::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  top: 0;
  width: 5px;
  transform: translateX(-50%);
  background: var(--rod);
  border-radius: 3px;
  z-index: 0;
}
/* the base bar */
.peg::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 8px;
  background: var(--base);
  border-radius: 4px;
  z-index: 0;
}
.peg.hover { background: rgba(224, 164, 90, 0.16); }
.peg.selected { background: rgba(224, 164, 90, 0.1); }

.disk {
  position: relative;
  z-index: 1;
  height: var(--disk-h);
  min-height: 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(8px, 2.4vh, 13px);
  font-weight: 700;
  color: rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.18), 0 1px 2px rgba(0, 0, 0, 0.3);
  touch-action: none;
  transition: transform 0.08s ease;
}
.disk[data-top="1"] { cursor: grab; }
.peg.selected .disk[data-top="1"] {
  transform: translateY(-6px) scale(1.03);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
}

/* ---- status + controls ---- */
#statusbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
#status {
  font-size: 12px;
  min-height: 16px;
  color: var(--muted);
  text-align: center;
}
.actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.btn {
  font: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid #3a4a5c;
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #20242b; font-weight: 700; }
.btn:disabled { opacity: 0.45; cursor: default; }
#disk-count {
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #3a4a5c;
  background: var(--panel);
  color: var(--ink);
}

/* ---- win banner / modal / toast ---- */
#win-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(15, 20, 28, 0.82);
  z-index: 5;
}
#win-banner.hidden { display: none; }
#win-banner h2 { margin: 0; font-size: 20px; }

#modal-root { position: relative; z-index: 20; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 30;
}
.modal {
  background: var(--panel);
  border: 1px solid #3a4a5c;
  border-radius: 12px;
  padding: 16px 18px;
  max-width: 420px;
  max-height: 90%;
  overflow: auto;
}
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.rules-body h3 { margin: 10px 0 4px; font-size: 13px; color: var(--accent); }
.rules-body p, .rules-body ul { margin: 0; font-size: 13px; line-height: 1.4; }
.rules-body ul { padding-left: 18px; }
.modal-buttons { margin-top: 12px; display: flex; justify-content: flex-end; gap: 8px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  background: rgba(20, 26, 34, 0.95);
  border: 1px solid #3a4a5c;
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 40;
}
#toast.show { opacity: 1; }
