:root {
  --bg: #0B0C16; --surface: #151929; --fg: #DDF7FF; --muted: #6A6E95; --border: #2A2E48;
  --accent: #82FB9C; --red: #FF5F6D; --orange: #FFA54F; --yellow: #FFD866; --green: #4FE88F;
  --cyan: #7CF8F7; --blue: #6C9BF5; --magenta: #C792EA;
  --card: rgba(21, 25, 41, 0.7); --hot: rgba(130, 251, 156, 0.2);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; touch-action: manipulation; } /* no double-tap zoom */
body {
  background: var(--bg); color: var(--fg);
  font: 16px/1.35 ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  display: flex; flex-direction: column; height: 100dvh; overflow: hidden;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  user-select: none; -webkit-user-select: none; overscroll-behavior: none;
}
button, input, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; }
/* body turns selection off for taps; typing still needs it (iOS won't focus or edit without it) */
input, textarea { -webkit-user-select: text; user-select: text; }
header {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; min-height: 52px; flex: none;
}
header h1 { margin: 0; font-size: 22px; font-weight: 500; color: var(--accent); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { background: none; border: 0; font-size: 30px; line-height: 1; padding: 0 8px 4px 0; color: var(--accent); cursor: pointer; }
.coins { color: var(--yellow); font-weight: 700; }
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pad { padding: 14px 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.scroll { overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.list { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 20px; }

/* home: the room with the balloon over it, then the status */
.room { position: relative; flex: 1; min-height: 200px; overflow: hidden; }
.room canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; touch-action: manipulation; }
.balloon-row { position: absolute; left: 0; right: 0; top: 8px; display: flex; justify-content: center; padding: 0 24px; pointer-events: none; }
.balloon {
  position: relative; max-width: 100%; padding: 7px 12px; background: #0F101C; border: 1px solid var(--border);
  border-radius: 0; color: var(--fg); text-align: center; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.balloon.fresh { border-color: var(--accent); }
.balloon.old { color: var(--muted); }
.status { padding: 8px 16px 12px; display: flex; flex-direction: column; gap: 5px; flex: none; }
.status .line { display: flex; gap: 8px; align-items: baseline; }
.status .line .muted { flex: 1; }
.stat { display: grid; grid-template-columns: 24px 64px 1fr 34px; gap: 6px; align-items: center; font-size: 14px; }
.stat .bar { height: 6px; background: rgba(21, 25, 41, 0.9); overflow: hidden; }
.stat .bar i { display: block; height: 100%; transition: width 0.3s; }
.stat b { font-weight: 400; text-align: right; }
.acts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 4px; }
.act {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0; border: 0;
  background: var(--card); cursor: pointer; font-size: 13px;
}
.act .g { font-size: 22px; line-height: 1.1; }
.act.hot { background: rgba(130, 251, 156, 0.22); }
.act.dim { opacity: 0.45; }
.act:active, .card:active, .tab:active, .btn:active { filter: brightness(1.4); }
.toast { color: var(--accent); text-align: center; font-size: 13px; min-height: 0; }

/* lists */
.card {
  display: flex; align-items: center; gap: 10px; padding: 12px; background: var(--card); border: 0; width: 100%;
  text-align: left; cursor: pointer;
}
.card.hot { background: rgba(130, 251, 156, 0.18); }
.card .t { flex: 1; min-width: 0; }
.card .s { display: block; font-size: 13px; color: var(--muted); }
.card .r { color: var(--accent); white-space: nowrap; }
.label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; margin-top: 8px; }
.tabs { display: flex; gap: 6px; padding: 0 16px; flex-wrap: wrap; }
.tab { padding: 6px 10px; background: rgba(21, 25, 41, 0.6); border: 0; cursor: pointer; }
.tab.on { background: rgba(130, 251, 156, 0.3); }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; min-width: 0; }
input[type=text] {
  background: var(--surface); border: 1px solid var(--border); padding: 10px 12px; outline: none; border-radius: 0;
}
input[type=text]:focus { border-color: var(--accent); }
.btn { padding: 10px 16px; background: rgba(130, 251, 156, 0.22); border: 0; cursor: pointer; color: var(--fg); }
.quote { font-style: italic; }

/* games */
.game { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; padding: 10px 16px 14px; }
.game canvas { flex: 1; min-height: 0; width: 100%; touch-action: none; image-rendering: pixelated; }
.game .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big { font-size: 22px; text-align: center; }
.center { text-align: center; }
.done { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 12px; }

/* chat */
.chat { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 8px; padding: 10px 16px 14px; }
.msgs { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 85%; padding: 8px 12px; background: rgba(21, 25, 41, 0.8); align-self: flex-start; user-select: text; -webkit-user-select: text; }
.msg.me { background: rgba(130, 251, 156, 0.25); align-self: flex-end; }

/* notices over every screen: news, a failed save, a new version */
.banner {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 10;
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--accent); color: var(--fg);
  font-size: 14px; text-align: center; box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}
.banner.tap { cursor: pointer; color: var(--accent); }
.hint { margin: 0; padding: 10px 12px; background: var(--card); color: var(--fg); }
