:root {
  --sea-0: #0a1822;
  --sea-1: #10293a;
  --sea-2: #173a50;
  --line: #28506b;
  --parchment: #f1e4c3;
  --parchment-dim: #c9b98f;
  --brass: #d6a84a;
  --brass-dark: #a97f26;
  --danger: #e0705a;
  --ok: #7cc48a;
  --radius: 10px;
  --serif: "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--parchment);
  background:
    radial-gradient(1200px 600px at 80% -10%, #1d4a63 0%, transparent 60%),
    linear-gradient(180deg, var(--sea-1), var(--sea-0));
  min-height: 100vh;
}

h1, h2 { font-family: var(--serif); margin: 0; letter-spacing: .02em; }
h2 { font-size: 1.15rem; color: var(--brass); margin-bottom: .7rem; }

#game { max-width: 1040px; margin: 0 auto; padding: 1rem 1rem 3rem; }

.card {
  background: rgba(16, 41, 58, .85);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
}

/* Connexion */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.auth-card { width: min(560px, 100%); padding: 1.6rem; }
.auth-card h1 { font-size: 1.9rem; color: var(--brass); }
.tagline { color: var(--parchment-dim); margin: .4rem 0 1.4rem; }
form label { display: block; font-size: .85rem; color: var(--parchment-dim); margin-bottom: .9rem; }
input {
  display: block; width: 100%; margin-top: .3rem; padding: .6rem .7rem;
  background: var(--sea-0); color: var(--parchment); border: 1px solid var(--line);
  border-radius: 8px; font: inherit;
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; }
.hint { font-size: .78rem; color: var(--parchment-dim); margin: .9rem 0 0; }

button {
  font: inherit; cursor: pointer; padding: .55rem .95rem; border-radius: 8px;
  color: var(--parchment); background: var(--sea-2); border: 1px solid var(--line);
}
button:hover:not(:disabled) { border-color: var(--brass); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--brass); color: #1a1405; border-color: var(--brass-dark); font-weight: 600; }
button.link { background: none; border: none; color: var(--parchment-dim); text-decoration: underline; padding: 0; }

.error { color: var(--danger); min-height: 1.2em; margin: .2rem 0; font-size: .9rem; }
.error.banner:empty { display: none; }

/* En-tête */
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; padding: .5rem 0 1rem; flex-wrap: wrap; }
.topbar h1 { font-size: 1.7rem; }
.meta { margin: .2rem 0 0; color: var(--parchment-dim); font-size: .9rem; }
.who { display: flex; align-items: center; gap: .7rem; font-size: .9rem; }
.badge { padding: .15rem .55rem; border-radius: 999px; border: 1px solid var(--ok); color: var(--ok); font-size: .75rem; }
.badge:empty { display: none; }

/* Ressources */
.resources { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.res { padding: .75rem .9rem; }
.res .name { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--parchment-dim); }
.res .amount { font-family: var(--serif); font-size: 1.6rem; margin: .1rem 0; font-variant-numeric: tabular-nums; }
.res .rate { font-size: .8rem; color: var(--parchment-dim); }
.res .bar { height: 5px; border-radius: 3px; background: var(--sea-0); margin-top: .45rem; overflow: hidden; }
.res .bar > i { display: block; height: 100%; background: var(--brass); }
.res.full .bar > i { background: var(--danger); }
.res.full .rate { color: var(--danger); }

/* Construction en cours */
.construction { margin-bottom: 1rem; border-color: var(--brass-dark); }
.construction .line { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.progress { height: 8px; border-radius: 4px; background: var(--sea-0); margin-top: .6rem; overflow: hidden; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brass-dark), var(--brass)); }

