:root {
  --bg: #15121c;
  --panel: #221d2c;
  --panel-2: #2d2639;
  --line: #3d3450;
  --ink: #f3eedf;
  --dim: #a89fbd;
  --grass: #6dbb4f;
  --gold: #ffd23f;
  --heart: #ff4f6d;
  --grem: #b57cff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 1px 1px, rgba(255,255,255,0.04) 1px, transparent 0);
  background-size: 20px 20px;
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  line-height: 1.5;
}

.ob-header {
  max-width: 920px;
  margin: 0 auto;
  padding: 18px 20px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.ob-back { color: var(--dim); text-decoration: none; font-size: 14px; }
.ob-back:hover { color: var(--ink); }
.ob-title {
  margin: 0;
  font-family: 'Silkscreen', monospace;
  font-weight: 700;
  font-size: 30px;
  letter-spacing: 1px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #7a3cc2;
}

.ob-wrap { max-width: 920px; margin: 0 auto; padding: 0 20px 40px; }

/* HUD */
.ob-hud {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 14px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  padding: 10px 14px;
  font-family: 'Silkscreen', monospace;
  font-size: 15px;
}
.ob-phase { color: var(--gold); margin-left: 6px; }
.ob-phase.night { color: var(--grem); }
.ob-clock {
  height: 10px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f3c94a 0 53.3%, #3a2f63 53.3% 100%);
  position: relative;
  overflow: hidden;
  border: 1px solid #00000055;
}
.ob-clock-fill {
  position: absolute; top: -2px; bottom: -2px; width: 4px;
  background: #fff;
  box-shadow: 0 0 6px #fff;
  left: 0;
}
.ob-stats { display: flex; gap: 14px; align-items: center; }
.ob-hearts { color: var(--heart); letter-spacing: 2px; font-family: 'Inter', sans-serif; font-size: 17px; }
.ob-hearts .empty { color: #5a4a5e; }
.ob-kids b { color: var(--gold); font-weight: 400; }

/* Stage */
.ob-stage {
  position: relative;
  border: 2px solid var(--line);
  background: #0c0a10;
  line-height: 0;
  touch-action: none;
}
#ob-canvas { width: 100%; display: block; image-rendering: pixelated; }

.ob-toast {
  position: absolute; left: 50%; top: 14px;
  transform: translateX(-50%);
  background: rgba(20, 16, 28, 0.88);
  border: 2px solid var(--line);
  color: var(--ink);
  font-size: 14px; line-height: 1.4;
  padding: 7px 14px;
  border-radius: 8px;
  max-width: 86%;
  text-align: center;
  opacity: 0;
  transition: opacity .25s;
  pointer-events: none;
}
.ob-toast.show { opacity: 1; }

.ob-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(40,26,64,.92), rgba(10,8,16,.97));
  line-height: 1.5;
  padding: 20px;
  text-align: center;
}
.ob-overlay[hidden] { display: none; }
.ob-card { max-width: 440px; }
.ob-card h2 {
  font-family: 'Silkscreen', monospace;
  font-size: 30px; margin: 0 0 8px;
  color: var(--gold);
  text-shadow: 3px 3px 0 #7a3cc2;
}
.ob-card p { margin: 0 0 14px; color: var(--dim); font-size: 15px; }
.ob-card .lead { color: var(--ink); }
.ob-btn {
  font-family: 'Silkscreen', monospace;
  font-size: 17px;
  background: var(--gold);
  color: #2a1a00;
  border: none;
  border-bottom: 4px solid #b38a10;
  border-radius: 8px;
  padding: 11px 20px;
  cursor: pointer;
  margin: 4px;
}
.ob-btn:hover { filter: brightness(1.08); }
.ob-btn:active { transform: translateY(2px); border-bottom-width: 2px; }
.ob-btn.alt { background: var(--panel-2); color: var(--ink); border-bottom-color: #120f18; }
.ob-btn:disabled { opacity: .5; cursor: default; }
.ob-note { font-size: 12px !important; opacity: .8; margin-top: 12px !important; }

.ob-slot-machine {
  width: 92px; height: 64px; margin: 6px auto 16px;
  background: #3a3149; border: 3px solid #5a4d70; border-radius: 10px;
  position: relative; overflow: hidden;
}
.ob-slot-machine::after {
  content: ''; position: absolute; left: 50%; top: 14px; width: 40px; height: 6px;
  transform: translateX(-50%); background: #0c0a10; border-radius: 3px;
}
.ob-coin {
  position: absolute; left: 50%; top: -40px; width: 30px; height: 30px; margin-left: -15px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff2b0, #e0b64a 55%, #a87b1c);
  border: 2px solid #8a6414;
  font: 700 11px/26px 'Inter', sans-serif; color: #6b4a08; text-align: center;
}
.ob-coin.drop { animation: coin-drop .8s ease-in forwards; }
@keyframes coin-drop {
  0% { top: -40px; }
  60% { top: 4px; }
  100% { top: 4px; width: 4px; margin-left: -2px; opacity: 0; }
}

/* Inventory bar */
.ob-bar {
  display: flex; gap: 14px; align-items: center; flex-wrap: wrap;
  background: var(--panel);
  border: 2px solid var(--line);
  border-top: none;
  border-radius: 0 0 10px 10px;
  padding: 10px 14px;
}
.ob-inv { display: flex; gap: 14px; font-size: 14px; color: var(--dim); }
.ob-inv b { color: var(--ink); margin-right: 3px; }
.ob-res { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; }
.sw-wood { background: #a0672f; box-shadow: inset 0 -3px #7a4b20; }
.sw-stone { background: #9aa0a8; box-shadow: inset 0 -3px #6b7078; }
.sw-door { background: #8a5527; box-shadow: inset 0 0 0 2px #5c3613; }
.sw-torch { background: linear-gradient(#ffcf4a 0 40%, #7a4b20 40%); }
.sw-fire { background: radial-gradient(circle, #ffb02e 30%, #c94a1a 60%, #6b6b6b 62%); }

.ob-slots { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.ob-slot {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel-2);
  border: 2px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 5px 9px;
  font: 500 12px/1.2 'Inter', sans-serif;
  cursor: pointer;
  text-align: left;
}
.ob-slot small { display: block; color: var(--dim); font-size: 11px; }
.ob-slot.sel { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold); }
.ob-slot.cant small { color: #ff8a8a; }
.ob-slot kbd { font-family: 'Silkscreen', monospace; color: var(--dim); font-size: 11px; }

/* Touch controls */
.ob-touch { display: none; justify-content: space-between; align-items: center; margin-top: 14px; user-select: none; -webkit-user-select: none; }
@media (pointer: coarse) { .ob-touch { display: flex; } }
.ob-touch button {
  background: var(--panel-2); color: var(--ink);
  border: 2px solid var(--line); border-radius: 10px;
  font: 600 14px 'Inter', sans-serif;
  touch-action: none;
}
.ob-touch button.held { background: #4a3d63; }
.ob-dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); gap: 4px; }
.d-up { grid-column: 2; grid-row: 1; }
.d-left { grid-column: 1; grid-row: 2; }
.d-right { grid-column: 3; grid-row: 2; }
.d-down { grid-column: 2; grid-row: 3; }
.ob-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.b-action { grid-column: span 2; height: 64px; background: #5a3d12 !important; border-color: var(--gold) !important; color: var(--gold) !important; font-size: 18px !important; }
.b-small { height: 44px; padding: 0 10px; }

.ob-help {
  margin-top: 22px;
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 4px 20px 10px;
  color: var(--dim);
  font-size: 14px;
}
.ob-help h2 { font-family: 'Silkscreen', monospace; color: var(--ink); font-size: 18px; }
.ob-help b { color: var(--ink); }
.ob-help li { margin-bottom: 4px; }

@media (max-width: 640px) {
  .ob-title { font-size: 22px; }
  .ob-hud { grid-template-columns: 1fr auto; font-size: 13px; }
  .ob-clock { grid-column: 1 / -1; grid-row: 2; }
  .ob-slots { margin-left: 0; }
}
