/* Mahjong Jade — styles */
:root {
	--world-hue: 150;
	--top: #1b3226;                 /* bord supérieur de toutes les pages = theme-color (barre d'état iOS/Android) */
	--bg: hsl(var(--world-hue), 38%, 9%);
	--bg2: hsl(var(--world-hue), 30%, 16%);
	--panel: hsla(var(--world-hue), 25%, 20%, .75);
	--panel-2: hsla(var(--world-hue), 25%, 26%, .9);
	--line: hsla(45, 60%, 70%, .16);
	--text: #f3efe4;
	--muted: #b9b3a3;
	--gold: #e8c060;
	--gold-2: #c99a2e;
	--jade: #4fd1a5;
	--red: #e0574b;
	--tile-face: linear-gradient(160deg, #fffdf6 0%, #f4eddc 55%, #e9dfc7 100%);
	--tile-side: #cfc19b;
	--tile-side-2: #a89466;
	--sat: env(safe-area-inset-top, 0px);
	--sab: env(safe-area-inset-bottom, 0px);
	--font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	--serif: Georgia, "Times New Roman", "Noto Serif", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
html { background: #1b3226; }
body {
	font-family: var(--font); color: var(--text);
	background: linear-gradient(180deg, var(--top) 0%, var(--bg) 70%);   /* uniforme horizontalement en haut : raccord parfait avec la barre d'état */
	overflow: hidden; -webkit-user-select: none; user-select: none; touch-action: manipulation;
	-webkit-text-size-adjust: 100%; overscroll-behavior: none;
	transition: background .6s;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: var(--gold); }
h1, h2, h3 { margin: 0; font-weight: 700; }
small { font-size: .8em; }
[hidden] { display: none !important; }

/* collé aux 4 bords de l'écran : indépendant des unités vh/dvh, fausses dans les web apps installées sur iPhone */
#app { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100%; display: flex; flex-direction: column; }

/* ---------- Splash ---------- */
#splash { position: fixed; inset: 0; z-index: 3000; background: linear-gradient(180deg, var(--top) 0%, var(--bg) 70%); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; transition: opacity .45s ease; }
#splash.hide { opacity: 0; pointer-events: none; }
.splash-tile { width: 84px; height: 110px; border-radius: 12px; background: var(--tile-face); box-shadow: 4px 4px 0 var(--tile-side), 6px 6px 0 var(--tile-side-2), 10px 14px 30px rgba(0, 0, 0, .5); display: grid; place-items: center; font-family: var(--serif); font-size: 56px; font-weight: 700; color: #b8322a; animation: splashIn .7s cubic-bezier(.2, 1.4, .4, 1) both, floaty 4s ease-in-out .7s infinite; }
@keyframes splashIn { from { transform: translateY(40px) scale(.6) rotate(-12deg); opacity: 0; } }
.splash-title { font-family: var(--serif); font-size: 34px; color: var(--text); animation: fade .6s .25s both; }
.splash-title em { font-style: italic; color: var(--jade); }
.splash-bar { width: 160px; height: 4px; border-radius: 2px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.splash-bar i { display: block; height: 100%; width: 40%; border-radius: 2px; background: linear-gradient(90deg, var(--jade), #b9ffe3); animation: splashBar 1.1s ease-in-out infinite; }
@keyframes splashBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
.splash-msg { font-size: 12px; color: var(--muted); }

/* ---------- HUD ---------- */
#hud {
	display: flex; align-items: center; justify-content: space-between; gap: 8px;
	padding: calc(var(--sat) + 8px) 12px 8px; flex: 0 0 auto;
}
.hud-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
#hud-title { font-weight: 700; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-help-hud b { font-family: var(--serif); font-size: 20px; color: var(--gold); }
.hud-right { display: flex; gap: 8px; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; background: var(--panel); display: grid; place-items: center; color: var(--text); }
.icon-btn svg { width: 22px; height: 22px; }
.pill {
	display: flex; align-items: center; gap: 5px; padding: 6px 10px 6px 8px; border-radius: 999px;
	background: var(--panel); border: 1px solid var(--line); font-weight: 700; font-size: 15px; line-height: 1;
}
.pill svg { width: 18px; height: 18px; }
.pill.lives { color: #ff7a6e; } .pill.lives b, .pill.coins b { color: var(--text); }
.pill.lives small { color: var(--muted); font-weight: 500; font-size: 11px; }
.pill.lives.empty { border-color: rgba(255, 90, 80, .6); box-shadow: 0 0 0 3px rgba(255, 90, 80, .15); }
.pill.coins { color: var(--gold); }
.pill .plus { width: 18px; height: 18px; border-radius: 50%; background: var(--gold); color: #3b2a00; display: grid; place-items: center; font-size: 15px; margin-left: 2px; }

/* ---------- Écrans ---------- */
#screens { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 0 14px 20px; }
.screen { display: none; max-width: 640px; margin: 0 auto; }
.screen.active { display: block; }
body.in-game #screens { padding: 0; overflow: hidden; }
/* en partie : tout l'écran est le feutre (barre du haut, réserve, plateau, bonus) — aucune cassure de couleur */
body.in-game {
	background:
		repeating-linear-gradient(45deg, rgba(255, 255, 255, .018) 0 2px, transparent 2px 7px),
		linear-gradient(180deg, var(--top) 0%, hsl(150, 36%, 22%) 42%, hsl(150, 40%, 12%) 100%);
}
body.in-game #screen-game { display: flex; flex-direction: column; height: 100%; max-width: none; }
body.in-game #tabbar { display: none; }
body.in-game #hud { display: none; }

#tabbar {
	flex: 0 0 auto; display: flex; justify-content: space-around; padding: 6px 4px calc(var(--sab) + 6px);
	background: hsla(var(--world-hue), 30%, 8%, .85); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
	border-top: 1px solid var(--line);
}
#tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 10px; border-radius: 10px; min-width: 56px; }
#tabbar button .ico { font-size: 20px; line-height: 1; }
#tabbar button.active { color: var(--gold); }

/* ---------- Boutons ---------- */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 14px;
	font-weight: 700; font-size: 16px; background: var(--panel-2); border: 1px solid var(--line); transition: transform .08s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: linear-gradient(180deg, #5fe0b3, #2fa87c); color: #05261a; border-color: transparent; box-shadow: 0 6px 18px rgba(47, 168, 124, .35); }
.btn.gold { background: linear-gradient(180deg, #f3d27a, #cfa03a); color: #3b2a00; border-color: transparent; box-shadow: 0 6px 18px rgba(207, 160, 58, .35); }
.btn.ghost { background: var(--panel); }
.btn.danger { color: #ff8b80; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn.big { width: 100%; padding: 16px; font-size: 20px; flex-direction: column; gap: 0; border-radius: 18px; }
.btn.big small { font-size: 13px; font-weight: 600; opacity: .85; }

/* ---------- Accueil ---------- */
#screen-home.active { display: flex; flex-direction: column; min-height: 100%; }
.home-hero { flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 6vh 0 3vh; }
.logo-tile {
	width: 72px; height: 94px; margin: 0 auto 10px; border-radius: 10px; background: var(--tile-face);
	box-shadow: 4px 4px 0 var(--tile-side), 6px 6px 0 var(--tile-side-2), 10px 12px 26px rgba(0, 0, 0, .45);
	display: grid; place-items: center; font-family: var(--serif); font-size: 48px; color: #b8322a; font-weight: 700;
	animation: floaty 4s ease-in-out infinite;
}
@keyframes floaty { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(3deg); } }
.logo { font-family: var(--serif); font-size: 40px; letter-spacing: .5px; line-height: 1; }
.logo em { font-style: italic; color: var(--jade); background: linear-gradient(90deg, #3fbf95 0%, #4fd1a5 35%, #d6fff0 50%, #4fd1a5 65%, #3fbf95 100%); background-size: 220% 100%; -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; animation: shimmer 4.5s linear infinite; }
@keyframes shimmer { 0% { background-position: 110% 0; } 100% { background-position: -110% 0; } }
.btn.big.primary { animation: playPulse 2.6s ease-in-out infinite; }
@keyframes playPulse { 0%, 100% { box-shadow: 0 6px 18px rgba(47, 168, 124, .35); } 50% { box-shadow: 0 8px 30px rgba(79, 209, 165, .7), 0 0 0 6px rgba(79, 209, 165, .12); } }
.btn.big .next-tag { display: inline-flex; gap: 6px; align-items: center; margin-top: 4px; font-size: 12px; font-weight: 600; opacity: .85; }
.btn.big .next-tag i { font-style: normal; padding: 1px 8px; border-radius: 999px; background: rgba(0, 0, 0, .18); }
.home-world { margin: 14px auto 4px; max-width: 420px; }
.home-world .hw-name { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.home-world .hw-name b { color: var(--text); font-weight: 600; }
.home-world .hw-bar { height: 8px; border-radius: 4px; background: rgba(255, 255, 255, .1); overflow: hidden; }
.home-world .hw-bar i { display: block; height: 100%; width: 0; border-radius: 4px; background: linear-gradient(90deg, var(--jade), #b9ffe3); transition: width .8s cubic-bezier(.2, .8, .3, 1); }
.home-sub { color: var(--muted); margin: 8px 0 0; font-size: 14px; }
/* défi du jour */
.card.dc { border-color: rgba(232, 192, 96, .4); background: linear-gradient(135deg, hsla(45, 55%, 35%, .22), var(--panel)); display: flex; flex-direction: column; gap: 6px; }
.dc-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 16px; }
.dc-head .dc-date { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.dc-body { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.dc-body .dc-ok { color: var(--jade); font-weight: 600; } .dc-body .dc-todo { color: var(--gold); font-weight: 600; }
.dc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 13px; }
.card.dc .hint { font-size: 11px; }
.lb-tabs { margin: 4px 0 0; }
.home-stats { text-align: center; color: var(--muted); margin: 12px 0; font-size: 14px; display: flex; justify-content: center; align-items: center; gap: 4px; flex-wrap: wrap; }
.home-stats b { color: var(--text); }
.home-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.tile-btn {
	background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 6px; display: flex; flex-direction: column; align-items: center; gap: 6px;
	font-size: 13px; font-weight: 600; color: var(--text);
}
.tile-btn .ico { font-size: 24px; line-height: 1; }
.tile-btn:active { transform: scale(.96); }
.home-foot { text-align: center; color: var(--muted); font-size: 12px; margin-top: auto; padding: 18px 0 6px; }
.diag { text-align: left; font: 12px/1.5 ui-monospace, Menlo, monospace; white-space: pre-wrap; user-select: text; -webkit-user-select: text; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 14px; margin: 12px 0; }
.card.daily { display: flex; align-items: center; gap: 12px; border-color: rgba(232, 192, 96, .45); background: linear-gradient(135deg, hsla(45, 60%, 40%, .25), var(--panel)); }
.daily-ico { font-size: 30px; }
.daily-body { flex: 1; display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.daily-body b { color: var(--text); font-size: 15px; }

/* ---------- Niveaux ---------- */
.world { margin: 14px 0 22px; padding: 12px; border-radius: 18px; background: linear-gradient(160deg, hsla(var(--world-hue), 45%, 30%, .5), hsla(var(--world-hue), 35%, 14%, .5)); border: 1px solid var(--line); }
.world.locked { opacity: .55; }
.world-locked { margin: 0; font-size: 13px; color: var(--muted); }
.world-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.world-head small { color: var(--muted); display: block; font-size: 12px; }
.world-head b { font-family: var(--serif); font-size: 20px; }
.world-stars { display: flex; align-items: center; gap: 4px; font-weight: 700; color: var(--gold); }
.world-stars svg { width: 18px; height: 18px; fill: var(--gold); }
.level-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.lvl {
	aspect-ratio: 1; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
	font-weight: 800; font-size: 17px; color: var(--text); position: relative;
}
.lvl.done { background: linear-gradient(180deg, hsla(var(--world-hue), 50%, 40%, .8), hsla(var(--world-hue), 50%, 28%, .8)); }
.lvl.current { background: linear-gradient(180deg, #f3d27a, #cfa03a); color: #3b2a00; box-shadow: 0 0 0 3px rgba(243, 210, 122, .35); animation: pulse 1.6s ease-in-out infinite; }
.lvl.locked { opacity: .5; }
.lvl.boss::before { content: '👑'; position: absolute; top: -8px; right: -4px; font-size: 14px; }
.lvl .lock { font-style: normal; font-size: 12px; }
.lvl::after { content: ''; position: absolute; left: 10px; right: 10px; bottom: 5px; height: 3px; border-radius: 2px; background: var(--dc, transparent); opacity: .9; }
[data-diff="facile"] { --dc: #4fd1a5; } [data-diff="moyen"] { --dc: #e8c060; } [data-diff="difficile"] { --dc: #f0883e; } [data-diff="extreme"] { --dc: #e0574b; }
.diff-legend { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 2px; font-size: 12px; color: var(--muted); }
.diff-legend span { display: inline-flex; align-items: center; gap: 5px; }
.diff-legend span::before { content: ''; width: 10px; height: 10px; border-radius: 50%; background: var(--dc); }
.intro-diff { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #08201a; background: var(--dc); }
.intro-hidden { color: var(--muted); font-size: 14px; }
.intro-theme { color: var(--text); font-size: 14px; font-weight: 600; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(243, 210, 122, .35); } 50% { box-shadow: 0 0 0 6px rgba(243, 210, 122, .15); } }

.stars { display: inline-flex; gap: 1px; }
.stars svg { width: 18px; height: 18px; }
.stars.xs svg { width: 11px; height: 11px; }
.stars.sm svg { width: 15px; height: 15px; }
.stars.lg svg { width: 44px; height: 44px; }
.stars .on svg { fill: var(--gold); filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .4)); }
.stars .off svg { fill: rgba(255, 255, 255, .18); }
.lvl.current .stars .off svg { fill: rgba(0, 0, 0, .2); }

/* ---------- Jeu ---------- */
.game-top {
	display: flex; align-items: center; gap: 8px; padding: calc(var(--sat) + 4px) 10px 4px; flex: 0 0 auto;
}
.g-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.g-info b { font-size: 15px; } .g-info small { color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 20px; padding: 3px 10px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); min-width: 74px; text-align: center; }
.g-timer.warn { color: #ff8b80; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .5; } }
.g-score { display: flex; flex-direction: column; align-items: flex-end; min-width: 60px; }
.g-score b { font-size: 18px; font-variant-numeric: tabular-nums; } .g-score small { color: var(--muted); font-size: 11px; }

/* Réserve */
#tray { flex: 0 0 auto; display: flex; justify-content: center; gap: 6px; padding: 0 10px 4px; --tray-tw: 44px; --dz: 4px; isolation: isolate; }
#tray .slot { width: var(--tray-tw); height: calc(var(--tray-tw) * 1.3); border-radius: calc(var(--tray-tw) * .12); border: 2px dashed rgba(255, 255, 255, .22); background: rgba(0, 0, 0, .22); position: relative; transition: background .15s, border-color .15s; }
#tray .slot.empty:active { background: rgba(79, 209, 165, .25); border-color: var(--jade); }
#tray.can-park .slot.empty { border-color: var(--jade); background: rgba(79, 209, 165, .14); animation: slotPulse 1s ease-in-out infinite; }
#tray.can-park .slot.empty::after { content: '↑'; position: absolute; inset: 0; display: grid; place-items: center; color: var(--jade); font-weight: 800; font-size: calc(var(--tray-tw) * .5); opacity: .8; }
@keyframes slotPulse { 0%, 100% { box-shadow: 0 0 0 0 var(--pulse, rgba(79, 209, 165, .35)); } 50% { box-shadow: 0 0 0 5px rgba(0, 0, 0, 0); } }
#tray .slot.danger { border-color: rgba(255, 107, 94, .6); }
#tray .slot.danger.empty::before { content: '☠'; position: absolute; inset: 0; display: grid; place-items: center; color: rgba(255, 107, 94, .55); font-size: calc(var(--tray-tw) * .45); }
#tray.can-park .slot.empty.danger { border-color: #ff6b5e; background: rgba(224, 87, 75, .2); animation: none; }
#tray.can-park .slot.empty.danger::after { content: '!'; color: #ff8b80; }
#tray.can-park .slot.empty.danger::before { display: none; }
#tray .slot.danger:not(.empty) { box-shadow: 0 0 0 3px rgba(255, 107, 94, .35); }
#tray.full .slot { border-color: #ff6b5e; animation: slotPulse 1s ease-in-out infinite; }
#tray.full .slot { --pulse: rgba(255, 107, 94, .4); }
#tray .tray-tile { position: absolute; left: -2px; top: -2px; width: var(--tray-tw); height: calc(var(--tray-tw) * 1.3); }
#tray .tray-tile.selected { transform: translateY(-4px) scale(1.06); }
.intro-tray { color: var(--muted); font-size: 14px; }

#board-wrap { flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 6px; position: relative; isolation: isolate; }
/* tapis de jeu : feutre vert, liseré doré, vignettage */
#board-wrap::before {
	content: ''; position: absolute; inset: 2px 4px; border-radius: 18px; z-index: -2; pointer-events: none;
	background: transparent;
	box-shadow: inset 0 0 0 2px rgba(232, 192, 96, .3), inset 0 0 0 5px rgba(0, 0, 0, .18), inset 0 0 50px rgba(0, 0, 0, .22);
}
/* emblème en filigrane */
#board-wrap::after {
	content: ''; position: absolute; left: 50%; top: 50%; width: min(68%, 300px); aspect-ratio: 1; transform: translate(-50%, -50%);
	background: url("data:image/svg+xml,<svg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20200%20200'><g%20fill='none'%20stroke='%23e8c060'%20stroke-width='2'><circle%20cx='100'%20cy='100'%20r='94'/><circle%20cx='100'%20cy='100'%20r='84'%20stroke-dasharray='5%207'/><circle%20cx='100'%20cy='100'%20r='34'/><circle%20cx='100'%20cy='100'%20r='14'/></g><g%20stroke='%23e8c060'%20stroke-width='3'%20stroke-linecap='round'><line%20x1='140.0'%20y1='100.0'%20x2='170.0'%20y2='100.0'/><line%20x1='128.3'%20y1='128.3'%20x2='149.5'%20y2='149.5'/><line%20x1='100.0'%20y1='140.0'%20x2='100.0'%20y2='170.0'/><line%20x1='71.7'%20y1='128.3'%20x2='50.5'%20y2='149.5'/><line%20x1='60.0'%20y1='100.0'%20x2='30.0'%20y2='100.0'/><line%20x1='71.7'%20y1='71.7'%20x2='50.5'%20y2='50.5'/><line%20x1='100.0'%20y1='60.0'%20x2='100.0'%20y2='30.0'/><line%20x1='128.3'%20y1='71.7'%20x2='149.5'%20y2='50.5'/></g></svg>") center / contain no-repeat; opacity: .12; z-index: -1; pointer-events: none;
}
/* logo au centre avant l'arrivée des tuiles */
.board-logo { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; z-index: 0; pointer-events: none; transition: opacity .6s ease, transform .6s ease; }
.board-logo .logo-tile { width: 64px; height: 84px; font-size: 42px; margin: 0; }
.board-logo .board-logo-name { font-family: var(--serif); font-size: 26px; color: var(--text); text-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.board-logo .board-logo-name em { color: var(--jade); }
.board-logo.fade { opacity: 0; transform: scale(.85); }
.board { position: relative; --tw: 40px; --th: 52px; --dz: 5px; --zpad: 0px; }

.tile {
	position: absolute; width: var(--tw); height: var(--th);
	left: calc(var(--x) * var(--tw) / 2 - var(--z) * var(--dz) + var(--zpad));
	top: calc(var(--y) * var(--th) / 2 - var(--z) * var(--dz) + var(--zpad));
	border-radius: calc(var(--tw) * .12);
	background: var(--tile-face);
	box-shadow: calc(var(--dz) * .55) calc(var(--dz) * .55) 0 var(--tile-side), calc(var(--dz) * .55 + 1px) calc(var(--dz) * .55 + 1px) 0 var(--tile-side-2), calc(var(--dz) * 1.2) calc(var(--dz) * 1.5) calc(var(--dz) * 1.8) rgba(0, 0, 0, .38), inset 0 0 0 1px rgba(90, 70, 20, .08);
	transition: transform .12s, box-shadow .12s, filter .2s, opacity .25s;
	cursor: pointer; will-change: transform;
}
.tile .face { position: absolute; inset: 4% 5%; }
.tile .face svg { width: 100%; height: 100%; display: block; }
.tile::after { content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; transition: background .2s; }
.tile.blocked::after { background: rgba(20, 30, 25, .32); }
body.no-dim .tile.blocked::after { background: transparent; }
body.no-idx .tile .idx { display: none; }
.tile.selected { transform: translate(-3px, -5px) scale(1.06); z-index: 99999 !important; box-shadow: 0 0 0 3px var(--gold), calc(var(--dz) * .55) calc(var(--dz) * .55) 0 var(--tile-side), 0 10px 22px rgba(0, 0, 0, .5); }
.tile.selected::after { background: rgba(232, 192, 96, .22); }
.tile.hint { animation: hintGlow 1s ease-in-out infinite; }
.tile.hint::after { background: rgba(79, 209, 165, .28); }
@keyframes hintGlow { 0%, 100% { box-shadow: 0 0 0 2px var(--jade), calc(var(--dz) * .55) calc(var(--dz) * .55) 0 var(--tile-side), 0 0 14px rgba(79, 209, 165, .5); } 50% { box-shadow: 0 0 0 4px var(--jade), calc(var(--dz) * .55) calc(var(--dz) * .55) 0 var(--tile-side), 0 0 26px rgba(79, 209, 165, .9); } }
/* tuiles retournées */
.tile.hidden-face .face { opacity: 0; }
.tile.hidden-face::before { content: '?'; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(160deg, hsl(var(--world-hue), 40%, 34%), hsl(var(--world-hue), 45%, 18%)); color: rgba(255, 255, 255, .45); display: grid; place-items: center; font-family: var(--serif); font-weight: 700; font-size: calc(var(--tw) * .55); box-shadow: inset 0 0 0 calc(var(--tw) * .07) rgba(255, 255, 255, .12); }
.tile.hidden-face.blocked::after { background: rgba(0, 0, 0, .3); }
.tile.flip { animation: flip .38s ease-in-out; }
@keyframes flip { 0% { transform: scaleX(1); } 45% { transform: scaleX(.05); } 55% { transform: scaleX(.05); } 100% { transform: scaleX(1); } }
.tile.pre-enter { opacity: 0; transform: translateX(var(--edx, -120vw)) rotate(var(--erot, -8deg)) scale(.9); }
.tile.entering { transition: transform .55s cubic-bezier(.2, .85, .25, 1.05), opacity .3s ease-out; }
.tile.removed { display: none; }
.tile.flying { visibility: hidden; }
.tile.ghost { pointer-events: none; }
.tile.vanish { animation: vanish .25s ease-in forwards; pointer-events: none; z-index: 99999 !important; }
@keyframes vanish { 0% { transform: scale(1.05); opacity: 1; } 100% { transform: scale(1.5) translateY(-10px); opacity: 0; } }
.tile.shake { animation: shake .3s; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px) rotate(-2deg); } 75% { transform: translateX(4px) rotate(2deg); } }
.tile.pop { animation: pop .3s ease-out; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

.boosters { flex: 0 0 auto; display: flex; justify-content: center; gap: 8px; padding: 6px 10px calc(var(--sab) + 6px); background: rgba(0, 0, 0, .18); border-top: 1px solid rgba(232, 192, 96, .14); }
.booster {
	flex: 1; max-width: 110px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 5px 4px 4px; border-radius: 12px;
	background: var(--panel); border: 1px solid var(--line); font-size: 10px; font-weight: 600; color: var(--text); position: relative;
}
.booster svg { width: 22px; height: 22px; color: var(--jade); }
.booster .b-count { position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 10px; background: var(--gold); color: #3b2a00; font-size: 12px; display: grid; place-items: center; }
.booster.zero .b-count { background: #3d4a45; color: #cfd8d3; }
.booster.zero svg { color: var(--muted); }
.booster:active { transform: scale(.95); }

.combo-banner {
	position: absolute; left: 50%; top: 18%; transform: translate(-50%, 0); pointer-events: none; z-index: 5;
	font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 34px; color: var(--gold); text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
.combo-banner.show { animation: comboPop .9s ease-out forwards; }
.combo-banner.show.long { animation-duration: 1.4s; }
@keyframes comboPop { 0% { transform: translate(-50%, 10px) scale(.6); opacity: 0; } 20% { transform: translate(-50%, 0) scale(1.15); opacity: 1; } 100% { transform: translate(-50%, -30px) scale(1); opacity: 0; } }

/* ---------- Tutoriel ---------- */
#tuto { position: fixed; inset: 0; z-index: 850; pointer-events: none; }
#tuto .tuto-spot { position: absolute; border-radius: 12px; box-shadow: 0 0 0 9999px rgba(3, 12, 9, .68), 0 0 0 3px var(--gold), 0 0 24px rgba(232, 192, 96, .6); transition: left .3s, top .3s, width .3s, height .3s; }
#tuto .tuto-bubble { position: absolute; left: 50%; transform: translateX(-50%); width: min(92vw, 360px); background: linear-gradient(170deg, hsl(150, 28%, 22%), hsl(150, 32%, 12%)); border: 1px solid rgba(232, 192, 96, .5); border-radius: 18px; padding: 14px 16px; box-shadow: 0 16px 40px rgba(0, 0, 0, .6); pointer-events: auto; animation: rise .25s ease-out; }
#tuto .tuto-bubble.center { top: 50%; transform: translate(-50%, -50%); }
#tuto .tuto-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
#tuto .tuto-skip { color: var(--muted); text-decoration: underline; font-size: 12px; }
#tuto .tuto-text { margin: 0 0 10px; font-size: 15px; line-height: 1.45; color: var(--text); }
#tuto .tuto-next { width: 100%; }
.tuto-target { z-index: 99998 !important; animation: hintGlow 1s ease-in-out infinite; }
#tray.tuto-target, .boosters.tuto-target { animation: none; }

/* ---------- Effets ---------- */
#fx { position: fixed; inset: 0; pointer-events: none; z-index: 1000; overflow: hidden; }
#fx i { position: absolute; width: 7px; height: 7px; border-radius: 50%; animation: particle .7s ease-out forwards; }
@keyframes particle { 0% { transform: translate(-50%, -50%) scale(1); opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; } }
#fx .confetti { position: absolute; width: 8px; height: 14px; border-radius: 2px; animation: confetti 1.8s ease-in forwards; }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--dx), 110vh) rotate(720deg); opacity: .7; } }
#fx .bolts { position: absolute; inset: 0; width: 100%; height: 100%; }
#fx .bolt { fill: none; stroke-linejoin: round; stroke-linecap: round; animation: boltFlicker .5s ease-out forwards; opacity: 0; }
#fx .bolt.core { stroke: #fff8c8; stroke-width: 3; }
#fx .bolt.glow { stroke: #ffd84a; stroke-width: 10; opacity: 0; filter: blur(3px); }
@keyframes boltFlicker { 0% { opacity: 0; } 10% { opacity: 1; } 30% { opacity: .5; } 45% { opacity: 1; } 100% { opacity: 0; } }
#fx .flash { position: absolute; inset: 0; background: #fff; animation: flashOut .4s ease-out forwards; }
@keyframes flashOut { 0% { opacity: .55; } 100% { opacity: 0; } }
.tile.zap { animation: zap .45s ease-out; filter: brightness(1.8) saturate(1.4); }
@keyframes zap { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-3px, 2px); } 40% { transform: translate(3px, -2px); } 60% { transform: translate(-2px, -2px); } 80% { transform: translate(2px, 2px); } }
.lvl .sp { position: absolute; top: -6px; left: -4px; font-style: normal; font-size: 13px; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }
.intro-special { color: #ffd84a; font-weight: 700; font-size: 14px; }
#fx .shock { position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; border: 4px solid #ffb347; box-shadow: 0 0 20px #ff7a2a; animation: shock .7s ease-out forwards; }
#fx .shock.big { border-width: 2px; border-color: #fff0c0; animation-duration: .9s; }
#fx .boom { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: radial-gradient(circle, #fff6c0 0%, #ff9a2a 40%, rgba(255, 60, 20, 0) 70%); animation: boomFlash .5s ease-out forwards; }
@keyframes shock { 0% { transform: scale(.3); opacity: 1; } 100% { transform: scale(14); opacity: 0; } }
@keyframes boomFlash { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(5); opacity: 0; } }
body.quake #app { animation: quake .45s ease-out; }
@keyframes quake { 0%, 100% { transform: translate(0, 0); } 15% { transform: translate(-6px, 4px); } 30% { transform: translate(5px, -5px); } 45% { transform: translate(-4px, 3px); } 60% { transform: translate(4px, 2px); } 75% { transform: translate(-2px, -2px); } }
#fx .float { position: absolute; transform: translate(-50%, -100%); font-weight: 900; font-size: 18px; color: #fff; text-shadow: 0 2px 6px rgba(0, 0, 0, .7); animation: floatUp .9s ease-out forwards; }
#fx .float.hot { color: var(--gold); font-size: 22px; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, -80%); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -200%); } }

/* ---------- Modales ---------- */
.modal-back { position: fixed; inset: 0; z-index: 900; background: rgba(4, 12, 10, .72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; padding: 20px; animation: fade .18s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: 100%; max-width: 380px; background: linear-gradient(170deg, hsl(var(--world-hue), 28%, 22%), hsl(var(--world-hue), 32%, 12%)); border: 1px solid var(--line); border-radius: 22px; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); animation: rise .22s ease-out; max-height: calc(var(--vh, 1vh) * 90); overflow-y: auto; }
@keyframes rise { from { transform: translateY(16px) scale(.97); opacity: 0; } }
.modal h2 { font-family: var(--serif); font-size: 24px; text-align: center; margin-bottom: 10px; }
.modal-body { text-align: center; color: var(--muted); font-size: 15px; line-height: 1.45; }
.modal-body p { margin: 6px 0; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.modal-actions .btn { flex: 1; min-width: 100px; }
.modal.stack .modal-actions { flex-direction: column; }
.modal.stack .modal-actions .btn { width: 100%; }
.modal .cnt { margin-left: 6px; background: var(--gold); color: #3b2a00; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.hint { color: var(--muted); font-size: 13px; }

.intro { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.intro-layout { font-family: var(--serif); font-size: 26px; color: var(--jade); }
.intro-row { display: flex; gap: 16px; font-weight: 700; color: var(--text); }
.intro-goal, .intro-best { display: flex; align-items: center; gap: 6px; }

.win-stars { display: flex; justify-content: center; margin: 4px 0 8px; }
.win-modal.celebrate .win-stars .on svg { animation: starIn .5s cubic-bezier(.2, 1.5, .5, 1) both; }
.win-modal.celebrate .win-stars .on:nth-child(2) svg { animation-delay: .2s; }
.win-modal.celebrate .win-stars .on:nth-child(3) svg { animation-delay: .4s; }
@keyframes starIn { from { transform: scale(0) rotate(-60deg); opacity: 0; } }
.win-record { color: var(--gold); font-weight: 800; letter-spacing: .5px; text-transform: uppercase; font-size: 13px; }
.win-row { display: flex; justify-content: space-between; padding: 6px 4px; border-bottom: 1px dashed var(--line); color: var(--text); }
.win-row b { font-variant-numeric: tabular-nums; }
.win-coins { margin-top: 10px; font-size: 20px; font-weight: 800; color: var(--gold); }

.help { text-align: left; padding-left: 20px; margin: 0; color: var(--text); }
.help li { margin: 8px 0; font-size: 14px; }
.help-tiles { display: flex; gap: 6px; margin-top: 6px; }
.mini { width: 30px; height: 39px; border-radius: 4px; background: var(--tile-face); box-shadow: 2px 2px 0 var(--tile-side-2); display: block; padding: 2px; }
.mini svg { width: 100%; height: 100%; }
.mini.sep { background: none; box-shadow: none; width: 10px; }

/* ---------- Listes / réglages ---------- */
.card.list { padding: 4px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); width: 100%; text-align: left; font-size: 15px; color: var(--text); text-decoration: none; }
.row:last-child { border-bottom: 0; }
.row.hint { font-size: 12px; }
.btn-row .chev { color: var(--muted); font-size: 20px; }
.btn-row.danger { color: #ff8b80; }
select { font: inherit; background: var(--panel-2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
.switch { appearance: none; -webkit-appearance: none; width: 46px; height: 26px; border-radius: 13px; background: #3d4a45; position: relative; transition: background .2s; flex: 0 0 auto; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch:checked { background: var(--jade); }
.switch:checked::after { transform: translateX(20px); }

/* ---------- Boutique ---------- */
.shop-sec h3 { font-family: var(--serif); font-size: 18px; margin-bottom: 8px; }
.shop-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px; border-radius: 14px; background: var(--panel-2); border: 1px solid var(--line); margin: 6px 0; text-align: left; color: var(--text); }
.shop-item:disabled { opacity: .5; }
.shop-item.gold { border-color: rgba(232, 192, 96, .5); background: linear-gradient(135deg, hsla(45, 60%, 40%, .35), var(--panel-2)); }
.si-ico { width: 40px; height: 40px; border-radius: 12px; background: rgba(0, 0, 0, .25); display: grid; place-items: center; font-size: 20px; flex: 0 0 auto; }
.si-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.si-body b { font-size: 15px; } .si-body b em { font-style: normal; color: var(--gold); }
.si-body small { color: var(--muted); font-size: 12px; }
.si-price { font-weight: 800; color: var(--gold); white-space: nowrap; }

/* ---------- Classement ---------- */
.lb { width: 100%; border-collapse: collapse; font-size: 14px; }
.lb th { text-align: left; color: var(--muted); font-weight: 600; font-size: 12px; padding: 4px 6px; }
.lb td { padding: 8px 6px; border-top: 1px solid var(--line); }
.lb tr.me td { background: rgba(232, 192, 96, .12); font-weight: 700; }
.center { text-align: center; } .muted { color: var(--muted); }

/* ---------- Compte ---------- */
.acc { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: linear-gradient(180deg, #5fe0b3, #2fa87c); color: #05261a; display: grid; place-items: center; font-size: 28px; font-weight: 800; margin-bottom: 6px; }
.avatar.guest { background: var(--panel-2); color: var(--muted); }
.acc small { color: var(--muted); }
.acc-stats { display: flex; align-items: center; gap: 4px; margin-top: 6px; color: var(--muted); font-size: 14px; }
.sync { font-size: 13px; margin-top: 6px; color: var(--jade); } .sync.error { color: #ff8b80; } .sync.syncing { color: var(--muted); }
.tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.tab { flex: 1; padding: 10px; border-radius: 12px; background: var(--panel-2); font-weight: 700; color: var(--muted); }
.tab.active { background: var(--jade); color: #05261a; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.field span { font-size: 13px; color: var(--muted); }
.field input { font: inherit; padding: 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0, 0, 0, .25); color: var(--text); width: 100%; -webkit-user-select: text; user-select: text; }
.field input:focus { outline: 2px solid var(--jade); }
.field small { color: var(--muted); font-size: 12px; }
.form-error { color: #ff8b80; font-size: 14px; margin: 4px 0; }

/* ---------- Pub simulée ---------- */
#ad-modal { position: fixed; inset: 0; z-index: 950; background: #000; display: flex; align-items: center; justify-content: center; }
.ad-box { width: min(92vw, 360px); text-align: center; color: #fff; }
.ad-title { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; color: #999; margin-bottom: 12px; }
.ad-fake { border: 1px dashed #444; border-radius: 16px; padding: 40px 20px; background: linear-gradient(160deg, #1b1b1b, #0a0a0a); }
.ad-fake-logo { width: 70px; height: 90px; margin: 0 auto 14px; border-radius: 10px; background: #f4eddc; color: #b8322a; font-size: 44px; font-family: var(--serif); display: grid; place-items: center; font-weight: 700; }
.ad-fake p { margin: 0; color: #bbb; }
.ad-bar { height: 5px; background: #333; border-radius: 3px; margin: 16px 0 8px; overflow: hidden; }
.ad-bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width 1s linear; }
.ad-count { color: #aaa; font-size: 14px; min-height: 20px; }
.ad-skip { margin-top: 10px; background: #fff; color: #000; }

/* ---------- Debug ---------- */
#debug-btn { position: fixed; left: 6px; top: 50%; z-index: 800; width: 34px; height: 34px; border-radius: 50%; background: rgba(0, 0, 0, .45); border: 1px solid var(--line); font-size: 16px; opacity: .6; }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 84px); transform: translateX(-50%); z-index: 990; background: rgba(8, 20, 16, .95); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 14px; font-size: 14px; max-width: 90vw; text-align: center; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); display: flex; gap: 10px; align-items: center; }
#toast.show { animation: toastIn .25s ease-out; }
@keyframes toastIn { from { transform: translate(-50%, 10px); opacity: 0; } }

/* ---------- Responsive / paysage ---------- */
@media (min-width: 700px) {
	.level-grid { grid-template-columns: repeat(5, 1fr); }
	.home-grid { grid-template-columns: repeat(6, 1fr); }
}
@media (orientation: landscape) and (max-height: 500px) {
	.game-top { padding-top: 4px; padding-bottom: 2px; }
	.boosters { padding-top: 2px; padding-bottom: calc(var(--sab) + 4px); }
	.booster { flex-direction: row; gap: 6px; padding: 4px 10px; }
	.booster svg { width: 18px; height: 18px; }
}
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
