:root {
  --night: #0e1220; --panel: rgba(16, 20, 36, .93); --ivory: #f6ecd2; --gold: #d9b45a; --gold-hi: #fff0b8; --gold-lo: #9a7426; --red: #c8323f; --teal: #3fbfae;
  --font: "Avenir Next", Futura, "Trebuchet MS", sans-serif;
  --lux: "Cinzel", "Didot", "Bodoni 72", "Times New Roman", serif;
  --script: "Cormorant Garamond", "Didot", Georgia, serif;
  --goldfill: linear-gradient(180deg, #fff3c2 0%, #f1cf73 32%, #b98a2e 58%, #f6dd8e 78%, #a57a26 100%);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2f9fc4; font-family: var(--font); color: var(--ivory); }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; cursor: grab; touch-action: none; }
canvas.drag { cursor: grabbing; }
button { font: inherit; color: inherit; cursor: pointer; }

#top { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; pointer-events: none; }
#top > * { pointer-events: auto; }
.brand, .pill, #panel, #zoom button, #legend { background: var(--panel); border: 1px solid var(--gold-lo); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 8px 20px rgba(0,0,0,.35); }

/* Le logo : capitales gravées, or dégradé, filets fins */
.brand { display: flex; align-items: baseline; gap: 10px; padding: 6px 16px 5px; border-radius: 4px; border-color: var(--gold); outline: 1px solid var(--gold-lo); outline-offset: -4px; }
.brand b { font-family: var(--lux); font-weight: 700; font-size: 21px; letter-spacing: .34em; margin-right: -.34em; background: var(--goldfill); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand span { font-family: var(--script); font-style: italic; font-size: 16px; color: var(--ivory); opacity: .85; padding-left: 10px; border-left: 1px solid var(--gold-lo); }

.pill { border-radius: 4px; padding: 6px 12px; display: flex; gap: 8px; align-items: center; font-size: 13.5px; min-height: 38px; }
.date b { font-family: var(--lux); font-weight: 500; letter-spacing: .08em; font-size: 14px; color: var(--gold-hi); }
#clock { font-variant-numeric: tabular-nums; opacity: .75; min-width: 3.2em; } #sun { color: var(--gold); font-size: 17px; }
.speeds { padding: 4px; gap: 3px; }
.pill button { border: 0; background: transparent; border-radius: 3px; padding: 6px 10px; font-weight: 600; }
.pill button:hover { background: rgba(217,180,90,.18); }
.pill button.on { background: var(--goldfill); color: #1a1408; }
.money { flex-direction: column; align-items: flex-start; gap: 0; padding: 3px 12px; }
.money span { font-size: 9.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--gold); }
.money b { font-size: 15px; font-variant-numeric: tabular-nums; color: var(--gold-hi); }
em { font-style: normal; } .pos { color: #8fe3a0; } .neg, .money b.neg { color: #ff8f8f; }
#nmine { background: var(--goldfill); color: #1a1408; border-radius: 9px; padding: 0 6px; margin-left: 4px; font-size: 12px; }
#panel { max-height: calc(100vh - 110px); overflow-y: auto; }
#actions { margin-top: 10px; display: grid; gap: 7px; }
.act { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; border-radius: 3px; font-weight: 600; font-size: 13.5px; }
.act.buy { background: var(--goldfill); color: #1a1408; } .act.buy:hover { filter: brightness(1.08); }
.act.sell { background: transparent; border: 1px solid var(--gold-lo); color: var(--ivory); } .act.sell:hover { background: rgba(217,180,90,.14); }
.act:disabled { filter: grayscale(1); opacity: .45; cursor: not-allowed; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.seg button { border: 1px solid var(--gold-lo); background: transparent; border-radius: 3px; padding: 7px 4px; font-size: 13px; }
.seg button.on { background: var(--goldfill); color: #1a1408; font-weight: 700; }
#actions h3 { margin: 6px 0 0; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
#actions .note { margin: 0; }
#assets, #report { position: fixed; background: var(--panel); border: 1px solid var(--gold); outline: 1px solid var(--gold-lo); outline-offset: -5px; border-radius: 4px; padding: 14px 16px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
#assets { right: 60px; top: 112px; width: 320px; max-height: calc(100vh - 180px); overflow-y: auto; }
#report { left: 50%; top: 112px; transform: translateX(-50%); width: 340px; cursor: pointer; }
#assets h2, #report h2 { margin: 0 0 8px; font-family: var(--lux); font-size: 16px; letter-spacing: .08em; color: var(--gold-hi); }
#assets h3 { margin: 12px 0 2px; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); }
.asset { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 7px 4px; border-bottom: 1px solid rgba(217,180,90,.22); cursor: pointer; font-size: 13px; }
.asset:hover { background: rgba(217,180,90,.1); } .asset span { display: grid; } .asset i { font-style: normal; opacity: .6; font-size: 11.5px; }
#rank i { font-style: normal; font-weight: 400; font-size: 11.5px; opacity: .75; color: var(--ivory); } #rank sup { font-size: 9px; }
h2.foe { margin-top: 18px !important; }
.asset span i { display: block; }
#news { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); display: grid; gap: 6px; justify-items: center; pointer-events: none; }
#news button { pointer-events: auto; background: var(--panel); border: 1px solid #ff5d73; border-left-width: 4px; border-radius: 3px; padding: 8px 14px; font-size: 13px; box-shadow: 0 8px 20px rgba(0,0,0,.4); }
button.pill { cursor: pointer; color: inherit; font: inherit; text-align: left; } button.pill:hover { border-color: var(--gold); }
.act.loan { background: transparent; border: 1px solid var(--gold); color: var(--gold-hi); } .act.loan:hover { background: rgba(217,180,90,.14); }
.act.danger { background: transparent; border: 1px solid #a34a4a; color: #ff9f9f; } .act.danger:hover { background: rgba(255,90,90,.12); }
.builds { display: grid; gap: 4px; }
.builds button { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; text-align: left; padding: 7px 10px; border: 1px solid var(--gold-lo); background: transparent; border-radius: 3px; font-size: 13px; }
.builds button:hover:not(:disabled) { background: rgba(217,180,90,.14); } .builds button:disabled { opacity: .4; cursor: not-allowed; }
.builds i { font-style: normal; opacity: .6; font-size: 11.5px; } .builds b { color: var(--gold-hi); font-variant-numeric: tabular-nums; }
#bank { position: fixed; right: 60px; top: 112px; width: 330px; background: var(--panel); border: 1px solid var(--gold); outline: 1px solid var(--gold-lo); outline-offset: -5px; border-radius: 4px; padding: 14px 16px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
#bank h2 { margin: 0 0 8px; font-family: var(--lux); font-size: 16px; letter-spacing: .08em; color: var(--gold-hi); }
#over { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(6,8,16,.9); padding: 16px; } #over[hidden] { display: none; }
#over h1 { background: linear-gradient(180deg, #ffb0b0, #c8323f); -webkit-background-clip: text; background-clip: text; }
#again { background: var(--goldfill); color: #1a1408; border: 0; padding: 12px 26px; font-family: var(--lux); font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
#news button.bad { border-color: #ff3b3b; background: #3a0f14; color: #ffd0d0; font-weight: 600; }
#cycle { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 9px; } #cycle:empty { display: none; }
#cycle.bad { background: #5a1a22; color: #ffb3b3; } #cycle.good { background: #1f4a30; color: #b6f0c4; }
#news button.good { border-color: #6fe08a; }
.act i { font-style: normal; font-weight: 400; opacity: .7; font-size: 11.5px; margin-right: auto; padding-left: 6px; }
#login { display: grid; gap: 8px; max-width: 280px; margin: 0 auto 6px; } #login[hidden], #go[hidden] { display: none; }
#login input { background: #0b0e1a; border: 1px solid var(--gold-lo); color: var(--ivory); padding: 11px 12px; font: inherit; border-radius: 3px; }
#login input:focus { outline: 1px solid var(--gold); }
#login button { background: var(--goldfill); color: #1a1408; border: 0; padding: 12px; font-family: var(--lux); font-weight: 700; letter-spacing: .16em; text-transform: uppercase; font-size: 13px; }
#lerr { margin: 0; min-height: 1.2em; font-size: 12.5px; color: #ff9f9f; }
#who { margin: 0 0 8px; font-family: var(--script); font-style: italic; font-size: 18px; color: var(--gold-hi); } #who:empty { display: none; }
.linkbtn { background: none; border: 0; color: var(--ivory); opacity: .65; text-decoration: underline; font-size: 12px; padding: 0; }
.acct { width: 100%; border-collapse: collapse; margin: 10px 0 4px; font-size: 11.5px; font-variant-numeric: tabular-nums; table-layout: auto; }
.acct th { text-align: left; font-weight: 400; padding: 4px 0; } .acct td { text-align: right; padding: 4px 0 4px 6px; white-space: nowrap; }
.acct thead th { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.acct thead td { font-size: 9.5px; letter-spacing: .02em; text-transform: uppercase; opacity: .7; }
.acct tbody tr { border-top: 1px solid rgba(217,180,90,.18); } .acct i { font-style: normal; opacity: .55; }
.acct tr.sum th, .acct tr.sum td { opacity: .8; border-top: 1px solid rgba(217,180,90,.45); }
.acct tr.total th, .acct tr.total td { font-weight: 700; font-size: 12px; border-top: 1px solid var(--gold-lo); padding-top: 6px; }
.acct tr.cur th, .acct tr.cur td { color: var(--gold-hi); font-weight: 700; }
.builds .est { display: block; font-size: 11px; opacity: .8; margin-top: 1px; }
#panel { width: 390px; } #assets { width: 360px; }
.step { display: grid; grid-template-columns: 40px 1fr 40px; gap: 6px; align-items: center; }
.step button { border: 1px solid var(--gold-lo); background: transparent; border-radius: 3px; height: 38px; font-size: 20px; font-weight: 700; color: var(--gold-hi); }
.step button:hover:not(:disabled) { background: rgba(217,180,90,.14); } .step button:disabled { opacity: .3; cursor: not-allowed; }
.step span { display: grid; text-align: center; } .step i { font-style: normal; font-size: 11.5px; opacity: .7; }
.chart { width: 100%; height: auto; display: block; margin: 8px 0 2px; background: rgba(0,0,0,.22); border-radius: 3px; }
.chart .cur { fill: none; stroke-width: 2.2; stroke-linejoin: round; } .chart .prev { fill: none; stroke: #f6ecd2; stroke-opacity: .32; stroke-width: 1.2; stroke-dasharray: 3 3; }
.chart .zero { stroke: #d9b45a; stroke-opacity: .7; stroke-width: 1; stroke-dasharray: 2 3; }
.chart text { fill: #f6ecd2; font-size: 8.5px; opacity: .6; } .chart .tk { text-anchor: middle; } .chart .zl { text-anchor: end; fill: #d9b45a; opacity: .9; }
.kpi { margin: 10px 0 2px; font-size: 12.5px; } .kpibar { height: 8px; background: rgba(255,255,255,.1); border-radius: 4px; overflow: hidden; margin-bottom: 5px; }
.kpibar i { display: block; height: 100%; background: #ff8f8f; transition: width .3s; } .kpibar i.ok { background: #8fe3a0; }
.pl { display: inline-block; padding: 4px 8px; border-radius: 4px; font-size: 15px; font-weight: 800; letter-spacing: .01em; line-height: 1.1; }
.pl.pos { background: #1d6b3a; color: #d6ffe0; box-shadow: 0 0 0 1px #4fd07f inset; } .pl.neg { background: #8a1f2a; color: #ffe0e0; box-shadow: 0 0 0 1px #ff7a86 inset; }
.acct tr.total th { font-size: 13px; } .acct tr.total td { padding-top: 8px; padding-bottom: 6px; padding-left: 4px; }
.acct tr.total { background: rgba(217,180,90,.08); }
#fresh { background: none; border: 0; color: var(--ivory); opacity: .6; text-decoration: underline; font-size: 12px; margin-top: 4px; }
.sound { margin-left: auto; font-size: 12px; } #track { font-family: var(--script); font-style: italic; font-size: 15px; color: var(--gold-hi); }
.sound label { display: flex; align-items: center; gap: 5px; } .sound input { width: 70px; accent-color: var(--gold); }

#panel { position: fixed; left: 10px; bottom: 44px; width: 310px; border-radius: 4px; padding: 14px 16px 10px; outline: 1px solid var(--gold-lo); outline-offset: -5px; }
#panel h2 { margin: 0 26px 2px 0; font-family: var(--lux); font-weight: 700; font-size: 17px; line-height: 1.2; letter-spacing: .04em; color: var(--gold-hi); }
#panel .sub { margin: 0 0 10px; font-family: var(--script); font-style: italic; font-size: 16px; opacity: .9; }
#panel h3 { margin: 12px 0 2px; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
.row { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(217,180,90,.22); font-size: 13px; }
.row b { text-align: right; font-weight: 600; } .row i { font-weight: 400; opacity: .6; font-style: normal; }
.note { font-size: 11.5px; opacity: .6; margin: 10px 0 2px; line-height: 1.35; }
#close { position: absolute; top: 9px; right: 9px; width: 26px; height: 26px; border: 1px solid var(--gold-lo); border-radius: 50%; background: transparent; font-size: 16px; line-height: 1; }

#tip { position: fixed; background: var(--night); border: 1px solid var(--gold-lo); font-size: 12.5px; padding: 5px 9px; border-radius: 3px; pointer-events: none; max-width: 230px; }
#zoom { position: fixed; right: 10px; bottom: 44px; display: flex; flex-direction: column; gap: 6px; }
#zoom button { width: 40px; height: 40px; border-radius: 4px; font-size: 20px; color: var(--gold-hi); }
#zoom button:hover { background: #1c2340; }
#badge { position: fixed; left: 10px; bottom: 10px; background: rgba(14,18,32,.8); font-size: 12px; padding: 6px 10px; border-radius: 3px; opacity: .9; }
#legend { position: fixed; right: 60px; bottom: 50px; border-radius: 4px; padding: 6px 10px; font-size: 12px; display: flex; gap: 8px; align-items: center; }
#legend[hidden] { display: none; }
#legend i { width: 90px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, #f3e24a, #f08a24, #e2262f); }

#intro { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 40%, rgba(10,12,22,.55), rgba(6,8,16,.92)); transition: opacity .7s; padding: 16px; }
#intro.gone { opacity: 0; pointer-events: none; }
.card { background: linear-gradient(180deg, #151a2e, #0b0e1a); padding: 34px 44px 26px; max-width: 520px; text-align: center; border: 1px solid var(--gold); outline: 1px solid var(--gold-lo); outline-offset: -8px; box-shadow: 0 30px 80px rgba(0,0,0,.7); }
.kicker { margin: 0 0 14px; letter-spacing: .42em; text-transform: uppercase; font-size: 11px; color: var(--gold); }
.deco { display: flex; align-items: center; gap: 12px; justify-content: center; color: var(--gold); font-size: 9px; }
.deco i { height: 1px; width: 110px; background: linear-gradient(90deg, transparent, var(--gold)); } .deco i:last-child { transform: scaleX(-1); }
.card h1 { margin: 10px 0 0; font-family: var(--lux); font-weight: 700; font-size: clamp(44px, 11vw, 78px); letter-spacing: .3em; margin-right: -.3em; line-height: 1.05; background: var(--goldfill); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 0 rgba(0,0,0,.6)); }
.tag { margin: 0 0 12px; font-family: var(--script); font-style: italic; font-size: 28px; color: var(--ivory); letter-spacing: .04em; }
.txt { font-size: 14px; line-height: 1.5; margin: 18px 0 20px; opacity: .85; }
#go { background: var(--goldfill); color: #1a1408; border: 0; padding: 13px 30px; font-family: var(--lux); font-weight: 700; font-size: 14px; letter-spacing: .2em; text-transform: uppercase; box-shadow: 0 0 0 1px #000, 0 0 0 2px var(--gold-lo); }
#go:hover { filter: brightness(1.1); }
.keys { font-size: 11.5px; opacity: .55; margin: 16px 0 0; }

@media (max-width: 720px) { .sound { display: none; } #assets, #report { width: calc(100vw - 20px); left: 10px; right: 10px; transform: none; } #panel { width: calc(100vw - 20px); } .card { padding: 26px 22px 20px; } }
@media (prefers-reduced-motion: reduce) { #intro { transition: none; } }

/* Largeurs des panneaux : placées en fin de fichier pour l'emporter sur les réglages plus haut */
#panel { width: 410px; max-width: calc(100vw - 20px); }
#assets { width: 370px; max-width: calc(100vw - 20px); }
.acct tr.total td { padding-left: 3px; }
.pl { font-size: 14px; padding: 4px 6px; }

#restart.armed { background: #8a1f2a; color: #ffe0e0; }
.row .live { color: var(--gold-hi); font-size: 14.5px; font-variant-numeric: tabular-nums; }

/* Bourse */
#market { position: fixed; right: 60px; top: 112px; width: 400px; max-width: calc(100vw - 20px); max-height: calc(100vh - 180px); overflow-y: auto; background: var(--panel); border: 1px solid var(--gold); outline: 1px solid var(--gold-lo); outline-offset: -5px; border-radius: 4px; padding: 14px 16px 12px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
#market h2 { margin: 0 0 4px; font-family: var(--lux); font-size: 16px; letter-spacing: .08em; color: var(--gold-hi); }
.share { border-top: 1px solid rgba(217,180,90,.25); padding: 9px 0 8px; }
.sh-top { display: grid; grid-template-columns: 1fr 90px auto; gap: 10px; align-items: center; font-size: 13px; }
.sh-top span { display: grid; } .sh-top i { font-style: normal; font-size: 11px; opacity: .6; }
.sh-px { text-align: right; font-variant-numeric: tabular-nums; } .sh-px b { font-size: 15px; color: var(--gold-hi); } .sh-px em { font-size: 12px; font-weight: 700; }
.spark { width: 90px; height: 26px; }
.sh-own { margin: 5px 0 0; font-size: 11.5px; opacity: .85; }
.sh-btns { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.sh-btns button { border: 1px solid var(--gold-lo); background: transparent; border-radius: 3px; padding: 5px 9px; font-size: 12px; }
.sh-btns button:hover:not(:disabled) { background: rgba(217,180,90,.16); } .sh-btns button:disabled { opacity: .35; cursor: not-allowed; }
.sh-btns button.sell { border-color: #a34a4a; color: #ffb8b8; }
/* Choix de la difficulté */
#levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; max-width: 360px; margin: 0 auto 12px; } #levels[hidden] { display: none; }
#levels button { border: 1px solid var(--gold-lo); background: transparent; padding: 9px 4px; font-family: var(--lux); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
#levels button.on { background: var(--goldfill); color: #1a1408; font-weight: 700; }
#levels p { grid-column: 1 / -1; margin: 4px 0 0; font-size: 12px; opacity: .75; line-height: 1.4; }
.kpibar.gold i { background: linear-gradient(90deg, #b98a2e, #ffd24a); }

/* Croix de fermeture des panneaux */
#assets, #bank, #market { padding-top: 14px; }
.x { position: sticky; float: right; top: 0; width: 28px; height: 28px; margin: -4px -6px 0 8px; border: 1px solid var(--gold-lo); border-radius: 50%; background: var(--night); color: var(--ivory); font-size: 17px; line-height: 1; z-index: 2; }
.x:hover { border-color: var(--gold); color: var(--gold-hi); }

/* Sur ordinateur, les deux rangées de la barre du haut se comportent comme une seule */
.hrow { display: contents; }
body { touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }

/* ---------- Version téléphone ---------- */
@media (max-width: 760px), (max-height: 520px) {
  #top { top: calc(6px + env(safe-area-inset-top)); left: 6px; right: 6px; display: grid; gap: 5px; }
  .hrow { display: flex; gap: 5px; align-items: stretch; }
  /* rangée 1 : date et vitesse ; rangée 2 : tout le reste, qui défile du doigt */
  .hrow.r2 { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .hrow.r2::-webkit-scrollbar { display: none; }
  .hrow.r2 > * { flex: 0 0 auto; }
  .brand { display: none; }
  .pill { min-height: 36px; padding: 4px 9px; font-size: 12.5px; gap: 6px; }
  .pill.date { flex: 1 1 auto; min-width: 0; } .date b { font-size: 12.5px; white-space: nowrap; } #clock { min-width: 2.9em; }
  .speeds { padding: 3px; } .pill button { padding: 7px 9px; }
  .money { padding: 2px 9px; } .money span { font-size: 8.5px; letter-spacing: .1em; white-space: nowrap; } .money b { font-size: 13.5px; white-space: nowrap; }
  #rank i { display: none; }
  .sound { display: none; }
  /* fiches et panneaux : feuilles qui montent du bas de l'écran */
  #panel, #assets, #bank, #market { left: 0; right: 0; bottom: 0; top: auto; width: 100%; max-width: none; border-radius: 12px 12px 0 0; outline: none; padding: 12px 14px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px rgba(0,0,0,.55); }
  #panel { max-height: 54vh; } #assets, #bank, #market { max-height: 74vh; z-index: 3; }
  #panel h2 { font-size: 16px; } #close { width: 34px; height: 34px; top: 8px; right: 10px; }
  .x { width: 34px; height: 34px; font-size: 19px; }
  .act { padding: 12px; font-size: 14px; } .seg button, .step button { min-height: 42px; }
  .builds button { padding: 10px; } .sh-btns button { padding: 9px 11px; font-size: 13px; }
  #report { left: 6px; right: 6px; top: calc(96px + env(safe-area-inset-top)); width: auto; transform: none; }
  #news { left: 6px; right: 6px; bottom: auto; top: calc(96px + env(safe-area-inset-top)); transform: none; justify-items: stretch; }
  #news button { text-align: left; }
  #zoom { right: 6px; bottom: auto; top: calc(100px + env(safe-area-inset-top)); }
  #zoom button { width: 42px; height: 42px; }
  #badge, #tip, #legend { display: none; }
  .card { padding: 22px 18px 18px; } .tag { font-size: 22px; } .txt { font-size: 13.5px; margin: 12px 0 14px; }
  #login input, #login button { font-size: 16px; padding: 13px; } /* 16 px : évite le zoom automatique de l'iPhone */
  .keys { display: none; }
}

/* L'écran d'accueil défile s'il est plus haut que l'écran */
#intro { overflow-y: auto; align-items: start; } .card { margin: auto; }

/* ---------- Téléphone tenu à l'horizontale : fiches sur le côté plutôt qu'en bas ---------- */
@media (max-height: 520px) {
  #panel, #assets, #bank, #market { top: 0; bottom: 0; left: 0; right: auto; width: min(48vw, 400px); max-height: none; border-radius: 0 12px 12px 0; padding: calc(10px + env(safe-area-inset-top)) 12px 10px calc(12px + env(safe-area-inset-left)); z-index: 4; }
  #top { left: auto; right: 6px; width: min(50vw, 420px); }
  .hrow.r2 { flex-wrap: nowrap; }
  #zoom { top: auto; bottom: 8px; flex-direction: row; }
  #report, #news { left: auto; right: 6px; width: min(50vw, 420px); top: 96px; }
  .card { padding: 14px 18px 12px; max-width: 560px; } .card h1 { font-size: 40px; margin-top: 4px; } .tag { font-size: 18px; margin-bottom: 4px; }
  .kicker, .deco { display: none; } .txt { margin: 6px 0 10px; font-size: 12.5px; }
}

/* Banque : montants à toucher, et bouton bien visible dans la barre */
.bankpill { border-color: var(--gold) !important; } .bankpill span { color: var(--gold-hi) !important; }
.amounts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.amounts button { border: 0; border-radius: 3px; padding: 10px 4px; background: var(--goldfill); color: #1a1408; font-size: 11px; line-height: 1.25; }
.amounts button b { font-size: 14px; } .amounts button:hover { filter: brightness(1.08); }
.amounts button.back { background: transparent; border: 1px solid var(--gold-lo); color: var(--ivory); }
.builds h3 { margin: 8px 0 0; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); font-weight: 600; }
#bank h3 { margin: 10px 0 0; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 600; }

/* Banque : taux du jour et rachat de prêt */
.rate { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 2px 10px; padding: 9px 12px; margin: 4px 0 8px; border: 1px solid var(--gold); border-radius: 4px; background: rgba(217,180,90,.08); }
.rate span { font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--gold); }
.rate b { font-size: 24px; font-family: var(--lux); color: var(--gold-hi); text-align: right; } .rate i { grid-column: 1 / -1; font-style: normal; font-size: 11.5px; opacity: .7; }
.refi { border: 0; border-radius: 3px; padding: 6px 8px; background: var(--goldfill); color: #1a1408; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.refi:disabled { filter: grayscale(1); opacity: .45; }
.acct tr.hint td { text-align: left; white-space: normal; font-size: 11px; opacity: .75; padding: 0 0 6px; border: 0; } .acct tr.hint { border-top: 0 !important; }
.acct td.neg { color: #ff8f8f; font-weight: 700; }

/* Grandes annonces : la une du journal en plein écran */
#flash { position: fixed; inset: 0; z-index: 9; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 50% 40%, rgba(10,12,22,.6), rgba(6,8,16,.92)); animation: flashbg .35s ease-out; }
#flash[hidden] { display: none; }
.paper { width: min(560px, 100%); text-align: center; padding: 26px 30px 22px; background: linear-gradient(180deg, #151a2e, #0b0e1a); border: 1px solid var(--gold); outline: 1px solid var(--gold-lo); outline-offset: -8px; box-shadow: 0 30px 80px rgba(0,0,0,.75); animation: flashin .5s cubic-bezier(.2,1.4,.4,1); }
.paper .edition { margin: 0 0 12px; font-family: var(--script); font-style: italic; font-size: 15px; opacity: .75; border-bottom: 1px solid var(--gold-lo); padding-bottom: 8px; }
.paper .kick { display: inline-block; margin: 0 0 8px; padding: 4px 12px; font-size: 11px; font-weight: 700; letter-spacing: .26em; text-transform: uppercase; background: var(--goldfill); color: #1a1408; }
#flash.bad .kick { background: #b3202c; color: #fff; } #flash.good .kick { background: #1d6b3a; color: #d6ffe0; }
.paper h1 { margin: 4px 0 12px; font-family: var(--lux); font-weight: 900; font-size: clamp(28px, 8vw, 50px); line-height: 1.08; letter-spacing: .04em; background: var(--goldfill); -webkit-background-clip: text; background-clip: text; color: transparent; }
#flash.bad h1 { background: linear-gradient(180deg, #ffd0d0, #e0485a); -webkit-background-clip: text; background-clip: text; }
.paper .line { margin: 6px 0; font-size: 14.5px; line-height: 1.45; } .paper .line b { color: var(--gold-hi); }
#flashok { margin-top: 16px; background: var(--goldfill); color: #1a1408; border: 0; padding: 12px 28px; font-family: var(--lux); font-weight: 700; font-size: 13px; letter-spacing: .2em; text-transform: uppercase; }
@keyframes flashin { from { transform: scale(.7) rotate(-3deg); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes flashbg { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #flash, .paper { animation: none; } }

/* Trésorerie bien en vue */
.cashpill { background: var(--goldfill) !important; border-color: #fff0b8 !important; padding: 4px 16px !important; box-shadow: 0 0 0 1px #000, 0 0 18px rgba(255,210,74,.45), 0 8px 20px rgba(0,0,0,.35) !important; }
.cashpill span { color: #3a2a08 !important; font-weight: 700; } .cashpill b { color: #1a1408 !important; font-size: 21px !important; font-weight: 800; }
.cashpill b.neg { color: #8a1f2a !important; }
.filters { padding: 4px; gap: 3px; } .filters button.on { background: var(--goldfill); color: #1a1408; }
#wlegend { position: fixed; right: 60px; bottom: 50px; background: var(--panel); border: 1px solid var(--gold-lo); border-radius: 4px; padding: 6px 10px; font-size: 12px; display: flex; gap: 12px; }
#wlegend[hidden] { display: none; }
.seg.two { grid-template-columns: 1fr 1fr; } .seg button { display: flex; align-items: center; justify-content: center; gap: 6px; } .seg button:disabled:not(.on) { opacity: .4; }
.sw { width: 14px; height: 14px; border-radius: 3px; border: 2px solid; display: inline-block; }
blockquote { margin: 8px 0; padding: 7px 10px; border-left: 3px solid var(--gold); background: rgba(217,180,90,.07); font-family: var(--script); font-style: italic; font-size: 15.5px; line-height: 1.3; }
blockquote cite { display: block; margin-top: 3px; font-family: var(--font); font-style: normal; font-size: 11px; opacity: .65; }
@media (max-width: 760px), (max-height: 520px) { .cashpill b { font-size: 16px !important; } #wlegend { right: 6px; bottom: 8px; } }

/* Logements loués ou vacants : un carré par lot */
.units { display: inline-flex; flex-wrap: wrap; gap: 2px; vertical-align: middle; margin-left: 6px; max-width: 150px; justify-content: flex-end; }
.unit { width: 9px; height: 9px; border-radius: 2px; display: inline-block; opacity: 1 !important; }
.unit.in { background: #8fe3a0; } .unit.out { background: transparent; border: 1.5px solid #ff8f8f; }

/* La fiche s'arrête sous le bandeau du haut, quelle que soit sa hauteur */
@media (min-width: 761px) and (min-height: 521px) {
  #panel { max-height: calc(100vh - var(--toph, 70px) - 56px); }
  #assets, #bank, #market { top: calc(var(--toph, 104px) + 8px); max-height: calc(100vh - var(--toph, 104px) - 70px); }
}
/* Objectif de la partie */
.goalpill { position: relative; padding-bottom: 9px; } .goalpill b i { font-style: normal; font-weight: 400; opacity: .75; font-size: .85em; }
.goalbar { position: absolute; left: 8px; right: 8px; bottom: 4px; height: 3px; border-radius: 2px; background: rgba(255,255,255,.14); overflow: hidden; }
.goalbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold-lo), var(--gold-hi)); }
.goalline { font-size: .92em; opacity: .95; } .goalline b { color: var(--gold-hi); }
#over.win h1 { background: var(--goldfill); -webkit-background-clip: text; background-clip: text; }
#over .card button + button { margin-left: 10px; }
/* Rapport d'incidents : reste affiché tant que ce n'est pas réparé */
#incidents { position: fixed; right: 10px; top: calc(var(--toph, 104px) + 8px); width: 300px; max-width: calc(100vw - 20px); max-height: 46vh; overflow-y: auto; z-index: 2; background: #2a0d12; border: 1px solid #ff5d73; border-left-width: 4px; border-radius: 4px; box-shadow: 0 10px 26px rgba(0,0,0,.5); }
#incidents[hidden] { display: none; }
.inchead { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px; background: none; border: 0; color: #ffd0d0; text-align: left; cursor: pointer; }
.inchead b { font-family: var(--lux); letter-spacing: .06em; font-size: 13px; color: #ffb3b3; } .inchead span { flex: 1; text-align: right; font-size: 12px; opacity: .9; } .inchead i { font-style: normal; }
.inc { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid rgba(255,93,115,.35); cursor: pointer; }
.inc p { flex: 1; margin: 0; display: grid; gap: 1px; font-size: 12.5px; } .inc p b { color: var(--ivory); font-size: 13.5px; } .inc p span { opacity: .9; } .inc p .neg { color: #ff9c9c; }
.inc button, .fixall { background: var(--goldfill, #d9b24c); color: #1a1408; border: 0; border-radius: 3px; padding: 6px 9px; font-weight: 700; font-size: 12px; cursor: pointer; display: grid; text-align: center; }
.inc button:disabled, .fixall:disabled { opacity: .45; cursor: default; }
.fixall { display: flex; justify-content: space-between; width: calc(100% - 24px); margin: 8px 12px 10px; }
@media (max-width: 760px), (max-height: 520px) {
  #incidents { left: 6px; right: 6px; width: auto; top: calc(var(--toph, 96px) + 4px); max-height: 38vh; }
}

/* Écran de fin : au-dessus de tout, titre qui tient dans la carte, second bouton discret */
#over { z-index: 12; }
#over h1 { font-size: clamp(34px, 8vw, 58px); letter-spacing: .16em; margin-right: -.16em; }
#over .txt { margin: 14px 0 18px; }
#keep { background: none; border: 1px solid var(--gold-lo); color: var(--ivory); padding: 11px 20px; font-family: var(--lux); letter-spacing: .12em; text-transform: uppercase; font-size: 12px; margin-top: 10px; }
#keep[hidden] { display: none; }

/* Attractivité : détail des raisons sous la note */
.att { margin: 1px 0 1px 12px; font-size: 12.5px; opacity: .95; } .att b { display: inline-block; min-width: 34px; }
.att.pos b, .est.pos { color: #8fe3a0; } .att.neg b, .est.neg { color: #ff9c9c; }
/* Événements en cours, dans le même encadré que les incidents */
#incidents.calm { background: #131a30; border-color: var(--gold-lo); } #incidents.calm .inchead b { color: var(--gold-hi); } #incidents.calm .inchead { color: var(--ivory); }
.inc.ev p .pos { color: #8fe3a0; }
#wlegend span { white-space: nowrap; }

/* « À surveiller » : en bleu, pour ne pas le confondre avec une panne */
.inc.watch { background: rgba(60,130,200,.22); border-left: 5px solid #6cb6e6; } .inc.watch p b { color: #bfe3ff; }
.inc.watch button { background: none; border: 1px solid #6cb6e6; color: #bfe3ff; }

/* Petite croix sur les notifications, le bilan et les grandes annonces */
#news button { position: relative; padding-right: 34px; }
.tx { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 22px; height: 22px; line-height: 20px; text-align: center; border: 1px solid rgba(255,255,255,.35); border-radius: 50%; font-size: 15px; opacity: .85; }
.tx:hover { opacity: 1; background: rgba(255,255,255,.15); }
#report, #flash .paper { position: fixed; } #flash .paper { position: relative; }
#report .x, #flash .x { position: absolute; top: 8px; right: 8px; float: none; margin: 0; }
#report h2 { margin-right: 34px; }
/* Nouveaux commerces de l'époque : en gras, avec une étiquette */
.builds button.fresh { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--gold-hi); }
.newname { font-weight: 900; color: var(--gold-hi); font-size: 1.05em; }
.newtag { font-style: normal; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; background: var(--gold-hi); color: #1a1408; border-radius: 2px; padding: 1px 5px; margin-left: 4px; font-weight: 700; }

/* Bourse : avantage d'actionnaire */
.sh-perk { margin: 2px 0 4px; font-size: 12px; opacity: .85; } .sh-perk.on { color: var(--gold-hi); opacity: 1; font-weight: 600; }
/* Besoin de trésorerie de fin de saison */
.duepill b i { font-style: normal; font-weight: 400; font-size: .8em; opacity: .8; } .duepill b i.neg { color: #ff9c9c; opacity: 1; font-weight: 700; }
.duepill.short { border-color: #ff5d73; box-shadow: 0 0 0 1px #ff5d73; }

/* Téléphone, tenu droit : incidents, notifications et bilan ne se recouvrent plus et laissent les boutons de zoom libres */
@media (max-width: 760px) and (min-height: 521px) {
  #incidents { right: 58px; }
  #news { top: calc(var(--toph, 96px) + 60px); left: 6px; right: 58px; }
  #news button:nth-last-child(n+3) { display: none; } /* deux notifications à la fois, les plus récentes */
  #report { top: 34vh; }
  .duepill span { max-width: 130px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
/* Téléphone couché : tout ce qui s'affiche en haut se range à droite, la fiche garde la gauche */
@media (max-height: 520px) {
  #incidents { left: auto; right: 58px; width: min(46vw, 380px); top: calc(var(--toph, 96px) + 4px); max-height: 50vh; }
  #news { top: calc(var(--toph, 96px) + 60px); right: 58px; }
  #news button:nth-last-child(n+2) { display: none; }
  #report { top: auto; bottom: 8px; }
}
@media (max-height: 520px) {
  #report { bottom: 52px; } /* au-dessus des boutons de zoom */
  body:has(#report:not([hidden])) #news { display: none; } /* pas assez de hauteur pour le bilan et les notifications à la fois */
}

/* Événements : bouton « voir sur la carte », et le même dans les grandes annonces */
.inc.ev .see { background: none; border: 1px solid var(--gold-lo, #b08d3c); color: var(--gold-hi, #f0d58a); white-space: nowrap; }
.inc.ev .see b { font-weight: 400; font-size: 10.5px; opacity: .85; }
.inc.ev .see:hover { background: rgba(240,213,138,.14); }
.flashbtns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
#flashsee { margin-top: 16px; background: none; color: inherit; border: 2px solid currentColor; padding: 10px 22px; font-family: var(--lux); font-weight: 700; font-size: 13px; letter-spacing: .14em; text-transform: uppercase; cursor: pointer; }

/* Cycle de vie d'un commerce : étiquette dans la liste de construction (symbole + texte, lisible sans la couleur) */
.lifetag { font-style: normal; font-size: 10.5px; font-weight: 700; padding: 1px 5px; border-radius: 3px; border: 1px solid currentColor; white-space: nowrap; }
.lifetag.pos { color: #8fe3a0; } .lifetag.neg { color: #ffb38a; }

/* Mise en demeure : bandeau qui reste affiché toute la saison */
#demeure { position: fixed; left: 50%; bottom: 44px; transform: translateX(-50%); z-index: 6; max-width: min(92vw, 720px); background: #7a0f18; color: #fff; border: 2px solid #ffb3b3; border-radius: 4px; padding: 9px 16px; font-weight: 700; font-size: 13.5px; text-align: center; box-shadow: 0 4px 18px rgba(0,0,0,.5); }
#demeure[hidden] { display: none; } #demeure.ok { background: #14432a; border-color: #8fe3a0; }

/* Journal des notifications et compte à rebours du prélèvement */
#journal { position: fixed; left: 10px; top: calc(var(--toph, 104px) + 8px); width: 360px; max-width: calc(100vw - 20px); max-height: 60vh; overflow-y: auto; z-index: 3; background: var(--panel); border: 1px solid var(--gold); border-radius: 4px; padding: 12px 12px 10px; box-shadow: 0 10px 30px rgba(0,0,0,.45); }
#journal[hidden] { display: none; }
#journal h2 { margin: 0 0 8px; font-family: var(--lux); font-size: 16px; letter-spacing: .08em; color: var(--gold-hi); }
#journal .jr { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; width: 100%; text-align: left; background: rgba(255,255,255,.04); border: 1px solid rgba(255,255,255,.12); border-left: 4px solid #ff5d73; border-radius: 3px; padding: 7px 9px; margin: 0 0 5px; font-size: 13px; color: var(--ivory); cursor: pointer; }
#journal .jr[data-none] { cursor: default; }
#journal .jr i { grid-column: 1 / -1; font-style: normal; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; opacity: .7; }
#journal .jr em { font-style: normal; font-size: 11px; color: var(--gold-hi); align-self: center; white-space: nowrap; }
#journal .jr.bad { border-left-color: #ff3b3b; background: #3a0f14; color: #ffd0d0; font-weight: 600; }
#journal .jr.good { border-left-color: #6fe08a; }
#journal .none { font-size: 13px; opacity: .7; margin: 4px 0; }
#logbtn.fresh b { background: #ffd24a; color: #1a1408; border-radius: 9px; padding: 0 6px; }
#duewhen { display: block; font-style: normal; font-size: 10.5px; opacity: .85; white-space: nowrap; }
#duewhen.soon { color: #ffd24a; opacity: 1; font-weight: 700; }
#journal .jx { position: sticky; float: right; top: 0; width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--gold); background: var(--panel); color: var(--ivory); font-size: 18px; line-height: 1; cursor: pointer; }
@media (max-width: 700px) { #journal { left: 6px; right: 6px; width: auto; max-width: none; z-index: 6; } }

/* Un panneau ouvert (biens, banque, bourse) cache le rapport d'événements, qui revient à la fermeture : plus de chevauchement */
body:has(#assets:not([hidden])) #incidents, body:has(#bank:not([hidden])) #incidents, body:has(#market:not([hidden])) #incidents { display: none; }
@media (max-width: 700px) { body:has(#journal:not([hidden])) #incidents { display: none; } }

/* Banque et bourse : le contenu défile dans la fenêtre au lieu d'en déborder */
#bank, #market { overflow-y: auto; overscroll-behavior: contain; }
@media (min-width: 761px) and (min-height: 521px) { #bank, #market { max-height: calc(100vh - var(--toph, 104px) - 24px); } }