/* Bâtiments */
.buildings { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .8rem; }
.building { display: flex; flex-direction: column; gap: .5rem; }
.building header { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; }
.building h3 { margin: 0; font-family: var(--serif); font-size: 1.1rem; }
.lvl { color: var(--brass); font-variant-numeric: tabular-nums; white-space: nowrap; }
.building p { margin: 0; font-size: .88rem; color: var(--parchment-dim); }
.cost { display: flex; flex-wrap: wrap; gap: .3rem .8rem; font-size: .85rem; font-variant-numeric: tabular-nums; }
.cost .short { color: var(--danger); }
.building footer { display: flex; justify-content: space-between; align-items: center; margin-top: auto; gap: .6rem; font-size: .85rem; color: var(--parchment-dim); }

/* Richesses */
.traits { margin-top: 1.2rem; }
.trait-list { display: flex; flex-wrap: wrap; gap: .6rem 1.4rem; font-size: .92rem; }
.trait-list b { font-variant-numeric: tabular-nums; }

@media (max-width: 520px) {
  .topbar h1 { font-size: 1.35rem; }
  .res .amount { font-size: 1.3rem; }
}

/* Classes */
fieldset.classes { border: 0; padding: 0; margin: 0 0 .6rem; min-width: 0; }
fieldset.classes legend { font-size: .85rem; color: var(--parchment-dim); padding: 0; margin-bottom: .5rem; }
fieldset.classes legend small { font-size: .75rem; }
.class-choices { display: grid; gap: .6rem; }
.class-choice { display: block; cursor: pointer; margin: 0; color: var(--parchment); font-size: .9rem; }
.class-choice input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.class-choice .box { display: block; padding: .7rem .85rem; border: 1px solid var(--line); border-radius: 8px; background: var(--sea-0); }
.class-choice:hover .box { border-color: var(--parchment-dim); }
.class-choice input:checked + .box { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
.class-choice input:focus-visible + .box { outline: 2px solid var(--brass); outline-offset: 2px; }
.class-choice strong { font-family: var(--serif); font-size: 1.05rem; color: var(--brass); }
.class-choice .tag { display: block; color: var(--parchment-dim); font-size: .85rem; margin: .1rem 0 .4rem; }
.perks { margin: .2rem 0 0; padding-left: 1.1rem; font-size: .85rem; }
.perks li { margin: .1rem 0; }
.perks .soon { color: var(--parchment-dim); }
.perks .soon::after { content: " (à venir)"; font-size: .75rem; opacity: .8; }
.ship-line { margin: .5rem 0 0; font-size: .85rem; color: var(--parchment-dim); }
.ship-line b { color: var(--parchment); }

.class-panel { margin-top: 1.2rem; }
.class-panel .tag { margin: 0 0 .5rem; color: var(--parchment-dim); }
@media (min-width: 560px) { .class-panel .cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; } }

/* Chantier naval */
#yard-info { margin: -.3rem 0 .8rem; }
.ships { margin-top: .6rem; }
.ship.locked { opacity: .55; }
.ship.unique { border-color: var(--brass-dark); }
.ship h3 { display: flex; align-items: center; flex-wrap: wrap; gap: .2rem .5rem; }
.ship .badge { border-color: var(--brass); color: var(--brass); font-family: var(--sans); font-size: .68rem; white-space: nowrap; letter-spacing: 0; }
#yard > h2 { margin-top: 1.5rem; }
.ship .stats { display: flex; flex-wrap: wrap; gap: .15rem .9rem; font-size: .82rem; color: var(--parchment-dim); font-variant-numeric: tabular-nums; }
.ship .stats b { color: var(--parchment); font-weight: 600; }
.ship .buy { display: flex; align-items: center; gap: .5rem; }
.ship .buy input { width: 5.2rem; margin: 0; padding: .4rem .5rem; }
.ship .need { font-size: .82rem; color: var(--brass); }
.ship-queue { margin-bottom: .8rem; display: grid; gap: .8rem; }
.ship-queue .line { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .92rem; }
.ship-queue .sub { color: var(--parchment-dim); font-size: .82rem; }

