/* ЩАСТЯ НА 360° — стилі. Палітра взята з фізичного поля гри. */
:root {
  --bg: #120c26;
  --bg-2: #1b1338;
  --card: #221a42;
  --card-2: #2a2153;
  --line: rgba(167, 139, 250, .18);
  --text: #f3efff;
  --muted: #a79ecf;
  --violet: #a78bfa;

  /* кольори типів карток = діаманти на полі */
  --c-opportunity: #d6409f;
  --c-expense: #e8961e;
  --c-resource: #3fb96a;
  --c-event: #7c5cff;
  --c-mak: #f26bd4;
  --c-cash: #3ed3e0;
  --c-start: #ffffff;
  --c-dream: #f0c24b;
  --c-fm: #ff5470;
  --c-income: #8fd14f;

  --r: 16px;
  --shadow: 0 10px 40px rgba(0,0,0,.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ''; position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 55% 45% at 12% 8%, rgba(214,64,159,.14), transparent 65%),
    radial-gradient(ellipse 50% 45% at 88% 90%, rgba(62,211,224,.10), transparent 65%),
    radial-gradient(ellipse 45% 40% at 80% 15%, rgba(124,92,255,.14), transparent 60%);
}
.screen { display: none; position: relative; z-index: 1; }
.screen.active { display: block; }
.hidden { display: none !important; }

/* ── кнопки ── */
.btn {
  font-family: 'Manrope', sans-serif; font-weight: 700; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card-2); color: var(--text);
  padding: .7rem 1.1rem; cursor: pointer; transition: transform .12s, filter .12s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .4; cursor: not-allowed; filter: none; }
