/* =====================================================================
   game.css – the flag game "Koble tre" (flagg-spill.html)
   ---------------------------------------------------------------------
   Sections:
     1. Top (home link, back link, language switch)
     2. Screens and buttons
     3. Score bar (level, hearts, points)
     4. Flags (top) and cards (bottom)
     5. Effects (entering, picking, right, wrong, +5, hearts)
     6. Game over (points animation, missed flags)
     7. Phones
     8. Choosing a level (Beginner, Medium, Hard with its padlock)
     9. Beginner's progress bar, perfect bonus, share button
    10. The flag album
    11. Beginner: streak dots, progress line, sound button, "×2"
    12. Learn: mistakes counter and the practice button
    13. The pack ladder (Learn and Beginner)
    14. Medals, next pack, "Ready? Try Beginner"
    15. Achievements
    16. The secret level (door, night-blue and gold look, key on the ladder)
    17. The game hall (one card per game, top of the start screen)
   Colours and fonts come from common.css.
   ===================================================================== */

:root { --max: 860px; --card-back: #383f48; }


/* ---------- 1. Top ---------- */
.top { display: flex; align-items: center; gap: 18px; padding: 22px 24px 10px; }
.home, .back {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	color: var(--dark);
	font-weight: 600;
	font-size: .9rem;
	text-decoration: none;
}
.back { color: var(--text); font-weight: 400; }
.home img { width: 28px; height: 28px; }
.home:hover, .back:hover { color: var(--primary); }

/* Language switch – the same look as the other pages */
.lang { display: flex; gap: 2px; margin-left: auto; padding: 3px; border: 1px solid var(--line); border-radius: 99px; background: #fff; }
.lang button { border: 0; background: none; padding: 4px 10px; border-radius: 99px; font-size: .72rem; font-weight: 600; letter-spacing: .05em; color: #999; cursor: pointer; }
.lang button:hover { color: var(--dark); }
.lang button[aria-pressed="true"] { background: var(--primary); color: #fff; }


/* ---------- 2. Screens and buttons ---------- */
.game { padding-bottom: 60px; }
.screen { text-align: center; padding-top: 24px; }
.screen[hidden] { display: none; }

h1 {
	margin: 10px 0 6px;
	color: var(--dark);
	font-size: clamp(1.8rem, 6vw, 2.6rem);
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .02em;
	line-height: 1.2;
}
h2 { color: var(--dark); font-size: 1.1rem; margin: 0 0 4px; }

.intro { font-size: 1.05rem; color: var(--dark); margin: 0 0 18px; }
.rules { list-style: none; padding: 0; margin: 0 auto 22px; max-width: 460px; text-align: left; }
.rules li { position: relative; padding: 6px 0 6px 28px; border-bottom: 1px solid var(--line); }
.rules li::before { content: "🍍"; position: absolute; left: 0; top: 6px; font-size: .9rem; }
.best-line { font-weight: 600; color: var(--dark); }

.big-button {
	display: inline-block;
	padding: 14px 44px;
	border: 0;
	border-radius: 99px;
	background: var(--primary);
	color: #fff;
	font-size: 1.05rem;
	font-weight: 600;
	letter-spacing: .04em;
	text-transform: uppercase;
	cursor: pointer;
	box-shadow: 0 8px 20px rgba(0, 136, 204, .3);
	transition: transform .2s ease, background .2s ease;
}
.big-button:hover { background: var(--primary-hover); transform: translateY(-2px); }
.big-button:focus-visible, .plain-button:focus-visible { outline: 3px solid var(--dark); outline-offset: 3px; }
.plain-button { color: var(--text); text-decoration: none; padding: 10px 16px; border: 0; background: none; font: inherit; cursor: pointer; }
.plain-button:hover { color: var(--primary); }


/* ---------- 3. Score bar ---------- */
.hud {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 10px 18px;
	border: 1px solid var(--line);
	border-radius: 16px;
	background: var(--soft);
	color: var(--dark);
}
.hud small { color: var(--text); text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; margin-right: 4px; }
.hud strong { display: inline-block; font-size: 1.3rem; min-width: 1.5em; }
.hud-lives { display: flex; gap: 6px; }
.heart { width: 26px; height: 26px; fill: var(--accent); transition: fill .3s ease; }
.heart.empty { fill: #ddd; }

.stage-note {
	margin: 12px auto 0;
	max-width: 520px;
	padding: 8px 16px;
	border-radius: 99px;
	background: var(--highlight);
	color: var(--dark);
	font-weight: 600;
	font-size: .9rem;
	animation: noteIn .5s cubic-bezier(.3, 1.4, .5, 1);
}
.hint { min-height: 1.7em; margin-top: 18px; color: var(--text); }


/* ---------- 4. Flags (top) and cards (bottom) ---------- */
.game-flags, .game-cards {
	list-style: none;
	padding: 0;
	margin: 26px 0 0;
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 18px;
}
.game-cards.four { grid-template-columns: repeat(4, 1fr); }
.game-cards li { position: relative; }

/* A flag: a button with the image, the same shape as the image */
.game-flag {
	display: block;
	width: 100%;
	padding: 0;
	border: 0;
	background: #f3f3f3;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .12);
	transition: transform .25s ease, box-shadow .25s ease, opacity .4s ease, filter .4s ease;
}
.game-flag img { display: block; width: 100%; height: auto; aspect-ratio: 600 / 410; }
@media (hover: hover) { .game-flag:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0, 0, 0, .18); } }
.game-flag:focus-visible, .game-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 4px; }

/* A card: the dark side shows the name; when matched it turns to show the flag */
.game-card {
	display: block;
	width: 100%;
	aspect-ratio: 600 / 410;
	padding: 0;
	border: 0;
	background: none;
	cursor: pointer;
	perspective: 900px;
	font: inherit;
}
.card-inner {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	transform-style: preserve-3d;
	transition: transform .7s cubic-bezier(.3, 1.35, .5, 1);
}
.card-back, .card-front {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	backface-visibility: hidden;
	-webkit-backface-visibility: hidden;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .14);
}
.card-back {
	background: linear-gradient(150deg, #4a5462 0%, var(--card-back) 55%, #2b3139 100%);
	color: #fff;
	padding: 8px 10px;
	transition: box-shadow .25s ease;
}
.card-back .label { font-weight: 600; line-height: 1.25; font-size: clamp(.8rem, 2.1vw, 1.05rem); }
.card-back .what { font-size: .7rem; color: #f5c518; margin-top: 4px; letter-spacing: .04em; }
.card-front { transform: rotateY(180deg); background: #fff; }
.card-front img { position: absolute; inset: 0; width: 100%; height: 100%; }
.card-front .label {
	position: absolute;
	left: 0; right: 0; bottom: 0;
	padding: 4px 6px;
	background: rgba(0, 0, 0, .55);
	color: #fff;
	font-size: .75rem;
	font-weight: 600;
}
@media (hover: hover) { .game-cards li:not(.done) .game-card:hover .card-back { box-shadow: 0 12px 24px rgba(0, 0, 0, .25); } }


/* ---------- 5. Effects ---------- */

/* A new level: flags drop in, cards rise up, one after another */
.enter li { animation: dropIn .5s cubic-bezier(.3, 1.4, .5, 1) backwards; animation-delay: calc(var(--i) * 70ms); }
.game-cards.enter li { animation-name: riseIn; animation-delay: calc(150ms + var(--i) * 70ms); }

/* The flag or card you tapped: lifted, a thick blue ring that pulses, and an arrow badge */
.game-flag { position: relative; }
.game-flags li.picked .game-flag {
	transform: translateY(-10px) scale(1.08);
	animation: pickPulse 1.1s ease-out infinite;
	z-index: 2;
}
.game-cards li.picked .game-card { transform: translateY(-8px) scale(1.06); transition: transform .25s ease; }
.game-cards li.picked .card-back { animation: pickPulse 1.1s ease-out infinite; background: linear-gradient(150deg, #1a9fe0 0%, var(--primary) 60%, #006699 100%); }

.pick-badge {
	position: absolute;
	left: 50%; bottom: -16px;
	width: 32px; height: 32px;
	margin-left: -16px;
	border-radius: 50%;
	background: var(--primary);
	color: #fff;
	font-weight: 700;
	line-height: 32px;
	box-shadow: 0 4px 10px rgba(0, 0, 0, .25);
	opacity: 0;
	transform: scale(0);
	transition: opacity .2s ease, transform .3s cubic-bezier(.3, 1.6, .5, 1);
}
.game-flags li.picked .pick-badge { opacity: 1; transform: scale(1); animation: badgeBob 1.2s ease-in-out infinite; }

/* The other flags (or cards) step back, so the picked one stands out */
.has-pick li:not(.picked):not(.done) .game-flag,
.has-pick li:not(.picked):not(.done) .game-card { opacity: .45; transform: scale(.94); transition: opacity .25s ease, transform .25s ease; }

/* The side to tap next glows softly */
.game-cards.waiting li:not(.done) .card-back { animation: invite 1.2s ease-in-out infinite; }
.game-flags.waiting li:not(.done) .game-flag { animation: invite 1.2s ease-in-out infinite; }

@keyframes pickPulse { 0%   { box-shadow: 0 0 0 5px var(--primary), 0 0 0 5px rgba(0, 136, 204, .5), 0 16px 30px rgba(0, 0, 0, .25); }
                       100% { box-shadow: 0 0 0 5px var(--primary), 0 0 0 16px rgba(0, 136, 204, 0), 0 16px 30px rgba(0, 0, 0, .25); } }
@keyframes invite    { 0%, 100% { box-shadow: 0 0 0 2px rgba(0, 136, 204, .25), 0 4px 14px rgba(0, 0, 0, .14); }
                       50%      { box-shadow: 0 0 0 5px rgba(0, 136, 204, .55), 0 8px 20px rgba(0, 0, 0, .18); } }
@keyframes badgeBob  { 50% { transform: translateY(4px); } }

/* Matched: the flag on top fades, the card turns over */
.game-flags li.done .game-flag { opacity: .25; filter: grayscale(1); cursor: default; transform: none; box-shadow: none; }
.game-cards li.done .card-inner { transform: rotateY(180deg); }
.game-cards li.done .game-card { cursor: default; }

/* Wrong: a quick shake and a red flash */
.shake { animation: shake .45s ease; }
.game-cards li.shake .card-back { background: var(--accent); }

/* The copy of the flag that flies onto the card */
.ghost { position: fixed; z-index: 50; pointer-events: none; box-shadow: 0 12px 28px rgba(0, 0, 0, .25); }

/* "+5" floating up */
.plus {
	position: absolute;
	left: 50%; top: 10%;
	z-index: 5;
	color: #1a9e4b;
	font-weight: 700;
	font-size: 1.5rem;
	text-shadow: 0 2px 6px rgba(255, 255, 255, .9);
	pointer-events: none;
	animation: plusUp .9s ease-out forwards;
}
.bump { animation: bump .4s cubic-bezier(.3, 1.6, .5, 1); }

/* Hearts: breaking when a life is lost, growing when one comes back */
.heart.breaking { animation: breakHeart .6s ease; }
.heart.growing { animation: growHeart .7s cubic-bezier(.3, 1.6, .5, 1); }

@keyframes dropIn  { from { opacity: 0; transform: translateY(-24px) scale(.9); } }
@keyframes riseIn  { from { opacity: 0; transform: translateY(24px) scale(.9); } }
@keyframes noteIn  { from { opacity: 0; transform: scale(.8); } }
@keyframes shake   { 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes plusUp  { from { opacity: 0; transform: translate(-50%, 10px); } 20% { opacity: 1; } to { opacity: 0; transform: translate(-50%, -46px); } }
@keyframes bump    { 50% { transform: scale(1.35); } }
@keyframes breakHeart { 0% { transform: scale(1); fill: var(--accent); } 40% { transform: scale(1.4) rotate(-12deg); } 100% { transform: scale(1); } }
@keyframes growHeart  { from { transform: scale(0); } }


/* ---------- 6. Game over ---------- */
.reached { color: var(--dark); margin: 0; }
.final { margin: 6px 0 0; color: var(--dark); }
.final { position: relative; }
.final strong { position: relative; display: inline-block; font-size: 3rem; line-height: 1.1; color: var(--primary); font-variant-numeric: tabular-nums; transition: color .3s ease; }
.final strong.bump { animation: scoreBump .25s ease-out; }
.final strong.done { animation: scoreDone .7s cubic-bezier(.3, 1.6, .5, 1); color: #1a9e4b; }
.new-best { display: inline-block; margin: 6px 0; padding: 4px 18px; border-radius: 99px; background: #f5c518; color: var(--dark); font-weight: 700; }
.new-best[hidden] { display: none; }
.new-best:not([hidden]) { animation: stamp .55s cubic-bezier(.3, 1.5, .5, 1); }   /* lands like a stamp */

/* The matched flags pop in one by one with "+5" */
.tally { list-style: none; padding: 0; margin: 18px auto; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 760px; }
.tally li { position: relative; width: 54px; opacity: 0; transform: scale(.4); transition: opacity .25s ease, transform .35s cubic-bezier(.3, 1.6, .5, 1); }
.tally li.in { opacity: 1; transform: none; animation: flipIn .45s cubic-bezier(.3, 1.5, .5, 1); }

/* The "+5" on its way up to the score, the ring every 100 points, and the confetti */
.flying-points { position: fixed; z-index: 60; pointer-events: none; padding: 0 6px; border-radius: 99px; background: #1a9e4b; color: #fff; font-size: .7rem; font-weight: 700; line-height: 1.5; box-shadow: 0 0 10px rgba(26, 158, 75, .6); }
.score-ring { position: absolute; left: 50%; top: 50%; width: 90px; height: 90px; margin: -45px 0 0 -45px; border: 4px solid #f5c518; border-radius: 50%; pointer-events: none; animation: ringOut .8s ease-out forwards; }
.confetti { position: fixed; z-index: 60; width: 9px; height: 14px; margin: -7px 0 0 -4px; pointer-events: none; box-shadow: 0 0 1px rgba(0, 0, 0, .3); }
@keyframes flipIn    { from { transform: perspective(300px) rotateY(90deg) scale(.6); } }
@keyframes scoreBump { 40% { transform: scale(1.12); color: #1a9e4b; } }
@keyframes scoreDone { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes ringOut   { from { transform: scale(.4); opacity: 1; } to { transform: scale(2.4); opacity: 0; } }
@keyframes stamp     { from { transform: scale(3) rotate(-14deg); opacity: 0; } 60% { opacity: 1; } }
.tally img { display: block; width: 100%; height: auto; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.tally span { position: absolute; top: -8px; right: -6px; padding: 0 5px; border-radius: 99px; background: #1a9e4b; color: #fff; font-size: .62rem; font-weight: 700; line-height: 1.5; }
.skip { font-size: .8rem; color: #aaa; }
.skip[hidden] { display: none; }

/* Missed flags, with name and capital, so you can learn them */
.missed { margin: 26px auto 0; max-width: 640px; padding: 18px; border-radius: 16px; background: var(--soft); }
.missed p { margin: 0 0 12px; font-size: .9rem; }
.missed-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; text-align: left; }
.missed-list li { display: flex; gap: 10px; align-items: center; background: #fff; padding: 8px; border-radius: 10px; }
.missed-list img { width: 60px; height: auto; flex: none; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.missed-list strong { display: block; color: var(--dark); font-size: .9rem; line-height: 1.3; }
.missed-list small { display: block; color: var(--text); font-size: .75rem; }
.end-buttons { margin-top: 28px; display: flex; gap: 12px; justify-content: center; align-items: center; flex-wrap: wrap; }


/* ---------- 7. Phones ---------- */
@media (max-width: 640px) {
	.top { gap: 12px; padding: 16px 16px 6px; }
	.container { padding: 0 16px; }
	.game-flags, .game-cards { gap: 10px; margin-top: 18px; }
	.game-cards.four { grid-template-columns: repeat(2, 1fr); }   /* 4 cards: 2 × 2 */
	.card-back .label { font-size: .8rem; }
	.hud { padding: 8px 12px; }
	.heart { width: 22px; height: 22px; }
	.game-flags li.picked .game-flag { transform: translateY(-8px) scale(1.04); }   /* a little less, so it doesn't cover its neighbours */
}

/* ---------- 8. Choosing a level ---------- */
.modes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; max-width: 720px; margin: 0 auto 18px; text-align: left; }
.mode { display: flex; flex-direction: column; gap: 6px; }
.mode-button {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 6px;
	height: 100%;
	padding: 18px 18px 16px;
	border: 2px solid var(--line);
	border-radius: 18px;
	background: #fff;
	text-align: left;
	cursor: pointer;
	box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
	transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
	animation: riseIn .5s cubic-bezier(.3, 1.4, .5, 1) backwards;
}
.mode:nth-child(2) .mode-button { animation-delay: .06s; }
.mode:nth-child(3) .mode-button { animation-delay: .12s; }
.mode:nth-child(4) .mode-button { animation-delay: .18s; }
.mode-button:hover { transform: translateY(-4px); border-color: var(--primary); box-shadow: 0 14px 28px rgba(0, 136, 204, .18); }
.mode-button:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.mode-name { display: flex; align-items: center; gap: 8px; color: var(--dark); font-size: 1.15rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.mode-text { font-size: .85rem; line-height: 1.5; }
.mode-best { margin-top: auto; padding-top: 4px; color: var(--dark); font-weight: 600; font-size: .8rem; }
.mode-best:empty { display: none; }
/* a coloured stripe on top of each card: yellow (Learn), green, blue, dark red (Hard) */
.mode-button::before { content: ""; position: absolute; left: 18px; right: 18px; top: -2px; height: 4px; border-radius: 0 0 4px 4px; background: #f5c518; }
.mode:nth-child(2) .mode-button::before { background: #1a9e4b; }
.mode:nth-child(3) .mode-button::before { background: var(--primary); }
.mode:nth-child(4) .mode-button::before { background: #b3261e; }
.restart { align-self: flex-start; border: 0; background: none; padding: 2px 4px; color: var(--text); font-size: .8rem; text-decoration: underline; cursor: pointer; }
.restart:hover { color: var(--primary); }

/* Hard, locked: greyed, with a padlock and a bar showing how close you are */
.padlock { width: 20px; height: 20px; color: #b3261e; display: none; }
.padlock .shackle { transition: transform .5s cubic-bezier(.3, 1.6, .5, 1); transform-origin: 16px 11px; }
.mode-button.locked .padlock, .mode-button.just-opened .padlock { display: inline-block; }
.mode-button.locked { cursor: not-allowed; background: var(--soft); border-style: dashed; }
.mode-button.locked .mode-name { color: #888; }
.mode-button.locked:hover { transform: none; border-color: #ccc; box-shadow: none; }
.lock-bar { position: relative; display: block; height: 22px; border-radius: 99px; background: #e9e9e9; overflow: hidden; }
.lock-bar[hidden] { display: none; }
.lock-fill { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: linear-gradient(90deg, #f5c518, #f4a261); transition: width .8s ease; }
.lock-label { position: relative; display: block; text-align: center; font-size: .72rem; font-weight: 600; line-height: 22px; color: var(--dark); }
/* the first time you see Hard open: the padlock springs open and fades away */
.mode-button.just-opened .padlock { animation: lockGone 1.6s ease forwards .6s; }
.mode-button.just-opened .padlock .shackle { animation: shackleUp .5s cubic-bezier(.3, 1.6, .5, 1) forwards .3s; }
.mode-button.just-opened { animation: openGlow 1.6s ease .3s; }
@keyframes shackleUp { to { transform: translateY(-4px) rotate(-35deg); } }
@keyframes lockGone  { 0%, 60% { opacity: 1; transform: none; } 100% { opacity: 0; transform: scale(.4); } }
@keyframes openGlow  { 30% { box-shadow: 0 0 0 6px rgba(245, 197, 24, .6), 0 14px 28px rgba(0, 0, 0, .12); border-color: #f5c518; } }

.points-rule { font-size: .85rem; margin: 0 0 14px; }
.album-button {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 22px;
	border: 2px solid var(--line);
	border-radius: 99px;
	background: #fff;
	color: var(--dark);
	font-weight: 600;
	cursor: pointer;
	transition: border-color .2s ease, transform .2s ease;
}
.album-button:hover { border-color: var(--primary); transform: translateY(-2px); }


/* ---------- 9. Beginner's progress bar, perfect bonus, share button ---------- */
.hud-progress { flex: 1; max-width: 260px; height: 12px; margin: 0 16px; border-radius: 99px; background: #e3e3e3; overflow: hidden; }
.hud-progress[hidden], .hud-lives[hidden] { display: none; }
.progress-fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #1a9e4b, #5cc98a); transition: width .6s ease; }
.hud-score { position: relative; }
.plus.gold { color: #d39e00; left: auto; right: 0; top: -6px; }
.stage-note.special { background: #f5c518; animation: noteIn .5s cubic-bezier(.3, 1.4, .5, 1), unlockGlow 1.2s ease 2; }
@keyframes unlockGlow { 50% { box-shadow: 0 0 0 8px rgba(245, 197, 24, .35); } }

/* "new in your album" – a little book that pops up on the card */
.game-cards li.new-in-album::after {
	content: "📖";
	position: absolute;
	right: -6px; top: -10px;
	z-index: 4;
	font-size: 1.2rem;
	animation: bookPop .9s cubic-bezier(.3, 1.6, .5, 1) both;
}
@keyframes bookPop { 0% { transform: scale(0) rotate(-30deg); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }

/* the gold stars for perfect levels in the points animation */
.tally li.star { display: flex; align-items: center; justify-content: center; height: 37px; background: #fff6d6; box-shadow: 0 2px 6px rgba(0, 0, 0, .12); }
.tally li.star b { color: #d39e00; font-size: 1.2rem; }
.tally li.star span { background: #d39e00; }
.album-line { font-weight: 600; color: var(--dark); }
.album-line[hidden] { display: none; }

.share-button {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 22px;
	border: 2px solid #25d366;
	border-radius: 99px;
	background: #fff;
	color: #128c4a;
	font-weight: 600;
	cursor: pointer;
	transition: background .2s ease, color .2s ease;
}
.share-button[hidden] { display: none; }
.share-button svg { width: 18px; height: 18px; fill: currentColor; }
.share-button:hover { background: #25d366; color: #fff; }
.share-note { color: #128c4a; font-weight: 600; }
.share-note[hidden] { display: none; }


/* ---------- 10. The flag album ---------- */
.album-total { color: var(--dark); font-weight: 600; margin: 0 0 8px; }
.album-bar { display: block; max-width: 420px; height: 12px; margin: 0 auto; border-radius: 99px; background: #e3e3e3; overflow: hidden; }
.album-fill { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #f5c518, #f4a261); }
.album-how { max-width: 560px; margin: 14px auto 6px; font-size: .85rem; }
.album-group { margin-top: 26px; text-align: left; }
.album-group h2 { display: flex; align-items: baseline; gap: 10px; border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.album-group h2 small { color: var(--text); font-weight: 400; font-size: .8rem; }
.album-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 12px; }
.album-list li { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; animation: riseIn .4s ease backwards; animation-delay: calc(var(--i) * 12ms); }
.album-list img, .album-list b { display: block; width: 100%; aspect-ratio: 134 / 92; height: auto; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); }
.album-list b { display: flex; align-items: center; justify-content: center; background: #eee; color: #c4c4c4; font-size: 1.4rem; box-shadow: inset 0 0 0 2px #e2e2e2; border-radius: 4px; }
.album-list span { font-size: .7rem; line-height: 1.3; color: var(--dark); }
.album-list li:not(.got) span { color: #bbb; }
#albumBack { margin-top: 24px; }

@media (max-width: 640px) {
	.modes { grid-template-columns: 1fr; gap: 12px; }
	.mode-button { padding: 14px 16px; }
	.hud-progress { margin: 0 10px; }
	.album-list { grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
}

/* ---------- 11. Beginner: streak dots, progress line, sound button, "×2" ---------- */
/* The progress line sits along the bottom edge of the score bar */
.hud { position: relative; overflow: hidden; }
.hud-progress { position: absolute; left: 0; right: 0; bottom: 0; flex: none; max-width: none; height: 5px; margin: 0; border-radius: 0; background: #e6e6e6; }

/* Three dots after the hearts: they fill up green as you get flags right in a row */
.streak { display: inline-flex; gap: 4px; margin-left: 8px; align-items: center; }
.streak i { width: 9px; height: 9px; border-radius: 50%; background: #ddd; transition: background .25s ease, transform .25s ease; }
.streak i.on { background: #1a9e4b; transform: scale(1.2); }

/* Sound on/off button, next to the language switch */
.sound-button { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: #fff; color: var(--dark); cursor: pointer; }
.sound-button + .lang { margin-left: 0; }
.sound-button svg { width: 20px; height: 20px; }
.sound-button .cross { display: none; }
.sound-button.off { color: #aaa; }
.sound-button.off .waves { display: none; }
.sound-button.off .cross { display: inline; }
.sound-button:hover { border-color: var(--primary); }
.sound-button:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* "×2" on a missed flag you got wrong more than once */
.missed-list li { position: relative; }
.missed-list em { position: absolute; top: -6px; left: -6px; padding: 0 6px; border-radius: 99px; background: var(--accent); color: #fff; font-style: normal; font-size: .7rem; font-weight: 700; line-height: 1.6; }

@media (max-width: 640px) {
	.top .home { font-size: 0; gap: 0; }   /* just the pineapple, to make room for the sound button */
	.streak { margin-left: 4px; gap: 3px; }
	.streak i { width: 7px; height: 7px; }
}

/* ---------- 12. Learn: mistakes counter and the practice button ---------- */
.miss-count { display: inline-block; padding: 2px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--dark); font-weight: 600; font-size: .85rem; }
.miss-count.bump { color: var(--accent); }
#practiceButton { background: #f5c518; color: var(--dark); box-shadow: 0 8px 20px rgba(245, 197, 24, .35); }
#practiceButton:hover { background: #e6b400; }
#practiceButton[hidden] { display: none; }
/* when the practice button is there, "Play again" steps back a little */
.big-button.quiet { background: #fff; color: var(--primary); border: 2px solid var(--primary); box-shadow: none; }
.big-button.quiet:hover { background: var(--primary); color: #fff; }

/* ---------- 13. The pack ladder (Learn and Beginner) ----------
   A numbered list of packs; finished ones show their medal, locked ones a padlock. */
.pack-list { list-style: none; padding: 0; margin: 0 auto 20px; max-width: 560px; display: flex; flex-direction: column; gap: 10px; text-align: left; counter-reset: none; }
.pack { display: flex; flex-direction: column; animation: riseIn .4s cubic-bezier(.3, 1.4, .5, 1) backwards; animation-delay: calc(var(--i) * 45ms); }
.pack-button {
	display: flex;
	align-items: center;
	gap: 14px;
	width: 100%;
	padding: 12px 16px;
	border: 2px solid var(--line);
	border-radius: 16px;
	background: #fff;
	font: inherit;
	text-align: left;
	cursor: pointer;
	transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.pack-button:hover { transform: translateX(4px); border-color: var(--primary); box-shadow: 0 8px 18px rgba(0, 136, 204, .15); }
.pack-button:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }
.pack-number { flex: none; display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 50%; background: var(--primary); color: #fff; font-weight: 700; }
.pack-text { flex: 1; display: flex; flex-direction: column; }
.pack-text strong { color: var(--dark); font-size: 1rem; }
.pack-text small { color: var(--text); font-size: .8rem; }
.pack-status { flex: none; font-size: 1.6rem; line-height: 1; }
.pack.has-medal .pack-number { background: #1a9e4b; }
.pack.has-medal .pack-status { animation: bookPop .6s cubic-bezier(.3, 1.6, .5, 1) backwards; animation-delay: calc(200ms + var(--i) * 45ms); }
.pack.locked .pack-button { background: var(--soft); border-style: dashed; cursor: not-allowed; }
.pack.locked .pack-button:hover { transform: none; border-color: #ccc; box-shadow: none; }
.pack.locked .pack-number { background: #bbb; }
.pack.locked .pack-text strong { color: #999; }
.pack.locked .pack-status { font-size: 1.1rem; }
/* the bonus pack: gold, so it is clearly an extra */
.pack.bonus .pack-button { border-color: #f5c518; background: #fffbea; }
.pack.bonus .pack-number { background: #f5c518; color: var(--dark); }
.pack.bonus.locked .pack-button { background: #fffbea; border-color: #f0dc8a; }
.pack .restart { align-self: flex-end; margin-top: 2px; }

.pack-ready { max-width: 520px; margin: 18px auto 6px; padding: 12px 16px; border-radius: 14px; background: #eef7fc; color: var(--dark); font-size: .9rem; }
.pack-ready[hidden] { display: none; }
.plain-button.link { color: var(--primary); font-weight: 600; padding: 4px 6px; }
#packBack { margin-top: 10px; }


/* ---------- 14. Medals, next pack, "Ready? Try Beginner" ---------- */
.medal { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 8px 0 4px; }
.medal[hidden] { display: none; }
.medal-icon { font-size: 4.2rem; line-height: 1; animation: medalIn 1s cubic-bezier(.3, 1.5, .5, 1) .3s backwards; filter: drop-shadow(0 6px 10px rgba(0, 0, 0, .2)); }
.medal-name { font-weight: 700; color: var(--dark); text-transform: uppercase; letter-spacing: .08em; font-size: .85rem; }
@keyframes medalIn { 0% { transform: translateY(-60px) rotate(-200deg) scale(.3); opacity: 0; } 70% { transform: translateY(4px) rotate(10deg) scale(1.1); opacity: 1; } }
.pack-unlocked { display: inline-block; margin: 6px 0; padding: 6px 16px; border-radius: 99px; background: #f5c518; color: var(--dark); font-weight: 700; animation: noteIn .5s cubic-bezier(.3, 1.4, .5, 1) 1s backwards; }
.pack-unlocked[hidden] { display: none; }
#nextPackButton { background: #1a9e4b; box-shadow: 0 8px 20px rgba(26, 158, 75, .3); }
#nextPackButton:hover { background: #158a40; }
#nextPackButton[hidden] { display: none; }


/* ---------- 15. Achievements ---------- */
.badges { margin: 28px auto 0; max-width: 720px; }
.badges h2 { font-size: .95rem; text-transform: uppercase; letter-spacing: .06em; }
.badges h2 small { color: var(--text); font-weight: 400; }
.badge-list { list-style: none; padding: 0; margin: 10px 0 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.badge-list li { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 6px; border-radius: 16px; background: var(--soft); text-align: center; animation: riseIn .4s ease backwards; animation-delay: calc(var(--i) * 60ms); }
.badge-icon { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 50%; background: #e4e4e4; font-size: 1.6rem; filter: grayscale(1); opacity: .45; }
.badge-list strong { color: #999; font-size: .78rem; line-height: 1.3; }
.badge-list small { color: #aaa; font-size: .68rem; line-height: 1.3; }
.badge-list li.got { background: #fffbea; }
.badge-list li.got .badge-icon { background: radial-gradient(circle at 35% 30%, #fff3b0, #f5c518); filter: none; opacity: 1; box-shadow: 0 4px 12px rgba(245, 197, 24, .45); }
.badge-list li.got strong { color: var(--dark); }
.badge-list li.got small { color: #1a9e4b; font-weight: 700; }

@media (max-width: 640px) {
	.badge-list { grid-template-columns: repeat(3, 1fr); }
	.pack-button { padding: 10px 12px; gap: 10px; }
	.pack-number { width: 32px; height: 32px; }
}

/* hidden achievement: a "?" until it is found */
.badge-list li.mystery .badge-icon { filter: none; opacity: .6; color: #777; font-weight: 700; font-size: 1.4rem; background: repeating-linear-gradient(45deg, #e9e9e9 0 6px, #e1e1e1 6px 12px); }


/* ---------- 16. The secret level ---------- */

/* The door: a dark layer, two door panels that slide apart, and the box behind them */
.secret-door { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(8, 12, 30, .88); overflow: hidden; }
.secret-door[hidden] { display: none; }
.door { position: absolute; top: 0; bottom: 0; width: 50%; background: linear-gradient(90deg, #2a2117, #4a3826 45%, #3a2c1e); box-shadow: inset 0 0 0 10px rgba(0, 0, 0, .25); z-index: 2; }
.door-left { left: 0; border-right: 3px solid #f5c518; }
.door-right { right: 0; border-left: 3px solid #f5c518; }
.door::after { content: ""; position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 50%; background: #f5c518; box-shadow: 0 0 12px #f5c518; }
.door-left::after { right: 22px; }
.door-right::after { left: 22px; }
.secret-door.open .door-left { animation: doorLeft 1.2s cubic-bezier(.6, 0, .3, 1) .5s forwards; }
.secret-door.open .door-right { animation: doorRight 1.2s cubic-bezier(.6, 0, .3, 1) .5s forwards; }
@keyframes doorLeft { to { transform: translateX(-102%); } }
@keyframes doorRight { to { transform: translateX(102%); } }

.secret-box { position: relative; z-index: 1; max-width: 440px; padding: 30px 26px 24px; border-radius: 22px; text-align: center; color: #f5e9c8;
	background: radial-gradient(circle at 50% 0%, #26345e, #121a36 70%); border: 2px solid #f5c518; box-shadow: 0 0 60px rgba(245, 197, 24, .35); }
.secret-box h2 { margin: 6px 0 10px; color: #f5c518; font-size: 1.5rem; text-transform: uppercase; letter-spacing: .04em; }
.secret-box p { margin: 0 0 20px; line-height: 1.6; }
.secret-key { font-size: 3.6rem; line-height: 1; filter: drop-shadow(0 0 14px rgba(245, 197, 24, .8)); }
.secret-door.open .secret-key { animation: keyIn 1.4s cubic-bezier(.3, 1.4, .5, 1) 1.2s backwards; }
@keyframes keyIn { 0% { transform: scale(0) rotate(-540deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.secret-buttons { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.big-button.gold { background: linear-gradient(180deg, #ffd84a, #f5b800); color: #1b1b1b; box-shadow: 0 8px 22px rgba(245, 197, 24, .45); }
.big-button.gold:hover { background: #ffe066; }
.plain-button.light { color: #c9bfa3; }
.plain-button.light:hover { color: #fff; }

/* Playing the secret level: night blue with gold cards */
#playScreen.secret { margin-top: 10px; padding: 18px 18px 22px; border-radius: 24px; background: radial-gradient(circle at 50% 0%, #26345e, #121a36 75%); box-shadow: 0 18px 40px rgba(18, 26, 54, .35); }
#playScreen.secret .hud { background: rgba(255, 255, 255, .06); border-color: rgba(245, 197, 24, .4); color: #f5e9c8; }
#playScreen.secret .hud small { color: #c9bfa3; }
#playScreen.secret .hint { color: #c9bfa3; }
#playScreen.secret .card-back { background: linear-gradient(150deg, #ffe27a 0%, #f5c518 55%, #d9a400 100%); color: #1b1b1b; }
#playScreen.secret .card-back .what { color: #5c4300; }
#playScreen.secret .stage-note { background: #f5c518; }
#playScreen.secret .heart { fill: #f5c518; }
#playScreen.secret .heart.empty { fill: rgba(255, 255, 255, .15); }
.flag-name { display: block; margin-top: 6px; color: #f5e9c8; font-weight: 600; font-size: .85rem; line-height: 1.3; text-align: center; }
.game-flags li.done .flag-name { opacity: .35; }
#endScreen.secret .final strong { color: #d9a400; }

/* the key on the pack ladder (play the secret level again) */
.pack.has-key { position: relative; }
.secret-key-button { position: absolute; right: 56px; top: 31px; transform: translateY(-50%); width: 38px; height: 38px; border: 2px solid #f5c518; border-radius: 50%; background: #121a36; font-size: 1.05rem; cursor: pointer; box-shadow: 0 0 12px rgba(245, 197, 24, .45); transition: transform .2s ease; }
.secret-key-button:hover { transform: translateY(-50%) scale(1.1) rotate(-15deg); }
.pack.has-key .pack-button { padding-right: 104px; }
.pack.has-key .restart { margin-top: 2px; }

@media (max-width: 640px) {
	#playScreen.secret { padding: 12px 10px 16px; margin-left: -6px; margin-right: -6px; }
	.flag-name { font-size: .72rem; }
	.secret-key-button { right: 50px; width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
	.door { display: none; }
}

/* ---------- 17. The game hall ---------- */
.hall { list-style: none; padding: 0; margin: 0 auto 36px; max-width: 720px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; text-align: left; }
.hall-card {
	display: flex;
	align-items: center;
	gap: 14px;
	height: 100%;
	padding: 16px 18px;
	border-radius: 18px;
	background: linear-gradient(135deg, #0088cc, #006da3);
	color: #fff;
	text-decoration: none;
	box-shadow: 0 10px 24px rgba(0, 136, 204, .28);
	transition: transform .25s ease, box-shadow .25s ease;
	animation: riseIn .5s cubic-bezier(.3, 1.4, .5, 1) backwards;
}
.hall li:nth-child(2) .hall-card { animation-delay: .08s; }
.hall-card.map { background: linear-gradient(135deg, #1a9e4b, #137a39); box-shadow: 0 10px 24px rgba(26, 158, 75, .28); }
.hall-card:hover { transform: translateY(-4px); box-shadow: 0 16px 30px rgba(0, 0, 0, .2); }
.hall-card:focus-visible { outline: 3px solid var(--dark); outline-offset: 3px; }
.hall-icon { flex: none; display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 14px; background: rgba(255, 255, 255, .18); font-size: 1.7rem; }
.hall-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.hall-text strong { font-size: 1.1rem; text-transform: uppercase; letter-spacing: .03em; }
.hall-text small { font-size: .8rem; line-height: 1.4; opacity: .9; }
.hall-go { flex: none; font-size: 1.4rem; font-weight: 700; }
.game-title { margin: 0 0 4px; color: var(--dark); font-size: 1.5rem; text-transform: uppercase; letter-spacing: .03em; scroll-margin-top: 20px; }
@media (max-width: 640px) {
	.hall { grid-template-columns: 1fr; margin-bottom: 28px; }
}

/* Less movement for people who ask for it in their device settings */
@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation: none !important; transition: none !important; }
}
