﻿:root { --topbar-h: 50px; --pad: clamp(16px, 3vw, 28px); }

/********** Main Body Styles ***********/
html, body {
	height: 100%;
}

body {
	overflow: hidden;
	overscroll-behavior: none;
}

html.allowscroll,
body.allowscroll {
	overflow-y: auto;
	overscroll-behavior: auto;
	-webkit-overflow-scrolling: touch;
}

body{
	min-height: 100svh;
/*	display: grid; */
	font-family:ui-rounded,system-ui,-apple-system,Segoe UI,Roboto,sans-serif;
	margin:0;
	background:#f9fafb;
	color:#0f172a;
	-webkit-tap-highlight-color: transparent;
}

.bg{
	z-index: 0; 
	position:fixed;
	inset:0;
	background:#f9fafb center/cover no-repeat;
	filter:saturate(1.05) contrast(1.03);
	z-index:0;
}

/* disable text selection + long-press callout everywhere */
html, body, #stage, canvas, .tile, .btn, .topbar, .grid, .piece, .placedImg {
	-webkit-user-select: none;
	user-select: none;
	-webkit-touch-callout: none;          /* blocks iOS long-press menu */
	-webkit-tap-highlight-color: transparent; /* removes gray tap flash */
}

/* but allow selection where you actually want it (inputs etc.) */
input, textarea, [contenteditable], .allow-select {
	-webkit-user-select: text;
	user-select: text;
	-webkit-touch-callout: default;
}

.hud{
	position:absolute; 
	left:12px; 
	bottom:12px;
	font:600 16px system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
	background:rgba(0,0,0,.35);
	color:#fff; 
	padding:6px 10px; 
	border-radius:999px;
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	user-select:none; 
	pointer-events:none;
}

.wrap{
	position:relative;
	z-index:1;
	display:grid;
	place-items:center;
	min-height:100svh;
	padding:24px
}

.grid{
	display:grid;
	gap:16px;
	grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
	width:min(100%,900px);
	margin: auto;
	place-self: center;
	height: auto;
}

.tile{
	background:white;
	border-radius:18px;
	padding:22px 18px;
	box-shadow:0 2px 10px rgba(0,0,0,.08);
	text-align:center;
	text-decoration: none; 
	color: inherit;
	touch-action:manipulation;
}

.tile:active{
	transform:scale(.985)
}

.tile:focus-visible { 
	outline: 3px solid #60a5fa; 
	outline-offset: 4px; 
	border-radius: 16px; 
}

.thumb{
	border-radius:12px;
	aspect-ratio: 16/10; 
	width:100%; 
	object-fit:cover; 
	display:block
}

.emoji{
	font-size:56px;
	line-height:1;
	margin-bottom:8px
}

.title{
	font-size:20px;
	font-weight:700;
	margin:6px 0 4px
}

.sub{
	font-size:14px;
	color:#475569;
	margin:0
}

.bar{
	position:sticky;
	top:0;
	background:linear-gradient(#f9fafb,#f9fafb00);
	height:16px
}

.label{
	left:12px;
	bottom:12px;
	background:#ffffffd9;
	padding:6px 10px;
	border-radius:12px;
	font-weight:700;
	box-shadow:0 2px 8px rgba(0,0,0,.12)
}

.count{
	font-size:12px;
	color:#475569;
	margin-left:6px;
	font-weight:600
}

.back{
	position:fixed;
	left:16px;
	top:16px;
	font-size:18px;
	text-decoration:none
}

* { box-sizing: border-box; }
.back{
  position:fixed; left:16px; top:16px; z-index:1000;
  background:#ffffffcc; padding:8px 12px; border-radius:12px;
  text-decoration:none; color:#111;
}

/******* TOP BAR STYLES ********/
/* --- SPA game mount (new) --- */
#app {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100svh;        /* mobile-friendly viewport */
  overflow: hidden;
  z-index: 1;            /* sits above the menu grid */
}
#app .game-root {
  position: relative;
  min-height: 100%;
}

/* Fixed top bar with iOS safe area padding (replace your existing block) */
#topbar, .topbar {
  position: fixed;                         /* <-- this was missing */
  top: 0; left: 0; right: 0;
  height: var(--topbar-h, 50px);           /* single source of truth */
  z-index: 1000;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 12px 10px;
  display: flex; align-items: center; gap: 8px;

  /* optional backdrop polish */
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  background: rgba(255,255,255,0.06);
}

/* Stage fills everything below the fixed topbar (replace your existing .stage block) */
.stage{
  position: absolute;
  top: var(--topbar-h, 50px);              /* below the bar */
  left: 0; right: 0; bottom: 0;
  padding: 10px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

/* Generic pill button */
.btn{
  display:inline-flex; align-items:center; gap:.5rem;
  padding:.55rem .9rem; border-radius:14px;
  background:rgba(255,255,255,.9);
  box-shadow:0 2px 8px rgba(0,0,0,.10);
  font-weight:600; color:#111; text-decoration:none;
}

/* fireworks */
.fx-canvas {
	z-index: 2000;
	pointer-events: none;
	position: fixed;
	inset: 0;
}

/* win modal */
#gc-win {
	z-index: 3000;
}

/* Win modal */
.gc-modal{
	position: fixed;
	inset: 0;
	z-index: 3000;
	display: none;                      /* toggled via .show */
	align-items: center;
	justify-content: center;
	background: rgba(0,0,0,.45);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.gc-modal.show{
	display: flex;
}

.gc-card{
	background: #fff;
	border-radius: 24px;
	padding: 28px 32px;
	box-shadow: 0 30px 80px rgba(2,8,23,.35);
	max-width: min(900px, 92vw);
	width: min(500px, 92vw);
	text-align: center;
}

.gc-card h2{
	margin: 0 0 12px;
	font: 800 40px/1.2 ui-rounded, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.gc-card p{
	margin: 0 0 22px;
	font: 500 20px/1.5 ui-rounded, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}



/* Overlay */
.overlay{
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.45);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}
.overlay.show{
  opacity: 1;
  pointer-events: auto;
}

/* Make the full-page game list scroll within #app */
#app .wrap.fullpage {
  position: absolute;
  inset: 0;
  overflow: auto;              /* <-- scrolling lives here */
  padding: max(0px, env(safe-area-inset-top)) 24px 24px;
}

/* Center and size the grid nicely in full-page mode */
#app .wrap.fullpage > .overlay-grid {
  width: min(100%, 900px);
  margin: 0 auto;
  overflow-y: visible;
  pointer-events: auto;
}

body.modal-open { overflow: hidden; } /* lock background scroll */

/* Panel ~80% of viewport, scrollable inside */
.overlay-panel{
  width: min(960px, 92vw);
  height: min(80vh, 720px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(2,8,23,.35);
  display: flex;
  flex-direction: column;
  transform: scale(.96);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
}
.overlay.show .overlay-panel{
  transform: scale(1);
  opacity: 1;
}

/* Sticky header + close */
.overlay-header{
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid rgba(0,0,0,.06);
  background: #fff;
}
.overlay-header .title{ font-weight: 800; font-size: 18px; }
.overlay-header .close{
  background: transparent; border: 0; font-size: 24px; line-height: 1;
  cursor: pointer; padding: 4px 8px; border-radius: 8px;
}

/* Grid reuses your .tile look; add container spacing + scrolling */
.overlay-grid{
  padding: 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
