/* PortuQuest, in Algarve Offseason's colours and type (see public/assets/app.css, the
   tokens at the top and the SOFT THEME section). Keep the two in step.
     paper #F4F8F7 sea mist   ink #24383F deep sea slate   sea #2B8A87 sea glass
     sun #EE9F4F winter sun   fig #4F9A5C won / right      clay #D2665A lost / wrong */
@font-face {
  font-family: "Bricolage";
  src: url("fonts/bricolage.woff2") format("woff2");
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
}

:root {
  --ink:       #24383F;
  --sea:       #2B8A87;
  --sea-deep:  #1F6B69;
  --sea-light: #A8DCD6;
  --sea-wash:  #E3F2EF;
  --paper:     #F4F8F7;
  --card:      #FFFFFF;
  --line:      #DDE8E6;
  --line-warm: #CBDCD9;
  --muted:     #5F767C;
  --sun:       #EE9F4F;
  --sun-deep:  #A8621C;
  --sand:      #FBF0E1;
  --fig:       #4F9A5C;
  --fig-wash:  #E4F1E6;
  --clay:      #D2665A;
  --clay-wash: #F8E3E0;
  --gold:      #B9862C;
  --display: "Bricolage", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --gap: 1rem;
  --shell: 78rem;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(36, 56, 63, .06), 0 6px 18px rgba(36, 56, 63, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 1rem/1.6 var(--sans);
}
h1, h2, h3 { font-family: var(--display); font-weight: 650; font-stretch: 92%; line-height: 1.15; letter-spacing: -.01em; color: var(--ink); }
h1 { font-size: clamp(1.7rem, 4.5vw, 2.5rem); margin: .2em 0 .4em; }
h2 { font-size: 1.35rem; margin: 1.4em 0 .5em; }
h3 { font-size: 1.1rem; margin: .2em 0 .3em; }
a { color: var(--sea-deep); }
p { margin: .4em 0 .8em; }
:focus-visible { outline: 2px solid var(--sun); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--card); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* Algarve Offseason's header comes first (aos-masthead.css, generated); under it, the game's own menu */
.pq-nav { background: #fff; border-bottom: 1px solid var(--line); }
.pq-nav-in { max-width: 1080px; margin: 0 auto; display: flex; gap: 4px; flex-wrap: wrap; padding: 8px 16px; }
.pq-nav a { padding: .35rem .8rem; border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 550; font-size: .9rem; }
.pq-nav a:hover { background: rgba(43, 138, 135, .1); }
.pq-nav a[aria-current="page"] { background: var(--sea-wash); color: var(--sea-deep); }
.badge { display: inline-block; min-width: 1.3em; padding: 0 .35em; border-radius: 99px; background: var(--clay); color: #fff; font-size: .75rem; text-align: center; line-height: 1.4; margin-left: 3px; }
.tabbar { display: none; }
@media (max-width: 760px) {
  .pq-nav { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
    background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { text-align: center; padding: 7px 2px 6px; font-size: .72rem; color: var(--muted); text-decoration: none; }
  .tabbar a svg { display: block; margin: 0 auto 2px; }
  .tabbar a[aria-current="page"] { color: var(--sea); font-weight: 600; }
  body.has-tabs main { padding-bottom: 84px; }
}

main { max-width: 1080px; margin: 0 auto; padding: 18px 16px 48px; }
.narrow { max-width: 680px; margin-left: auto; margin-right: auto; }
.lede { font-size: 1.1rem; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.flash { background: var(--sand); border: 0; padding: 10px 14px; border-radius: 12px; margin-bottom: 14px; }
.notice-mock { background: var(--clay-wash); border: 2px dashed var(--clay); padding: 10px 14px; border-radius: 10px; }

/* Cards and grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.stack > * + * { margin-top: 10px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: .7rem 1.3rem; min-height: 44px;
  border-radius: 999px; border: 0; background: var(--sea); color: #fff; font: 650 1rem var(--sans);
  text-decoration: none; cursor: pointer; transition: transform .08s ease, background .15s ease;
}
.btn:hover { background: var(--sea-deep); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: #fff; color: var(--sea-deep); box-shadow: inset 0 0 0 1.5px var(--sea); }
.btn.secondary:hover { background: var(--sea-wash); }
.btn.terra { background: var(--clay); }
.btn.terra:hover { background: #B9534A; }
.btn.ochre { background: var(--sun); color: #fff; }
.btn.ochre:hover { background: #DE8A36; }
.btn.ghost { background: rgba(255, 255, 255, .7); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-warm); }
.btn.ghost:hover { background: #fff; }
.btn.small { padding: .35rem .9rem; min-height: 34px; font-size: .88rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; color: var(--sea-deep); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }
form.inline { display: inline; }

/* Next-action tiles on the dashboard */
.actions { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); margin: 14px 0 6px; }
.action {
  position: relative; display: block; padding: 16px 16px 14px; border-radius: var(--radius); text-decoration: none; color: var(--ink);
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow); border-left: 5px solid var(--sea);
}
.action:hover { transform: translateY(-1px); }
.action .k { font-size: .8rem; color: var(--sea-deep); font-weight: 650; }
.action .t { font-family: var(--display); font-size: 1.2rem; font-weight: 650; font-stretch: 92%; margin: 4px 0; display: block; }
.action .d { color: var(--muted); font-size: .93rem; }
.action.continue { border-left-color: var(--sea); }
.action.defend { border-left-color: var(--clay); }
.action.weak { border-left-color: var(--fig); }
.action.daily { border-left-color: var(--sun); }
.action.done { opacity: .75; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--display); font-size: 1.5rem; }
.stat span { color: var(--muted); font-size: .85rem; }
progress { width: 100%; height: 12px; border-radius: 99px; overflow: hidden; border: 0; background: var(--sea-wash); }
progress::-webkit-progress-bar { background: var(--sea-wash); border-radius: 99px; }
progress::-webkit-progress-value { background: var(--sea); border-radius: 99px; }
progress::-moz-progress-bar { background: var(--sea); border-radius: 99px; }

/* Map */
.map-wrap { position: relative; }
.map { width: 100%; max-width: 420px; height: auto; display: block; margin: 0 auto; }
.map .sea { fill: var(--sea-wash); }
.map .land { fill: var(--line-warm); stroke: var(--card); stroke-width: 2; }
.map .reg { stroke: var(--card); stroke-width: 1.6; transition: filter .15s; }
.map a:hover .reg, .map a:focus .reg { filter: brightness(1.08) saturate(1.2); }
.map .st-locked { fill: var(--line-warm); }
.map .st-open { fill: var(--sand); }
.map .st-siege { fill: var(--sun); }
.map .st-conquered { fill: var(--sea); }
.map .st-unrest { fill: var(--clay); }
.map .st-revolt { fill: var(--clay); }
.map .pin { fill: var(--card); stroke: var(--ink); stroke-width: 1.5; }
.map .flag { fill: var(--sun); stroke: var(--ink); stroke-width: .8; }
.map .lbl { font: 600 11px system-ui, sans-serif; fill: var(--ink); paint-order: stroke; stroke: var(--card); stroke-width: 3px; }
.map .st-conquered + .lbl, .map .on-dark { fill: #fff; stroke: var(--sea-deep); }
.map .unrest-ring { fill: none; stroke: var(--clay); stroke-width: 2.5; stroke-dasharray: 4 3; }
@media (prefers-reduced-motion: no-preference) {
  .map .unrest-ring { animation: spin 6s linear infinite; transform-box: fill-box; transform-origin: center; }
  @keyframes spin { to { transform: rotate(360deg); } }
}
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: .85rem; color: var(--muted); justify-content: center; margin-top: 8px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 4px; }
.legend .locked { background: var(--line-warm); } .legend .open { background: var(--sand); border: 1px solid var(--sun); }
.legend .siege { background: var(--sun); } .legend .conquered { background: var(--sea); } .legend .revolt { background: var(--clay); }
.conquest { text-align: center; }
.conquest .pct { font-family: var(--display); font-size: 2.6rem; font-weight: 800; color: var(--sea); line-height: 1; }

/* Territory list and lessons */
.tlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tlist li a, .lessonrow {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); text-decoration: none;
}
.dot { display: inline-block; width: 14px; height: 14px; border-radius: 50%; flex: none; background: var(--line-warm); vertical-align: -2px; }
.dot.open { background: var(--sand); border: 2px solid var(--sun); } .dot.siege { background: var(--sun); }
.dot.conquered, .dot.unrest { background: var(--sea); } .dot.revolt { background: var(--clay); }
.pill { display: inline-block; padding: 1px 9px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--sea-wash); color: var(--sea-deep); }
.pill.terra { background: var(--clay-wash); color: var(--clay); } .pill.ochre { background: var(--sand); color: var(--sun-deep); }
.pill.olive { background: var(--fig-wash); color: var(--fig); } .pill.stone { background: var(--line-warm); color: var(--ink); }
.lessonrow .num { font-family: var(--display); font-weight: 800; color: var(--sea); width: 2ch; text-align: right; }
.lessonrow .grow { flex: 1; min-width: 0; }
.locked-row { opacity: .6; }

