/* Pocket Pet: cozy room layout. Colors come from [data-theme] variables below. */
@font-face { font-family: 'Nunito'; src: url('../fonts/nunito.woff2') format('woff2'); font-weight: 200 1000; font-display: swap; }

:root, [data-theme="midnight"] {
  --page: #0e1230;
  --ui-bg: rgba(12, 16, 52, .62); --ui-bg-strong: rgba(12, 16, 52, .80); --ui-border: rgba(255, 255, 255, .13);
  --ui-shadow: 0 8px 20px rgba(0, 0, 25, .28);
  --text: #ffffff; --sub: #b9c2ff; --label: #c9d0ff; --icon: #c9d2ff;
  --accent-a: #5b6ce6; --accent-b: #3a47c4; --accent-glow: rgba(60, 80, 230, .45); --accent-text: #ffffff;
  --avatar-a: #5b6ce6; --avatar-b: #2a3394;
  --panel: rgba(246, 247, 255, .97); --panel-text: #262c55; --muted: #7a82b8; --card: #e8ebfb; --card-sel: #dfe4ff; --line: rgba(38, 44, 85, .10);
  --scrim: rgba(5, 7, 30, .45); --dot: #ffd65a; --dot-ring: rgba(12, 16, 52, .9);
  --clock-text: #ffd9b0; --track: rgba(255, 255, 255, .16);
}
[data-theme="mint"] {
  --page: #8ccbb6;
  --ui-bg: rgba(255, 255, 255, .74); --ui-bg-strong: rgba(255, 255, 255, .88); --ui-border: rgba(20, 90, 70, .14);
  --ui-shadow: 0 8px 20px rgba(20, 80, 60, .18);
  --text: #12443a; --sub: #2a7a66; --label: #2f6f60; --icon: #2f7a68;
  --accent-a: #3cc29f; --accent-b: #1d8a70; --accent-glow: rgba(29, 138, 112, .40); --accent-text: #ffffff;
  --avatar-a: #6fd3b5; --avatar-b: #258a74;
  --panel: rgba(250, 255, 253, .98); --panel-text: #12443a; --muted: #5f9a8a; --card: #e1f5ee; --card-sel: #cdeee2; --line: rgba(18, 68, 58, .10);
  --scrim: rgba(10, 50, 40, .30); --dot: #ff8a5b; --dot-ring: #ffffff;
  --clock-text: #12443a; --track: rgba(18, 68, 58, .12);
}
[data-theme="sunset"] {
  --page: #f2b39a;
  --ui-bg: rgba(255, 249, 243, .76); --ui-bg-strong: rgba(255, 249, 243, .90); --ui-border: rgba(140, 50, 50, .14);
  --ui-shadow: 0 8px 20px rgba(120, 40, 30, .18);
  --text: #5a2230; --sub: #b5485a; --label: #8a3a48; --icon: #a8455a;
  --accent-a: #ff8a6b; --accent-b: #e0566a; --accent-glow: rgba(224, 86, 106, .40); --accent-text: #ffffff;
  --avatar-a: #ffb06b; --avatar-b: #c8435a;
  --panel: rgba(255, 250, 245, .98); --panel-text: #5a2230; --muted: #b0707a; --card: #ffe8dc; --card-sel: #ffd8c6; --line: rgba(90, 34, 48, .10);
  --scrim: rgba(70, 20, 20, .30); --dot: #6f5ab8; --dot-ring: #ffffff;
  --clock-text: #5a2230; --track: rgba(90, 34, 48, .12);
}
[data-theme="lavender"] {
  --page: #b9a8e0;
  --ui-bg: rgba(252, 250, 255, .76); --ui-bg-strong: rgba(252, 250, 255, .90); --ui-border: rgba(70, 50, 130, .14);
  --ui-shadow: 0 8px 20px rgba(60, 40, 120, .18);
  --text: #34265e; --sub: #6f5ab8; --label: #574a88; --icon: #6a58a8;
  --accent-a: #9a86d6; --accent-b: #5f4b9a; --accent-glow: rgba(95, 75, 154, .40); --accent-text: #ffffff;
  --avatar-a: #a996d6; --avatar-b: #5f4b9a;
  --panel: rgba(253, 252, 255, .98); --panel-text: #34265e; --muted: #8a7cb8; --card: #ece5fb; --card-sel: #e0d6fa; --line: rgba(52, 38, 94, .10);
  --scrim: rgba(30, 20, 70, .30); --dot: #ff7aa2; --dot-ring: #ffffff;
  --clock-text: #34265e; --track: rgba(52, 38, 94, .12);
}
[data-theme="graphite"] {
  --page: #16181c;
  --ui-bg: rgba(22, 24, 28, .72); --ui-bg-strong: rgba(22, 24, 28, .86); --ui-border: rgba(255, 255, 255, .10);
  --ui-shadow: 0 8px 20px rgba(0, 0, 0, .35);
  --text: #f4f4f5; --sub: #ffa36e; --label: #b8bcc4; --icon: #c2c6cd;
  --accent-a: #ff8a4f; --accent-b: #e0561e; --accent-glow: rgba(224, 86, 30, .40); --accent-text: #ffffff;
  --avatar-a: #5a5f6a; --avatar-b: #2a2d33;
  --panel: rgba(36, 38, 43, .98); --panel-text: #f0f0f2; --muted: #9a9fa8; --card: #34373e; --card-sel: #40444c; --line: rgba(255, 255, 255, .08);
  --scrim: rgba(0, 0, 0, .45); --dot: #ff7a3d; --dot-ring: #16181c;
  --clock-text: #ffd2b8; --track: rgba(255, 255, 255, .14);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--page); overflow: hidden; overscroll-behavior: none; }
body {
  font-family: 'Nunito', ui-rounded, 'SF Pro Rounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text); -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  -webkit-text-size-adjust: 100%; touch-action: manipulation;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
button:focus-visible { outline: 3px solid var(--accent-a); outline-offset: 2px; }
[hidden] { display: none !important; }

/* phone-shaped column, centered on tablets/desktop */
.app {
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px);
  position: fixed; top: 0; bottom: 0; left: 0; right: 0; margin: 0 auto;
  width: min(100%, 500px, max(320px, 60vh)); overflow: hidden; isolation: isolate;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 0 60px rgba(0, 0, 0, .35);
}
#room { position: absolute; left: 0; top: 0; image-rendering: pixelated; touch-action: none; }

/* mask icons: pixel icons that take the current text color */
.mi { display: inline-block; width: 20px; height: 20px; flex: none; background: currentColor;
  -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; image-rendering: pixelated; }

/* ------------------------------------------------------------- header -- */
.top { position: absolute; z-index: 10; top: calc(var(--sat) + 10px); left: calc(var(--sal) + 14px); right: calc(var(--sar) + 14px); pointer-events: none; }
.top > * { pointer-events: auto; }
.row1 { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.who { display: flex; align-items: center; gap: 10px; min-height: 44px; min-width: 0; text-align: left; border-radius: 16px; padding-right: 6px; }
.av { width: 44px; height: 44px; border-radius: 15px; flex: none; display: grid; place-items: center; overflow: hidden;
  background: linear-gradient(160deg, var(--avatar-a), var(--avatar-b)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 14px rgba(0, 0, 20, .30); }
.av canvas { image-rendering: pixelated; }
.names { min-width: 0; }
.h1 { display: block; font-size: 21px; font-weight: 900; line-height: 1.05; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-shadow: 0 2px 8px rgba(0, 0, 30, .30); }
[data-theme="mint"] .h1, [data-theme="sunset"] .h1, [data-theme="lavender"] .h1 { text-shadow: 0 1px 0 rgba(255, 255, 255, .7); }
.names small { display: block; font-size: 11px; font-weight: 800; color: var(--sub); margin-top: 3px; letter-spacing: .03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.round { width: 44px; height: 44px; flex: none; border-radius: 15px; display: grid; place-items: center; color: var(--icon);
  background: var(--ui-bg); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border: 1px solid var(--ui-border); box-shadow: var(--ui-shadow); }
.round .mi { width: 20px; height: 20px; }
.chips { display: flex; gap: 8px; margin-top: 10px; }
.chip { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 7px; padding: 7px 9px 7px 7px; border-radius: 16px;
  background: var(--ui-bg); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); border: 1px solid var(--ui-border); box-shadow: var(--ui-shadow); }
.chip .ic { width: 26px; height: 26px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.chip .ic .mi { width: 16px; height: 16px; }
.chip[data-stat="hunger"] .ic { background: rgba(255, 138, 61, .20); color: #ff9a4c; }
.chip[data-stat="happy"] .ic { background: rgba(255, 90, 138, .20); color: #ff6f9a; }
.chip[data-stat="energy"] .ic { background: rgba(255, 200, 60, .22); color: #f2b82a; }
.chip .meta { flex: 1; min-width: 0; display: block; }
.chip .lab { display: flex; justify-content: space-between; gap: 4px; font-size: 10.5px; font-weight: 800; color: var(--label); white-space: nowrap; }
.chip .lab b { color: var(--text); font-weight: 900; }
.bar { display: block; height: 5px; border-radius: 3px; background: var(--track); margin-top: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: 3px; transition: width .4s ease; }
.chip[data-stat="hunger"] .bar i { background: linear-gradient(90deg, #ff7a3d, #ffb35c); }
.chip[data-stat="happy"] .bar i { background: linear-gradient(90deg, #ff5a8a, #ff9ac0); }
.chip[data-stat="energy"] .bar i { background: linear-gradient(90deg, #ffc23a, #ffe38a); }
.chip.low .lab b { color: #ff5a5a; }
.chip.low { animation: lowpulse 1.4s ease-in-out infinite; }
@keyframes lowpulse { 50% { box-shadow: var(--ui-shadow), 0 0 0 2px rgba(255, 90, 90, .55); } }
.top.egg .chips { opacity: .55; }

/* clock pill under the window */
.clock { position: absolute; z-index: 6; display: flex; align-items: center; gap: 6px; padding: 4px 10px 4px 7px; border-radius: 999px;
  background: var(--ui-bg); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border: 1px solid var(--ui-border);
  font-size: 11px; font-weight: 800; color: var(--clock-text); white-space: nowrap; pointer-events: none; }
.clock .mi { width: 12px; height: 12px; }

/* speech bubble over the cat (replaces the CALL light) */
.bubble { position: absolute; z-index: 7; left: 0; top: 0; width: 48px; height: 44px; border-radius: 15px; background: #fff; display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(5, 8, 40, .35); transform-origin: 14px 50px; animation: bob 1.2s ease-in-out infinite; }
.bubble::after { content: ''; position: absolute; left: 12px; bottom: -6px; width: 12px; height: 12px; background: #fff; transform: rotate(45deg); border-radius: 2px; }
.bubble .bub-ic { width: 26px; height: 26px; display: block; background: center / contain no-repeat; image-rendering: pixelated; }
.bubble.whim { background: #fff6d6; } .bubble.whim::after { background: #fff6d6; }
@keyframes bob { 50% { translate: 0 -3px; } }

/* toast */
.toast { position: absolute; z-index: 20; left: 50%; top: calc(var(--sat) + 124px); transform: translate(-50%, -8px); max-width: calc(100% - 40px);
  padding: 9px 14px; border-radius: 999px; background: var(--ui-bg-strong); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border: 1px solid var(--ui-border); box-shadow: var(--ui-shadow); font-size: 13px; font-weight: 800; text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------- action bar -- */
.actions { position: absolute; z-index: 12; left: calc(var(--sal) + 10px); right: calc(var(--sar) + 10px); bottom: calc(max(var(--sab), 8px) + 6px);
  height: 64px; display: grid; grid-template-columns: repeat(6, 1fr); gap: 2px; padding: 5px; border-radius: 22px;
  background: var(--ui-bg-strong); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); border: 1px solid var(--ui-border); box-shadow: 0 14px 34px rgba(0, 0, 20, .35); }
.act { position: relative; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; border-radius: 17px;
  font-size: min(10.5px, 2.95vw); font-weight: 800; color: var(--icon); letter-spacing: .01em; transition: background .15s, transform .08s; }
.act span { white-space: nowrap; }
.act .mi { width: 22px; height: 22px; }
.act:active, .act.pressed { transform: scale(.94); }
.act.on { background: linear-gradient(180deg, var(--accent-a), var(--accent-b)); color: var(--accent-text); box-shadow: 0 6px 14px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .3); }
.act.need::before { content: ''; position: absolute; top: 6px; right: calc(50% - 19px); width: 9px; height: 9px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 2px var(--dot-ring); }
.act.off { opacity: .45; }

/* ------------------------------------------------------------ food tray -- */
.tray { position: absolute; z-index: 13; left: calc(var(--sal) + 14px); right: calc(var(--sar) + 14px); bottom: calc(max(var(--sab), 8px) + 6px + 64px + 12px);
  padding: 10px 10px 11px; border-radius: 24px; background: var(--panel); color: var(--panel-text); box-shadow: 0 18px 40px rgba(3, 5, 30, .45);
  animation: pop .18s ease-out; }
.tray::after { content: ''; position: absolute; left: var(--tip, 34px); bottom: -7px; width: 16px; height: 16px; background: var(--panel); transform: rotate(45deg); border-radius: 3px; }
.tray .hd { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 0 5px 8px; }
.tray .hd b { font-size: 14px; font-weight: 900; white-space: nowrap; }
.tray .hd span { font-size: 11px; font-weight: 800; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.foods { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.food { position: relative; min-height: 92px; border-radius: 16px; background: var(--card); padding: 8px 2px 7px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--panel-text); transition: transform .08s; }
.food:active, .food.pressed { transform: scale(.95); background: var(--card-sel); box-shadow: inset 0 0 0 2px var(--accent-a); }
.food .pic { height: 36px; display: grid; place-items: center; }
.food .pic canvas { image-rendering: pixelated; }
.food .nm { font-size: 11px; font-weight: 900; white-space: nowrap; }
.food .fx { font-size: 9.5px; font-weight: 800; color: var(--muted); line-height: 1.15; text-align: center; padding: 0 3px; }
.food .tag { position: absolute; top: -8px; right: -2px; font-size: 9px; font-style: normal; font-weight: 900; color: #fff; background: #ff8a3d; padding: 2px 6px; border-radius: 999px; }
.food .tag.treat { background: #ff5a8a; }
.food .tag.daily { background: #3fb8a8; }
.food.nope { opacity: .45; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* --------------------------------------------------------- sheets/modals -- */
.scrim { position: absolute; inset: 0; z-index: 30; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.scrim.center { align-items: center; padding: calc(var(--sat) + 16px) 16px calc(var(--sab) + 16px); }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-height: calc(100% - var(--sat) - 24px); overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  background: var(--panel); color: var(--panel-text); border-radius: 26px 26px 0 0; padding: 8px 18px calc(var(--sab) + 18px); box-shadow: 0 -10px 40px rgba(0, 0, 20, .35);
  animation: up .22s cubic-bezier(.2, .9, .3, 1); -webkit-user-select: none; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 2px auto 10px; filter: brightness(.8); }
.sheet h2, .modal h2 { margin: 0; font-size: 20px; font-weight: 900; }
.sheet h3 { margin: 16px 0 10px; font-size: 13px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.sheet-hd { display: flex; align-items: center; justify-content: space-between; }
.x { width: 44px; height: 44px; flex: none; border-radius: 14px; background: var(--card); font-size: 26px; line-height: 1; font-weight: 700; color: var(--panel-text); display: grid; place-items: center; }

.st-head { display: flex; align-items: center; gap: 12px; }
.portrait { width: 76px; height: 76px; border-radius: 22px; flex: none; display: grid; place-items: center; background: linear-gradient(160deg, var(--avatar-a), var(--avatar-b)); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25); }
.portrait canvas { image-rendering: pixelated; }
.st-names { flex: 1; min-width: 0; }
.st-names p { margin: 3px 0 0; font-size: 12.5px; font-weight: 800; color: var(--muted); }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.tile { background: var(--card); border-radius: 16px; padding: 9px 12px 10px; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; }
.tile small { flex-basis: 100%; font-size: 10.5px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.tile b { font-size: 15px; font-weight: 900; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { font-style: normal; font-size: 10.5px; font-weight: 900; padding: 2px 8px; border-radius: 999px; color: #fff; background: #3fb8a8; }
.pill.skinny { background: #5b8fd9; } .pill.chubby { background: #ff9a4c; } .pill.fat { background: #e0566a; }
.swatches { display: inline-flex; gap: 3px; }
.swatches i { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .18); }
.meters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; margin-top: 14px; }
.meter .lab { display: flex; justify-content: space-between; font-size: 12px; font-weight: 800; color: var(--muted); }
.meter .lab b { color: var(--panel-text); font-weight: 900; }
.meter .bar { height: 8px; background: var(--line); margin-top: 5px; border-radius: 4px; }
.meter .bar i { border-radius: 4px; background: linear-gradient(90deg, var(--c1), var(--c2)); }
.status { margin: 14px 0 0; padding: 10px 12px; border-radius: 14px; background: var(--card); font-size: 13px; font-weight: 800; line-height: 1.35; }
.train { margin-top: 14px; }
.train-hd { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; }
.train-hd b { font-size: 15px; font-weight: 900; }
.train-hd span { font-size: 11.5px; font-weight: 800; color: var(--muted); }
.train-hd span.alert { color: #e0566a; }
.train-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 9px; }

.btn { min-height: 48px; border-radius: 16px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 900; color: var(--accent-text); background: linear-gradient(180deg, var(--accent-a), var(--accent-b)); box-shadow: 0 6px 14px var(--accent-glow), inset 0 1px 0 rgba(255, 255, 255, .3); transition: transform .08s; }
.btn:active, .btn.pressed { transform: scale(.96); }
.btn .mi { width: 18px; height: 18px; }
.btn.good { background: linear-gradient(180deg, #4fd0a0, #23a07a); box-shadow: 0 6px 14px rgba(35, 160, 122, .35), inset 0 1px 0 rgba(255, 255, 255, .3); }
.btn.warn { background: linear-gradient(180deg, #ff8a6b, #e0566a); box-shadow: 0 6px 14px rgba(224, 86, 106, .35), inset 0 1px 0 rgba(255, 255, 255, .3); }
.btn.ghost { background: var(--card); color: var(--panel-text); box-shadow: none; }
.btn.link { background: none; box-shadow: none; color: var(--muted); font-size: 14px; min-height: 44px; }
.btn.wide { width: 100%; margin-top: 14px; }
a.btn { text-decoration: none; }
.about-link { margin-top: 10px; font-size: 14px; }
.btn.big { min-height: 60px; font-size: 17px; border-radius: 18px; }

.themes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 6px 0; border-radius: 16px; font-size: 11px; font-weight: 800; color: var(--muted); min-height: 72px; }
.swatch i { width: 44px; height: 44px; border-radius: 14px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12); }
.swatch[aria-pressed="true"] { background: var(--card); color: var(--panel-text); }
.swatch[aria-pressed="true"] i { box-shadow: 0 0 0 3px var(--panel), 0 0 0 5px var(--accent-a); }
.set-row { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; padding: 10px 12px; background: var(--card); border-radius: 16px; min-height: 60px; }
.set-row b { display: block; font-size: 15px; font-weight: 900; }
.set-row small { font-size: 12px; font-weight: 700; color: var(--muted); }
.switch { width: 56px; height: 34px; border-radius: 999px; background: var(--line); position: relative; flex: none; transition: background .15s; filter: none; }
.switch i { position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: left .15s; }
.switch[aria-checked="true"] { background: var(--accent-a); }
.switch[aria-checked="true"] i { left: 25px; }
.switch[aria-checked="false"] { background: rgba(128, 128, 140, .45); }

.modal { width: 100%; max-width: 420px; max-height: 100%; overflow-y: auto; background: var(--panel); color: var(--panel-text); border-radius: 26px; padding: 18px; box-shadow: 0 20px 50px rgba(0, 0, 20, .45); animation: pop .2s ease-out; }
.help ul { margin: 10px 0 0; padding-left: 18px; font-size: 14px; line-height: 1.45; font-weight: 600; }
.help li { margin: 5px 0; }

.play { text-align: center; }
.pg-top { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 900; color: var(--muted); }
.pg-wins { display: inline-flex; align-items: center; gap: 5px; color: #ff5a8a; font-size: 16px; }
.pg-wins .mi { width: 16px; height: 16px; }
.play h2 { margin-top: 8px; }
.pg-stage { position: relative; height: 168px; margin: 12px 0 6px; border-radius: 20px; overflow: hidden; display: grid; place-items: end center; padding-bottom: 14px;
  background: linear-gradient(180deg, var(--card) 0 64%, color-mix(in srgb, var(--card) 45%, #b07a50) 64%); }
.pg-stage canvas { image-rendering: pixelated; transition: transform .25s cubic-bezier(.3, 1.4, .6, 1); }
.pg-msg { min-height: 2.6em; margin: 6px 0 10px; font-size: 14px; font-weight: 800; color: var(--muted); }
.pg-msg.yes { color: #23a07a; } .pg-msg.no { color: #e0566a; }
.pg-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pg-btns button[disabled] { opacity: .5; }

.goodbye { position: absolute; inset: 0; z-index: 25; display: flex; align-items: flex-end; justify-content: center; padding: 0 14px calc(max(var(--sab), 8px) + 84px);
  background: linear-gradient(180deg, transparent 40%, rgba(0, 0, 20, .35)); }
.bye { text-align: center; }
.bye p { margin: 8px 0 0; font-size: 14px; font-weight: 700; line-height: 1.45; color: var(--muted); }

/* ---------------------------------------------------------------- debug -- */
.dbg-toggle { position: absolute; z-index: 29; right: calc(var(--sar) + 4px); top: calc(var(--sat) + 172px); width: 44px; height: 32px; border-radius: 10px;
  font: 800 10px/1 ui-monospace, monospace; background: rgba(0, 0, 0, .55); color: #fff; }
.debug { position: absolute; z-index: 41; left: 8px; right: 8px; top: calc(var(--sat) + 208px); max-height: 55%; overflow: auto; padding: 8px; border-radius: 12px;
  background: rgba(0, 0, 0, .82); color: #e8ecff; font: 11px/1.35 ui-monospace, monospace; -webkit-user-select: text; user-select: text; }
.debug .row { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-bottom: 6px; }
.debug button { background: #2b3486; color: #fff; padding: 6px 8px; border-radius: 6px; font: inherit; }
.debug button.on { background: #e0561e; }
.debug pre { margin: 0; white-space: pre-wrap; }

/* ---------------------------------------------------------- naming -- */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.name-edit { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; max-width: 100%; text-align: left; border-radius: 12px; color: var(--panel-text); }
.name-edit h2 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.name-edit .mi { width: 16px; height: 16px; color: var(--muted); }
/* the naming sheet rides on top of the on-screen keyboard (--kb set from visualViewport) */
#nameSheet { z-index: 35; padding-bottom: var(--kb, 0px); transition: padding-bottom .12s ease-out; }
.name-sheet { max-height: calc(100% - var(--sat) - 8px); /* 100% is already above the keyboard (scrim has padding-bottom: --kb) */ padding-bottom: calc(var(--sab) + 16px); }
.app.kb-open .name-sheet { padding-bottom: 12px; border-radius: 22px 22px 0 0; }
.nm-head { display: flex; align-items: center; gap: 12px; }
.nm-pic { width: 60px; height: 60px; flex: none; border-radius: 18px; display: grid; place-items: center; background: linear-gradient(160deg, var(--avatar-a), var(--avatar-b)); }
.nm-pic canvas { image-rendering: pixelated; }
.nm-names { flex: 1; min-width: 0; }
.nm-names p { margin: 2px 0 0; font-size: 12.5px; font-weight: 800; color: var(--muted); }
.nm-skip { flex: none; padding: 0 10px; min-width: 56px; }
.app.kb-open .nm-pic, .app.kb-open .nm-names p, .app.kb-open .name-sheet .grab { display: none; }
.nm-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; }
.app.kb-open .nm-form { margin-top: 10px; }
.nm-field { position: relative; display: block; min-width: 0; }
.nm-field input { width: 100%; height: 52px; border-radius: 16px; border: 2px solid transparent; background: var(--card); color: var(--panel-text);
  font: 900 18px/1 'Nunito', ui-rounded, system-ui, sans-serif; padding: 0 52px 0 14px; outline: none; -webkit-user-select: text; user-select: text; }
.nm-field input:focus { border-color: var(--accent-a); }
.nm-field input::placeholder { color: var(--muted); opacity: .7; }
.nm-count { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 800; color: var(--muted); pointer-events: none; }
.nm-count.over { color: #e0566a; }
.nm-dice { height: 52px; padding: 0 14px; }
.nm-dice .mi { width: 18px; height: 18px; }
.nm-ok { grid-column: 1 / -1; }
.app.kb-open .nm-ok { min-height: 50px; }

/* small phones (320 wide) */
@media (max-width: 359px) {
  .top { left: calc(var(--sal) + 10px); right: calc(var(--sar) + 10px); }
  .h1 { font-size: 18px; }
  .names small { font-size: 10px; }
  .chips { gap: 6px; }
  .chip { gap: 5px; padding: 6px 7px 6px 6px; border-radius: 14px; }
  .chip .ic { width: 22px; height: 22px; border-radius: 8px; }
  .chip .ic .mi { width: 14px; height: 14px; }
  .chip .lab { font-size: 9.5px; }
  .actions { left: calc(var(--sal) + 6px); right: calc(var(--sar) + 6px); height: 60px; padding: 4px; gap: 1px; }
  .act .mi { width: 20px; height: 20px; }
  .tray { left: calc(var(--sal) + 8px); right: calc(var(--sar) + 8px); bottom: calc(max(var(--sab), 8px) + 6px + 60px + 10px); padding: 9px 8px 9px; }
  .foods { gap: 5px; }
  .food { min-height: 86px; }
  .food .nm { font-size: 10px; }
  .food .fx { font-size: 9px; }
  .tray .hd span { display: none; }
  .meters { gap: 8px 10px; }
  .sheet { padding-left: 14px; padding-right: 14px; }
  .toast { top: calc(var(--sat) + 112px); }
  .nm-dice span { display: none; }
  .nm-names h2 { font-size: 18px; }
  .nm-pic { width: 52px; height: 52px; }
  .nm-dice { width: 52px; padding: 0; }
}
@media (max-height: 600px) {
  .pg-stage { height: 130px; }
  .play h2 { font-size: 18px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* iOS standalone uses a translucent status bar with white text: keep it legible on light themes */
[data-theme="mint"] .app::before, [data-theme="sunset"] .app::before, [data-theme="lavender"] .app::before {
  content: ''; position: absolute; z-index: 9; left: 0; right: 0; top: 0; height: var(--sat); pointer-events: none;
  background: linear-gradient(rgba(0, 0, 0, .30), rgba(0, 0, 0, 0)); }