/* Onglets */
.tabs { display: flex; gap: .5rem; margin: .4rem 0 1rem; }
.tab[aria-pressed="true"] { background: var(--brass); color: #1a1405; border-color: var(--brass-dark); font-weight: 600; }

/* Carte */
.ocean { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; max-width: 520px; margin: .6rem 0 1rem; }
.arch { text-align: left; padding: .5rem .6rem; line-height: 1.25; }
.arch small { display: block; color: var(--parchment-dim); font-size: .74rem; font-weight: 400; }
.arch[aria-pressed="true"] { border-color: var(--brass); box-shadow: inset 0 0 0 1px var(--brass); }
.arch .home { color: var(--brass); font-size: .72rem; }

.map-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 520px) 1fr; align-items: start; }
@media (max-width: 760px) { .map-layout { grid-template-columns: 1fr; } }

.grid-map { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; padding: 6px;
  background: #0b2433; border: 1px solid var(--line); border-radius: var(--radius); }
.grid-map .cell { aspect-ratio: 1; border-radius: 6px; border: 0; padding: 0; position: relative; background: rgba(23, 58, 80, .5); }
.grid-map button.cell { cursor: pointer; }
.grid-map button.cell::after { content: ""; position: absolute; inset: 24%; border-radius: 50%; background: #c9b98f; }
.grid-map button.cell.mine::after { background: var(--brass); box-shadow: 0 0 0 3px rgba(214, 168, 74, .35); }
.grid-map button.cell.other::after { background: var(--danger); }
.grid-map button.cell.strategic::after { inset: 14%; border-radius: 3px; transform: rotate(45deg); background: #7ec8e3; box-shadow: 0 0 0 2px rgba(126, 200, 227, .4); }
.grid-map button.cell.selected { outline: 2px solid var(--parchment); outline-offset: 1px; }
.grid-map button.cell:hover { background: rgba(40, 80, 107, .8); }

.legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin: .6rem 0 0; font-size: .8rem; color: var(--parchment-dim); }
.dot { display: inline-block; width: .7rem; height: .7rem; border-radius: 50%; background: #c9b98f; margin-right: .35rem; vertical-align: -1px; }
.dot.mine { background: var(--brass); }
.dot.other { background: var(--danger); }
.dot.strategic { background: #7ec8e3; border-radius: 2px; transform: rotate(45deg); }
.strategic-box h4 { margin: .6rem 0 .2rem; }
.strategic-box .status { font-size: .85rem; color: var(--parchment-dim); }

.island-info h3 { font-family: var(--serif); font-size: 1.2rem; margin: 0 0 .2rem; color: var(--brass); }
.island-info p { margin: .3rem 0; font-size: .92rem; }
.island-info .muted { color: var(--parchment-dim); font-size: .85rem; }
.island-info ul { margin: .4rem 0 0; padding-left: 1.1rem; font-size: .9rem; }
.island-info .badge { margin-left: .3rem; }

/* Missions, flottes, rapports */
.island-select { margin-top: .5rem; max-width: 100%; padding: .35rem .5rem; background: var(--sea-0); color: var(--parchment);
  border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: .88rem; }
.tab .count { background: var(--danger); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; margin-left: .4rem; font-weight: 600; }

.fleets { display: grid; gap: .6rem; margin-bottom: 1.2rem; }
.fleet .line { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: .92rem; }
.fleet .sub { color: var(--parchment-dim); font-size: .82rem; margin-top: .15rem; }

.send { margin-top: .9rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.send h4 { margin: 0 0 .5rem; font-family: var(--serif); color: var(--brass); font-size: 1rem; }
.ship-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin: 0 0 .4rem; font-size: .88rem; color: var(--parchment); }
.ship-row input { width: 5rem; margin: 0; padding: .35rem .5rem; }
.preview { min-height: 2.6em; margin: .6rem 0; font-size: .85rem; color: var(--parchment-dim); }
.preview .bad { color: var(--danger); display: block; margin-top: .2rem; }
.preview b { color: var(--parchment); font-variant-numeric: tabular-nums; }

.reports { display: grid; gap: .7rem; }
.report summary { cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; align-items: baseline; }
.report summary strong { font-family: var(--serif); font-size: 1.05rem; }
.report summary .when { color: var(--parchment-dim); font-size: .8rem; }
.report .body { margin-top: .7rem; display: grid; gap: .5rem; font-size: .9rem; }
.report .body h4 { margin: .3rem 0 .1rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--parchment-dim); font-weight: 600; }
.report .body ul { margin: 0; padding-left: 1.1rem; }
.report .body p { margin: 0; }
.report .new { color: var(--danger); border-color: var(--danger); }
.report.ok { border-color: var(--ok); }
.report.fail { border-color: var(--danger); }

.expedition { margin-bottom: 1.4rem; }
.expedition h3 { margin: 0 0 .4rem; font-family: var(--serif); }

.mission-switch { display: flex; gap: .4rem; margin: 0 0 .6rem; }
.mission-switch button { padding: .35rem .8rem; }
.preview .warn { color: var(--danger); }

.table-wrap { overflow-x: auto; }
.ranking { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ranking th, .ranking td { padding: .45rem .7rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ranking th { color: var(--parchment-dim); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.ranking .num { text-align: right; font-variant-numeric: tabular-nums; }
.ranking th.cat { text-align: right; }
.ranking tr.me td { background: rgba(212, 169, 74, .12); color: var(--parchment); }

.offer-form { margin-bottom: 1rem; }
.offer-form h3 { margin: 0 0 .6rem; font-family: var(--serif); }
.offer-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .8rem; }
.offer-row label { display: grid; gap: .3rem; font-size: .85rem; color: var(--parchment-dim); }
.pair { display: flex; gap: .4rem; }
.pair input { width: 7rem; margin: 0; }
.pair select { flex: 1; padding: .4rem; background: var(--sea-0); color: var(--parchment); border: 1px solid var(--line); border-radius: 8px; font: inherit; }
.preview .bad { display: block; }
.building.locked { opacity: .55; }

/* Factions */
#faction-root > .card, #faction-root > section.card { margin-bottom: .9rem; }
.faction-head { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .8rem; }
.faction-head h2 { margin: 0; }
.faction-head .meta { flex-basis: 100%; margin: 0; }
.faction-form { display: grid; gap: .6rem; max-width: 28rem; margin-bottom: 1rem; }
.faction-form label, .offer-form label.check { display: grid; gap: .25rem; font-size: .85rem; color: var(--parchment-dim); }
.offer-form label.check { display: flex; align-items: center; gap: .5rem; margin: .5rem 0 0; }
.offer-form label.check input { width: auto; margin: 0; }
.frow { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem .8rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.frow.war { color: var(--danger); }
.actions { display: inline-flex; flex-wrap: wrap; gap: .4rem; }
.actions button, .frow button { padding: .3rem .6rem; font-size: .8rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0 .3rem; align-items: center; }
.inline-form input[type=text], .inline-form select { flex: 1 1 12rem; margin: 0; }
.inline-form input[type=number] { width: 7rem; margin: 0; }
button.danger { border-color: var(--danger); color: var(--danger); }
.treasury { font-variant-numeric: tabular-nums; font-weight: 600; margin: .2rem 0; }
.perk { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .5rem 0; border-top: 1px solid var(--line); }
.perk p { margin: .15rem 0 0; }
.chat { max-height: 16rem; overflow-y: auto; padding: .4rem .2rem; font-size: .88rem; }
.chat p { margin: .2rem 0; }
.chat b { color: var(--brass); }
.inline-form select { padding: .5rem .6rem; background: var(--sea-0); color: var(--parchment); border: 1px solid var(--line); border-radius: 8px; font: inherit; }

/* Messagerie privée */
.messages-layout { display: grid; grid-template-columns: minmax(12rem, 18rem) 1fr; gap: 1rem; align-items: start; }
@media (max-width: 700px) { .messages-layout { grid-template-columns: 1fr; } }
.conversations { display: flex; flex-direction: column; gap: .3rem; margin-top: .6rem; }
.conv { text-align: left; display: flex; flex-direction: column; gap: .1rem; }
.conv.active { border-color: var(--brass); }
.conv small { color: var(--muted, #9a8f7d); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.conv .count { background: var(--danger); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; font-weight: 600; }
.thread .chat { max-height: 26rem; min-height: 10rem; }
.thread .chat p.mine b { color: var(--ok); }

/* --- Logo, bêta fermée et CGU ------------------------------------------------------------------------ */
.brand { display: flex; align-items: center; gap: .9rem; }
.game-logo { width: 76px; height: 76px; flex: none; border-radius: 50%; box-shadow: 0 0 18px rgba(214, 168, 74, .25); }
.auth-logo { display: block; width: 140px; height: 140px; margin: .2rem auto 1.1rem; border-radius: 50%;
  box-shadow: 0 0 26px rgba(214, 168, 74, .3); }
.beta-flag { display: inline-block; margin: 0 0 .7rem; padding: .15rem .65rem; border: 1px solid var(--brass);
  border-radius: 999px; color: var(--brass); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; }
.beta-badge { border-color: var(--brass); color: var(--brass); }
.link-small { color: var(--parchment-dim); font-size: .85rem; align-self: center; }
label.check { display: flex; align-items: flex-start; gap: .5rem; color: var(--parchment); font-size: .9rem; margin: .9rem 0; }
label.check input { width: auto; margin: .15rem 0 0; }

.cgu-gate { width: min(760px, 100%); }
.cgu-scroll { max-height: 52vh; overflow-y: auto; padding: .2rem 1rem .6rem; background: var(--sea-0);
  border: 1px solid var(--line); border-radius: 8px; font-size: .9rem; line-height: 1.5; }
.cgu-scroll h1 { font-size: 1.25rem; color: var(--brass); margin: .8rem 0 .4rem; }
.cgu-scroll h2, .cgu h2 { font-size: 1rem; margin: 1.1rem 0 .35rem; }
.cgu-scroll p, .cgu p { margin: .35rem 0; color: var(--parchment); }
.cgu-scroll a, .cgu a { color: var(--brass); }
.cgu-id { display: grid; grid-template-columns: max-content 1fr; gap: .2rem .8rem; margin: .4rem 0 .6rem; font-size: .88rem; }
.cgu-id dt { color: var(--parchment-dim); }
.cgu-id dd { margin: 0; }
.cgu-dialog { width: min(780px, 94vw); padding: 1rem; color: var(--parchment); background: var(--sea-1);
  border: 1px solid var(--line); border-radius: var(--radius); }
.cgu-dialog::backdrop { background: rgba(4, 10, 15, .7); }
.cgu-dialog .cgu-scroll { max-height: 70vh; margin-bottom: .8rem; }
.cgu-dialog form { justify-content: flex-end; }
.cgu-page { padding: 1.5rem 1rem; }
.cgu-page .cgu { max-width: 820px; margin: 0 auto; line-height: 1.55; }
.cgu-page .cgu h1 { color: var(--brass); font-size: 1.6rem; margin-bottom: .6rem; }
.cgu-back { max-width: 820px; margin: 1rem auto; }
.cgu-back a { color: var(--brass); }
.site-footer { text-align: center; color: var(--parchment-dim); font-size: .8rem; padding: 1rem 1rem 2rem; }

/* --- Files d'attente (constructions et recherches) ------------------------------------------------------- */
.queue-box { display: grid; gap: .55rem; }
.queue-head { display: flex; justify-content: space-between; align-items: baseline; font-family: var(--serif); color: var(--brass); }
.queue-item { display: grid; gap: .25rem; }
.queue-item.waiting { padding-top: .5rem; border-top: 1px dashed var(--line); color: var(--parchment-dim); font-size: .9rem; }
.queue-item .progress { margin-top: .2rem; }
.queue-item button.link { justify-self: end; font-size: .8rem; }

@media (max-width: 520px) {
  .game-logo { width: 54px; height: 54px; }
}