/* Lesson intro */
.explain p { font-size: 1.04rem; }
.examples { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.examples li { padding: 8px 12px; border-left: 4px solid var(--sea); background: var(--sea-wash); border-radius: 0 10px 10px 0; }
.examples .pt { font-weight: 600; }
.vocab { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; margin: 0; }
.vocab div { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dotted var(--line); padding: 3px 0; }
.vocab dt { font-weight: 600; } .vocab dd { margin: 0; color: var(--muted); text-align: right; }
.say { border: 1px solid var(--line); background: var(--card); border-radius: 99px; width: 30px; height: 30px; cursor: pointer; color: var(--sea); vertical-align: middle; }

/* The exercise runner */
.play { max-width: 680px; margin: 0 auto; }
.play-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.play-head progress { flex: 1; }
.timer { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--clay); min-width: 4ch; text-align: right; }
.q { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px; box-shadow: var(--shadow); }
.q .kind { font-size: .82rem; color: var(--sea-deep); font-weight: 650; }
.q .prompt { font-size: 1.2rem; margin: 6px 0 14px; }
.q .passage, .q .sentence { background: var(--sand); border-radius: 10px; padding: 10px 14px; font-size: 1.08rem; margin-bottom: 12px; }
.q .sentence { text-decoration: underline wavy var(--clay); text-underline-offset: 4px; }
.dialogue { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.dialogue li { background: var(--sea-wash); border-radius: 12px 12px 12px 2px; padding: 8px 12px; max-width: 90%; }
.dialogue b { display: block; font-size: .8rem; color: var(--sea-deep); }
.opts { display: grid; gap: 8px; }
.opt {
  text-align: left; padding: 12px 14px; min-height: 48px; border-radius: 12px; border: 2px solid var(--line); background: var(--card);
  color: var(--ink); font: inherit; font-size: 1.03rem; cursor: pointer; display: flex; gap: 10px; align-items: center;
}
.opt .key { font-size: .75rem; border: 1px solid var(--line); border-radius: 6px; padding: 0 6px; color: var(--muted); }
.opt:hover { border-color: var(--sea); }
.opt[aria-pressed="true"] { border-color: var(--sea); background: var(--sea-wash); }
.opt.right { border-color: var(--fig); background: var(--fig-wash); }
.opt.wrong { border-color: var(--clay); background: var(--clay-wash); }
.answer-input { width: 100%; font: inherit; font-size: 1.15rem; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--line); background: var(--card); color: var(--ink); }
.answer-input:focus { border-color: var(--sea); outline: none; }
.accents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.accents button { min-width: 38px; min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.built { min-height: 54px; border: 2px dashed var(--line); border-radius: 12px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.bank { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--sea); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; min-height: 40px; }
.chip.used { visibility: hidden; }
.match { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.match .col { display: grid; gap: 8px; align-content: start; }
.match .opt { justify-content: center; text-align: center; font-size: .97rem; }
.match .paired { border-style: dashed; opacity: .9; }
.match .sel { border-color: var(--sun); background: var(--sand); }
.fb { margin-top: 14px; padding: 12px 14px; border-radius: 12px; }
.fb.ok { background: var(--fig-wash); border: 1px solid var(--fig); }
.fb.bad { background: var(--clay-wash); border: 1px solid var(--clay); }
.fb .title { font-weight: 700; }
.q-foot { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.listen-btn { font-size: 1.05rem; }
@media (prefers-reduced-motion: no-preference) {
  .q.enter { animation: rise .22s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
  .pop { animation: pop .3s ease-out; }
  @keyframes pop { 0% { transform: scale(.9); } 60% { transform: scale(1.05); } 100% { transform: none; } }
}

/* Results */
.score-big { font-family: var(--display); font-size: 3rem; font-weight: 800; color: var(--sea); line-height: 1; }
.victory { background: linear-gradient(160deg, var(--sea) 0%, var(--sea-deep) 100%); color: #fff; border-radius: 20px; padding: 22px; text-align: center; box-shadow: var(--shadow); }
.victory h2 { color: #fff; margin-top: 0; }
.reviewlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.reviewlist li { padding: 10px 12px; border-radius: 10px; background: var(--card); border: 1px solid var(--line); border-left: 6px solid var(--fig); }
.reviewlist li.no { border-left-color: var(--clay); }

/* Tables (league, rankings) */
table.rank { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 12px; overflow: hidden; }
.rank th, .rank td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.rank th { font-size: .85rem; font-weight: 600; color: var(--muted); }
.rank td.n { text-align: right; font-variant-numeric: tabular-nums; }
.rank tr.me td { background: var(--sea-wash); font-weight: 600; }
.rank tr.up td:first-child { box-shadow: inset 4px 0 0 var(--fig); }
.rank tr.down td:first-child { box-shadow: inset 4px 0 0 var(--clay); }

/* Feed */
.feed { list-style: none; padding: 0; margin: 0; }
.feed li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.feed time { color: var(--muted); font-size: .82rem; min-width: 7ch; }
.ach { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.ach div { padding: 10px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); }
.ach div.got { border-color: var(--sun); background: var(--sand); }
.ach div:not(.got) { opacity: .6; }

/* Forms */
label { font-weight: 600; display: block; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=search], input:not([type]), select {
  font: inherit; padding: .6rem .75rem; border-radius: 10px; border: 1px solid var(--line-warm); background: #fff; color: var(--ink); width: 100%; max-width: 420px;
}
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 12px 0; }
legend { font-weight: 700; padding: 0 6px; }
.radio { font-weight: 400; display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
.radio input { margin-top: 5px; }
.codebox { font-size: 1.6rem; letter-spacing: .3em; text-align: center; max-width: 220px; }

/* Talk */
.chat { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.chat li { padding: 9px 12px; border-radius: 14px; max-width: 85%; }
.chat .npc { background: var(--sea-wash); border-bottom-left-radius: 2px; }
.chat .me { background: var(--sand); margin-left: auto; border-bottom-right-radius: 2px; }
.chat .en { display: block; font-size: .85rem; color: var(--muted); }
.chat .tip { font-size: .85rem; color: var(--clay); display: block; }

/* Landing */
.hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 22px; align-items: center; padding: 18px 0 8px; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); }
.hero h1 em { color: var(--sea); font-style: normal; }
.points3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 18px 0; }
footer.foot { background: #fff; color: var(--muted); font-size: .85rem; margin-top: 24px; }
footer.foot .foot-in { max-width: 1080px; margin: 0 auto; padding: 18px 16px 90px; }
footer.foot a { color: var(--muted); }

/* Simpler home: one first step for new players, then next step, compete row, map */
.mt { margin-top: 14px; }
.btn.big { font-size: 1.08rem; padding: .85rem 1.6rem; }
.first-step { border-left: 5px solid var(--sea); padding: 20px 22px; margin: 10px 0 18px; }
.first-step .k { font-size: .82rem; color: var(--sea-deep); font-weight: 650; margin: 0; }
.first-step h2 { margin: .25em 0 .3em; }
.action.league { border-left-color: var(--gold); }
.action.duel { border-left-color: var(--clay); }
.compete { margin-bottom: 18px; }
.mini-rank { list-style: none; padding: 0; margin: 8px 0 14px; counter-reset: r; }
.mini-rank li { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); counter-increment: r; }
.mini-rank li span::before { content: counter(r) ". "; color: var(--muted); }
.mini-rank li.me { font-weight: 650; color: var(--sea-deep); }
.me-links { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 16px; }

.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.postcard { border-left: 5px solid var(--sun); background: #fffdf8; }
.postcard .k { font-size: .82rem; color: var(--sun-deep); font-weight: 650; margin: 0 0 4px; }
.pc-pt { font-size: 1.08rem; margin: .2em 0; }
.postcard details summary { cursor: pointer; color: var(--sea-deep); font-size: .9rem; }
.action .note i { color: var(--ink); }
.coach { border-left: 5px solid var(--sea); }
/* A little festa: paper streamers drift down behind the "feels like home" banner */
.victory { position: relative; overflow: hidden; }
.victory::before, .victory::after {
  content: ""; position: absolute; inset: -40px 0 auto 0; height: 200%; pointer-events: none; opacity: .85;
  background-image: radial-gradient(circle, #F2B567 3px, transparent 4px), radial-gradient(circle, #fff 2px, transparent 3px), radial-gradient(circle, #D9607C 2.5px, transparent 3.5px);
  background-size: 70px 60px, 50px 80px, 90px 70px; background-position: 0 0, 25px 30px, 45px 10px;
}
.victory::after { background-size: 110px 90px, 80px 70px, 60px 100px; opacity: .6; }
.victory > * { position: relative; }
@media (prefers-reduced-motion: no-preference) {
  .victory::before { animation: festa 6s linear infinite; }
  .victory::after { animation: festa 9s linear infinite; }
  @keyframes festa { from { transform: translateY(-50%); } to { transform: translateY(0); } }
}