.btn:focus-visible { outline: 2px solid var(--c-cash); outline-offset: 2px; }
.btn-primary { background: linear-gradient(135deg, #a78bfa, #7c5cff); border: none; color: #fff; box-shadow: 0 6px 24px rgba(124,92,255,.4); }
.btn-cyan { background: linear-gradient(135deg, #3ed3e0, #2ba8c9); border: none; color: #06212a; }
.btn-danger { background: rgba(255,84,112,.15); border-color: rgba(255,84,112,.45); color: #ff8ba0; }
.btn-ghost { background: transparent; }
.btn-big { font-size: 1.1rem; padding: 1rem 1.6rem; }
.btn-small { font-size: .85rem; padding: .5rem .9rem; }
.btn-tiny { font-size: .78rem; padding: .38rem .7rem; border-radius: 9px; }
.btn-dice { font-family: 'Unbounded', sans-serif; font-size: 1.05rem; width: 100%;
  background: linear-gradient(135deg, #f0c24b, #e8961e); border: none; color: #2a1a00; padding: .95rem; }

/* ── головна ── */
.home-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.4rem; padding: 2rem 1.4rem; text-align: center; }
.home-hex {
  width: 110px; height: 110px;
  background: conic-gradient(from 0deg, var(--c-opportunity), var(--c-expense), var(--c-resource), var(--c-cash), var(--c-event), var(--c-mak), var(--c-opportunity));
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  filter: drop-shadow(0 0 32px rgba(167,139,250,.55));
  animation: hexspin 24s linear infinite;
}
@keyframes hexspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .home-hex { animation: none; } }
.home-title { font-family: 'Unbounded', sans-serif; font-weight: 900; font-size: clamp(2.4rem, 8vw, 4rem); line-height: 1.04; letter-spacing: .02em; }
.home-title .deg { background: linear-gradient(90deg, #f26bd4, #3ed3e0); -webkit-background-clip: text; background-clip: text; color: transparent; }
.home-sub { color: var(--muted); font-size: .95rem; }
.home-actions { display: flex; flex-direction: column; gap: .8rem; width: min(340px, 100%); }
.home-form { display: flex; flex-direction: column; gap: .7rem; width: min(340px, 100%); }
.home-form input, .cash-row input, .modal input, .modal textarea, .modal select {
  font-family: 'Manrope', sans-serif; font-size: 1rem; color: var(--text);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .75rem .9rem; width: 100%;
}
.home-form input:focus, .modal input:focus, .modal textarea:focus { outline: 2px solid var(--violet); }
.form-error { color: #ff8ba0; font-size: .85rem; min-height: 1.1em; }

/* ── топбар ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .65rem 1rem; background: rgba(18,12,38,.9); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.room-code { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: .85rem; letter-spacing: .06em; color: var(--c-cash); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; font-size: .95rem; color: var(--c-dream); }
.turn-pill { font-size: .82rem; font-weight: 700; padding: .35rem .8rem; border-radius: 99px; background: var(--card-2); border: 1px solid var(--line); }
.turn-pill.my-turn { background: linear-gradient(135deg, #f0c24b, #e8961e); color: #2a1a00; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(240,194,75,.15); } }

/* ── розкладка гравця ── */
.player-layout { display: grid; gap: .9rem; padding: .9rem; max-width: 1400px; margin: 0 auto;
  grid-template-columns: 1fr; }
@media (min-width: 900px) {
  .player-layout { grid-template-columns: minmax(340px, 420px) 1fr minmax(260px, 320px); grid-template-rows: auto auto; }
  .board-card { grid-column: 1; grid-row: 1 / 3; }
  .action-panel { grid-column: 2; grid-row: 1; }
  .fin-panel { grid-column: 2; grid-row: 2; }
  .side-panel { grid-column: 3; grid-row: 1 / 3; }
}
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 1rem; box-shadow: var(--shadow); }

/* ── поле ── */
.board-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .8rem; box-shadow: var(--shadow); }
.board-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.board-title { font-family: 'Unbounded', sans-serif; font-size: .8rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.board-svg-wrap svg { width: 100%; height: auto; display: block; }
.bcell { cursor: pointer; transition: filter .15s; }
.bcell:hover { filter: brightness(1.35); }
.bcell.here { filter: drop-shadow(0 0 6px #fff); }
.cell-info { min-height: 2.2em; font-size: .82rem; color: var(--muted); padding: .4rem .2rem 0; text-align: center; }
.cell-info b { color: var(--text); }

/* ── дії ── */
.dice-zone { display: flex; flex-direction: column; gap: .5rem; }
.dice-result { min-height: 1.4em; text-align: center; font-weight: 800; font-size: 1rem; color: var(--c-dream); }
.draw-zone { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; min-height: 2.4em; }
.draw-zone .btn { flex: 1 1 40%; }
.draw-hint { width: 100%; text-align: center; color: var(--muted); font-size: .82rem; align-self: center; }
.cash-zone { border-top: 1px dashed var(--line); padding-top: .8rem; display: flex; flex-direction: column; gap: .5rem; }
.cash-row { display: flex; gap: .5rem; }
.cash-row .btn { white-space: nowrap; }
.cash-row input[type=number] { max-width: 130px; }

/* кольори кнопок колод */
.btn-deck-opportunity { background: var(--c-opportunity); border: none; color: #fff; }
.btn-deck-expense { background: var(--c-expense); border: none; color: #2a1a00; }
.btn-deck-resource { background: var(--c-resource); border: none; color: #06210f; }
.btn-deck-event { background: var(--c-event); border: none; color: #fff; }
.btn-deck-mak { background: var(--c-mak); border: none; color: #3a0a2e; }

/* ── фінанси ── */
.fin-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: .8rem; }
.fin-name { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1.05rem; }
.fin-prof { color: var(--muted); font-size: .85rem; }
.fin-balance { text-align: right; }
.fin-balance .lbl { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.fin-balance .val { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1.3rem; color: var(--c-cash); }
.fin-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .7rem; }
.fin-cell { background: var(--bg-2); border-radius: 10px; padding: .5rem .6rem; }
.fin-cell .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.fin-cell .v { font-weight: 800; font-size: .95rem; font-variant-numeric: tabular-nums; }
.fin-cell.hl .v { color: var(--c-income); }
.dream-line { font-size: .85rem; color: var(--muted); background: var(--bg-2); border-radius: 10px; padding: .55rem .7rem; margin-bottom: .8rem; }
.dream-line b { color: var(--c-dream); }

.tabs { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .7rem; }
.tab { font-size: .78rem; font-weight: 700; padding: .38rem .7rem; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
.tab.active { background: var(--violet); border-color: var(--violet); color: #16102e; }
.tab-body { max-height: 340px; overflow-y: auto; }

/* гаманець */
.wallet-add { display: flex; gap: .4rem; margin-bottom: .6rem; }
.wallet-add input { background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); padding: .45rem .6rem; font-size: .85rem; }
.wallet-add input:first-child { max-width: 100px; }
.wallet-add input:nth-child(2) { flex: 1; }
.ledger { width: 100%; border-collapse: collapse; font-size: .84rem; }
.ledger td { padding: .35rem .3rem; border-bottom: 1px solid var(--line); }
.ledger .amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger .amt.pos { color: var(--c-income); }
.ledger .amt.neg { color: #ff8ba0; }
.ledger .bal { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* активи */
.asset { display: flex; justify-content: space-between; gap: .6rem; align-items: center; padding: .5rem .2rem; border-bottom: 1px solid var(--line); font-size: .86rem; }
.asset .a-title { flex: 1; }
.asset .a-meta { color: var(--muted); font-size: .76rem; }
.asset .a-pd { color: var(--c-income); font-weight: 700; white-space: nowrap; }

/* МАК / інсайти / історія */
.mak-item { background: var(--bg-2); border-left: 3px solid var(--c-mak); border-radius: 8px; padding: .55rem .7rem; margin-bottom: .5rem; font-size: .86rem; }
.mak-item .sphere { color: var(--c-mak); font-weight: 700; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; }
.mak-img { width: 100%; max-width: 220px; border-radius: 10px; display: block; margin-bottom: .4rem; }
.mak-img-big { max-width: 100%; }
.insight-add { display: flex; gap: .4rem; margin-bottom: .6rem; }
.insight-add input { flex: 1; background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); padding: .45rem .6rem; font-size: .85rem; }
.hist-item { display: flex; gap: .5rem; align-items: baseline; padding: .35rem .2rem; border-bottom: 1px solid var(--line); font-size: .84rem; }
.hist-item .dot { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; transform: rotate(45deg); }
.hist-item .kept { margin-left: auto; font-size: .74rem; color: var(--muted); white-space: nowrap; }

/* індекси */
.indices-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.index-cell { background: var(--bg-2); border-radius: 10px; padding: .5rem .6rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.index-cell .k { font-size: .78rem; }
.index-ctrl { display: flex; align-items: center; gap: .4rem; }
.index-ctrl button { width: 26px; height: 26px; border-radius: 8px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); font-weight: 800; cursor: pointer; }
.index-ctrl .iv { font-weight: 800; min-width: 1.4em; text-align: center; }

/* ── гравці/стрічка ── */
.side-title { font-family: 'Unbounded', sans-serif; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: .2rem 0 .55rem; }
.players-list { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1rem; }
.pl-row { display: flex; align-items: center; gap: .55rem; font-size: .86rem; padding: .4rem .5rem; border-radius: 10px; background: var(--bg-2); }
.pl-row .dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.pl-row .nm { font-weight: 700; }
.pl-row .st { margin-left: auto; color: var(--muted); font-size: .74rem; white-space: nowrap; }
.pl-row.turn { outline: 1px solid var(--c-dream); }
.pl-row.off { opacity: .5; }
.feed { display: flex; flex-direction: column; gap: .35rem; max-height: 300px; overflow-y: auto; font-size: .82rem; }
.feed-tall { max-height: 420px; }
.feed .f-item { padding: .4rem .55rem; background: var(--bg-2); border-radius: 9px; line-height: 1.35; }
.feed .f-item.card { border-left: 3px solid var(--c-mak); }
.feed .f-item.cash { border-left: 3px solid var(--c-cash); }
.feed .f-item.big { border-left: 3px solid var(--c-dream); }
.feed .f-item.announce { border-left: 3px solid var(--c-event); background: rgba(124,92,255,.12); }

/* ── ведучий ── */
.host-layout { display: grid; gap: .9rem; padding: .9rem; grid-template-columns: 1fr; max-width: 1700px; margin: 0 auto; }
@media (min-width: 1050px) { .host-layout { grid-template-columns: 1fr minmax(320px, 420px); } }
.host-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .8rem; }
.invite-box { display: flex; align-items: center; gap: .5rem; font-size: .82rem; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .45rem .7rem; flex-wrap: wrap; }
.invite-box code { color: var(--c-cash); font-size: .8rem; word-break: break-all; }
.cash-requests { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .8rem; }
.cash-req { display: flex; align-items: center; gap: .7rem; background: rgba(62,211,224,.09); border: 1px solid rgba(62,211,224,.35); border-radius: 12px; padding: .6rem .8rem; font-size: .9rem; flex-wrap: wrap; }
.cash-req .amt { font-family: 'Unbounded', sans-serif; font-weight: 700; color: var(--c-cash); }
.cash-req .note { color: var(--muted); font-size: .82rem; }
.cash-req .actions { margin-left: auto; display: flex; gap: .4rem; }

.host-players { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.hp-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; box-shadow: var(--shadow); }
.hp-card.turn { outline: 2px solid var(--c-dream); }
.hp-head { display: flex; align-items: center; gap: .55rem; margin-bottom: .55rem; }
.hp-head .dot { width: 14px; height: 14px; border-radius: 50%; }
.hp-head .nm { font-weight: 800; font-size: 1rem; }
.hp-head .prof { color: var(--muted); font-size: .8rem; }
.hp-head .off-dot { color: #ff8ba0; font-size: .7rem; margin-left: .2rem; }
.hp-head .badges { margin-left: auto; display: flex; gap: .3rem; font-size: .9rem; }
.hp-fin { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-bottom: .55rem; }
.hp-fin .fin-cell { padding: .4rem .5rem; }
.hp-dream { font-size: .8rem; color: var(--muted); margin-bottom: .5rem; }
.hp-dream b { color: var(--c-dream); }
.hp-pos { font-size: .78rem; color: var(--muted); margin-bottom: .55rem; }
.hp-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.last-card { font-size: .86rem; line-height: 1.4; }
.last-card .lc-deck { font-weight: 800; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; }

/* ── модалки та тост картки ── */
.modal-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6,3,18,.75); backdrop-filter: blur(4px); }
.modal { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 20px; padding: 1.3rem; width: min(560px, 100%); max-height: 88vh; overflow-y: auto; box-shadow: 0 24px 80px rgba(0,0,0,.6); }
.modal h3 { font-family: 'Unbounded', sans-serif; font-size: 1.05rem; margin-bottom: .8rem; }
.modal .m-row { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .7rem; }
.modal label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.modal .m-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.modal .m-actions .btn { flex: 1; }
.modal .m-close { position: absolute; top: .8rem; right: .9rem; background: none; border: none; color: var(--muted); font-size: 1.3rem; cursor: pointer; }
.chip-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chip { font-size: .8rem; font-weight: 600; padding: .4rem .75rem; border-radius: 99px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--violet); }
.chip.active { background: var(--violet); border-color: var(--violet); color: #16102e; }

/* картка на всю ширину модалки */
.gamecard { border-radius: 16px; padding: 1.1rem; margin: .3rem 0 .6rem; color: #fff; }
.gamecard .gc-deck { font-family: 'Unbounded', sans-serif; font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.gamecard .gc-title { font-family: 'Unbounded', sans-serif; font-weight: 700; font-size: 1.15rem; margin: .35rem 0 .55rem; line-height: 1.25; }
.gamecard .gc-text { font-size: .92rem; line-height: 1.5; white-space: pre-line; opacity: .95; }
.gamecard .gc-nums { display: flex; flex-wrap: wrap; gap: .8rem; margin-top: .7rem; font-size: .86rem; }
.gamecard .gc-nums span b { display: block; font-size: 1rem; }
.gc-opportunity { background: linear-gradient(140deg, #d6409f, #8e2a6a); }
.gc-expense { background: linear-gradient(140deg, #e8961e, #a35f06); color: #fff; }
.gc-resource { background: linear-gradient(140deg, #3fb96a, #1f7a42); }
.gc-event { background: linear-gradient(140deg, #7c5cff, #4b2fb8); }
.gc-mak { background: linear-gradient(140deg, #f26bd4, #a4308a); }
.gc-profession { background: linear-gradient(140deg, #3ed3e0, #1f7f9e); color: #06212a; }
.gc-dream { background: linear-gradient(140deg, #f0c24b, #b57f12); color: #2a1a00; }

.card-toast { position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 90;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 14px; padding: .7rem 1rem;
  font-size: .88rem; box-shadow: var(--shadow); max-width: min(480px, 92vw); cursor: pointer; }
.card-toast b { color: var(--c-mak); }

/* фото поля */
.field-photo { width: 100%; border-radius: 12px; }

/* скролбари */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--card-2); border-radius: 99px; }

@media (max-width: 600px) {
  .fin-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar { padding: .55rem .7rem; }
  .tab-body { max-height: 280px; }
}
