/* =========================================================
   Page « Parties » — game database, viewer, engine
   ========================================================= */

/* ============ Hero ============ */
.phero { position: relative; padding: clamp(64px, 12vh, 140px) var(--gutter) clamp(56px, 9vh, 110px); text-align: center; overflow: hidden; }
.phero__copy { position: relative; z-index: 2; max-width: 900px; margin: 0 auto; }
.phero__glyphs span { position: absolute; font-family: var(--font-glyph); color: var(--color-studio-mist); font-size: clamp(90px, 14vw, 220px); line-height: 1; user-select: none; will-change: transform; }
.phero__glyphs span:nth-child(1) { left: 4%; top: 8%; color: #e9eef6; }
.phero__glyphs span:nth-child(2) { right: 6%; top: 4%; }
.phero__glyphs span:nth-child(3) { left: 14%; bottom: -6%; }
.phero__glyphs span:nth-child(4) { right: 16%; bottom: -10%; color: #e9eef6; }
.phero__glyphs span:nth-child(5) { left: 42%; top: -14%; font-size: clamp(60px, 8vw, 120px); }
.phero__glyphs span:nth-child(6) { right: 36%; bottom: -24%; font-size: clamp(60px, 8vw, 120px); }
.phero__stats { display: flex; justify-content: center; gap: clamp(28px, 6vw, 80px); margin-top: 36px; }
.phero__stats div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.phero__stats b { font-size: clamp(28px, 3.6vw, 44px); font-weight: 500; }
.phero__stats span { font-size: 14px; color: var(--color-slate); }

/* ============ App grid ============ */
.gdb { background: var(--color-studio-mist); padding: 40px var(--gutter) 90px; display: grid; grid-template-columns: 300px minmax(320px, 1fr) 340px; gap: 20px; align-items: start; scroll-margin-top: 44px; }
.gdb > * { min-width: 0; }

/* list */
.gdb__list { background: #fff; border-radius: var(--radius-cards); padding: 18px; position: sticky; top: 64px; display: flex; flex-direction: column; max-height: calc(100vh - 84px); }
.gfilters { display: flex; flex-direction: column; gap: 8px; padding-bottom: 12px; border-bottom: 1px solid var(--color-control-gray); }
.gsearch { position: relative; display: block; }
.gsearch svg { position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; margin-top: -8px; fill: var(--color-steel); }
.gfilters input, .gfilters select { width: 100%; min-width: 0; font: inherit; font-size: 14px; color: var(--color-ink); background: var(--color-paper-frost); border: 0; box-shadow: var(--shadow-subtle); border-radius: 12px; padding: 9px 12px; outline: none; transition: box-shadow .2s; }
.gfilters select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%2386868b' stroke-width='1.4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.gsearch input { padding-left: 38px; border-radius: var(--radius-inputs); }
.gfilters input:focus, .gfilters select:focus { box-shadow: 0 0 0 2px var(--color-pricing-blue); }
.gfilters__row { display: flex; gap: 8px; }
.gfilters__foot { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--color-slate); padding-top: 2px; }
.linkbtn { background: none; border: 0; padding: 0; font-size: 12px; color: var(--color-apple-blue); }
.linkbtn:hover { text-decoration: underline; }

.glist { list-style: none; margin: 8px -6px 0; padding: 0 6px; overflow-y: auto; flex: 1; min-height: 120px; scrollbar-width: thin; }
.glist li { border-radius: 14px; }
.gitem { width: 100%; text-align: left; background: none; border: 0; padding: 12px; border-radius: 14px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; color: var(--color-ink); transition: background-color .2s; }
.gitem:hover { background: var(--color-studio-mist); }
.gitem.is-on { background: var(--color-ink); color: #fff; }
.gitem.is-on .gitem__meta, .gitem.is-on .gitem__eco { color: rgba(255, 255, 255, .65); }
.gitem__players { font-size: 14px; font-weight: 600; letter-spacing: -0.224px; line-height: 1.3; }
.gitem__res { font-family: var(--font-mono); font-size: 12px; align-self: start; padding-top: 2px; }
.gitem__meta { grid-column: 1 / -1; font-size: 12px; color: var(--color-slate); display: flex; gap: 8px; flex-wrap: wrap; }
.gitem__eco { font-family: var(--font-mono); color: var(--color-apple-blue); }
.gitem__tag { color: var(--color-launch-orange); font-weight: 600; }
.glist__empty { padding: 24px 8px; font-size: 14px; color: var(--color-slate); text-align: center; }
.glist__import { margin-top: 12px; font-size: 14px; padding: 9px; }

/* board column */
.gdb__board { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 64px; }
.gboard { display: flex; gap: 12px; align-items: stretch; }
.gboard__wrap { flex: 1; min-width: 0; }
.gboard__player { margin: 0; padding: 8px 4px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.gboard__player::before { content: ""; width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--color-steel); }
.gboard__player.is-black::before { background: var(--color-ink); box-shadow: none; }
.gboard__player.is-white::before { background: #fff; }

[data-board].board2d { display: block; position: relative; width: 100%; aspect-ratio: 1; border-radius: 16px; overflow: hidden; background: #eef2f7; user-select: none; }
.board2d__squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.board2d__pieces { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.board2d__arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.board2d__arrows .arrow { stroke-width: 0.17; stroke-linecap: round; opacity: .82; }
.board2d__arrows .arrow--best { stroke: var(--color-pricing-blue); }
.board2d__arrows .arrow--alt { stroke: var(--color-steel); stroke-width: 0.12; opacity: .55; }
.board2d__arrows marker path { fill: var(--color-pricing-blue); }
[data-board] .piece { font-size: clamp(26px, 5.2vw, 60px); }
[data-board] .sq.check { background: radial-gradient(circle, rgba(217, 48, 37, .55) 0%, rgba(217, 48, 37, 0) 70%); }
[data-board] .sq.sel { box-shadow: inset 0 0 0 3px var(--color-pricing-blue); }
[data-board] .sq.tgt::after { content: ""; position: absolute; left: 50%; top: 50%; width: 26%; height: 26%; margin: -13% 0 0 -13%; border-radius: 50%; background: rgba(0, 113, 227, .35); }

.evalbar { width: 22px; border-radius: 11px; background: #1d1d1f; position: relative; overflow: hidden; margin: 37px 0; flex-shrink: 0; }
.evalbar[hidden] { display: none; }
.evalbar span { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: #fff; box-shadow: inset 0 0 0 1px var(--color-hairline-silver); transition: height .6s var(--ease); }
.evalbar b { position: absolute; left: 0; right: 0; bottom: 6px; font-size: 9px; text-align: center; color: var(--color-ink); writing-mode: vertical-rl; transform: rotate(180deg); font-weight: 500; }
.evalbar.is-black b { bottom: auto; top: 6px; color: #fff; }
.is-flipped .evalbar { transform: rotate(180deg); }
.is-flipped .evalbar b { transform: none; }

.player--wide { max-width: none; justify-content: center; margin: 0; }
.engine-toggle { margin-left: 8px; font-size: 14px; padding: 9px 16px; gap: 8px; }
.engine-toggle__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-steel); transition: background-color .3s; }
.engine-toggle[aria-pressed="true"] { background: var(--color-ink); color: #fff; box-shadow: none; }
.engine-toggle[aria-pressed="true"] .engine-toggle__dot { background: #34c759; box-shadow: 0 0 0 4px rgba(52, 199, 89, .2); }

/* side panel */
.gdb__side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 64px; max-height: calc(100vh - 84px); }
.ghead { background: #fff; border-radius: var(--radius-cards); padding: 22px 24px; }
.ghead__event { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--color-slate); }
.ghead__players { font-family: var(--font-display); font-size: 21px; font-weight: 600; line-height: 1.2; margin: 0 0 10px; display: flex; flex-direction: column; letter-spacing: -0.01em; }
.ghead__players em { font-style: normal; font-weight: 400; font-size: 13px; color: var(--color-steel); margin: 2px 0; }
.ghead__meta { margin: 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--color-slate); }
.ghead__result { background: var(--color-studio-mist); color: var(--color-ink); border-radius: 8px; padding: 3px 8px; font-size: 12px; }

.engine { background: #fff; border-radius: 20px; padding: 14px 16px; }
.engine[hidden] { display: none; }
.engine__head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-bottom: 8px; }
.engine__name { font-weight: 600; }
.engine__name em { font-style: normal; font-weight: 400; color: var(--color-slate); margin-left: 6px; }
.engine__depth { font-size: 12px; color: var(--color-slate); }
.engine__lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.engine__lines li { display: grid; grid-template-columns: 54px 1fr; gap: 8px; align-items: baseline; padding: 7px 8px; border-radius: 10px; background: var(--color-paper-frost); line-height: 1.5; }
.engine__lines b { font-weight: 500; text-align: center; border-radius: 6px; padding: 1px 0; background: #fff; box-shadow: var(--shadow-subtle); }
.engine__lines b.pos { color: var(--color-ink); }
.engine__lines b.neg { background: var(--color-ink); color: #fff; box-shadow: none; }
.engine__lines span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.notation { background: #fff; border-radius: var(--radius-cards); padding: 18px 20px; font-size: 14px; line-height: 1.9; overflow-y: auto; flex: 1; min-height: 180px; scrollbar-width: thin; outline: none; }
.notation:focus-visible { box-shadow: 0 0 0 2px var(--color-pricing-blue); }
.notation .mv { font-family: var(--font-mono); font-size: 13px; background: none; border: 0; padding: 1px 4px; border-radius: 6px; color: var(--color-ink); cursor: pointer; }
.notation .mv:hover { background: var(--color-control-gray); }
.notation .mv.is-on { background: var(--color-pricing-blue); color: #fff; }
.notation .num { font-family: var(--font-mono); font-size: 12px; color: var(--color-steel); margin-left: 4px; }
.notation .nag { color: var(--color-launch-orange); font-weight: 600; }
.notation .cm { display: block; margin: 4px 0 6px; padding: 8px 12px; font-size: 13px; line-height: 1.45; color: var(--color-slate); background: var(--color-paper-frost); border-radius: 10px; }
.notation .var { display: block; margin: 2px 0 4px 12px; padding-left: 10px; border-left: 2px solid var(--color-control-gray); font-size: 13px; }
.notation .var .mv { font-size: 12px; color: var(--color-slate); }
.notation .var .mv.is-on { color: #fff; }
.notation .var .cm { background: none; padding: 0 4px; display: inline; }
.notation .res { display: block; margin-top: 8px; font-family: var(--font-mono); font-weight: 600; }

.gactions { display: flex; flex-wrap: wrap; gap: 6px; }
.chipbtn { font: inherit; font-size: 12px; border: 0; background: #fff; box-shadow: var(--shadow-subtle); border-radius: var(--radius-buttons); padding: 7px 12px; color: var(--color-ink); cursor: pointer; transition: background-color .2s, color .2s; }
.chipbtn:hover { background: var(--color-ink); color: #fff; }
.chipbtn--danger { color: #b3261e; }
.chipbtn--danger:hover { background: #b3261e; color: #fff; }

.gnotes { background: #fff; border-radius: 20px; padding: 12px 16px; font-size: 14px; }
.gnotes summary { cursor: pointer; font-weight: 500; }
.gnotes textarea { width: 100%; margin-top: 10px; font: inherit; font-size: 14px; border: 0; box-shadow: var(--shadow-subtle-2); border-radius: 12px; padding: 10px 12px; resize: vertical; outline: none; }
.gnotes textarea:focus { box-shadow: 0 0 0 2px var(--color-pricing-blue); }
.gnotes__hint { margin: 6px 0 0; font-size: 12px; color: var(--color-slate); }

/* ============ Import dialog ============ */
.gimport { border: 0; padding: 0; border-radius: var(--radius-cards); width: min(640px, calc(100vw - 32px)); background: #fff; color: var(--color-ink); box-shadow: var(--shadow-subtle); }
.gimport::backdrop { background: rgba(29, 29, 31, .35); backdrop-filter: blur(6px); }
.gimport__inner { padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.gimport__head { display: flex; justify-content: space-between; align-items: center; }
.gimport__head h2 { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.gimport__close { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--color-studio-mist); font-size: 22px; line-height: 1; }
.gtabs { display: flex; gap: 6px; background: var(--color-studio-mist); border-radius: var(--radius-buttons); padding: 4px; }
.gtab { flex: 1; border: 0; background: none; padding: 8px 12px; border-radius: var(--radius-buttons); font-size: 14px; color: var(--color-ink); }
.gtab.is-on { background: #fff; box-shadow: var(--shadow-subtle); font-weight: 500; }
.gpanel textarea, .gpanel input[type=text] { width: 100%; font-family: var(--font-mono); font-size: 13px; border: 0; box-shadow: var(--shadow-subtle-2); border-radius: 14px; padding: 14px; outline: none; resize: vertical; }
.gpanel input[type=text] { font-family: var(--font-text); font-size: 15px; border-radius: var(--radius-inputs); padding: 12px 18px; }
.gpanel textarea:focus, .gpanel input:focus { box-shadow: 0 0 0 2px var(--color-pricing-blue); }
.gpanel__hint { font-size: 12px; color: var(--color-slate); margin: 8px 4px 0; }
.gdrop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 170px; border-radius: 18px; border: 1.5px dashed var(--color-steel); background: var(--color-paper-frost); cursor: pointer; text-align: center; padding: 20px; transition: background-color .2s, border-color .2s; }
.gdrop.is-over { background: #e8f1fc; border-color: var(--color-pricing-blue); }
.gdrop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gdrop span { font-size: 13px; color: var(--color-slate); }
.gimport__msg { margin: 0; font-size: 13px; min-height: 1.4em; white-space: pre-line; }
.gimport__msg.is-error { color: #b3261e; }
.gimport__msg.is-ok { color: #2e7d32; }
.gimport__foot { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.gimport__foot p { margin: 0; font-size: 12px; color: var(--color-slate); }

/* toast (shared look with contact page) */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, calc(100% + 40px)); opacity: 0; background: var(--color-ink); color: #fff; font-size: 14px; padding: 12px 20px; border-radius: var(--radius-buttons); z-index: 200; pointer-events: none; transition: transform .5s var(--ease), opacity .3s; }
.toast.is-on { transform: translate(-50%, 0); opacity: 1; }

/* ============ Responsive ============ */
@media (max-width: 1240px) {
  .gdb { grid-template-columns: 280px 1fr; }
  .gdb__side { grid-column: 1 / -1; position: static; max-height: none; display: grid; grid-template-columns: 1fr 1fr; }
  .gdb__side .notation { grid-row: span 3; max-height: 460px; }
}
@media (max-width: 860px) {
  .gdb { grid-template-columns: 1fr; padding: 24px 16px 64px; }
  .gdb__list, .gdb__board { position: static; max-height: none; }
  .gdb__list { order: 2; }
  .gdb__board { order: 1; }
  .gdb__side { order: 3; grid-template-columns: 1fr; }
  .glist { max-height: 360px; }
  .player--wide { flex-wrap: wrap; }
  .engine-toggle { margin: 8px 0 0; flex-basis: 100%; justify-content: center; }
  .evalbar { width: 14px; }
}

/* club games: progressive list */
.glist__more { display: block; margin: 10px auto 4px; font-size: 14px; }
.glist__more[hidden] { display: none; }

/* game review */
.chipbtn--main { background: var(--color-ink) !important; color: #fff !important; }
.review { background: #fff; border-radius: 22px; padding: 20px; margin: 14px 0; box-shadow: 0 0 0 1px rgba(0,0,0,.06); }
.review[hidden] { display: none; }
.review__progress { display: flex; flex-direction: column; gap: 10px; }
.review__head { display: flex; justify-content: space-between; align-items: center; }
.review__head h3 { margin: 0; font-size: 19px; }
.review__acc { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.review__acc div { background: var(--color-studio-mist); border-radius: 16px; padding: 12px; text-align: center; display: flex; flex-direction: column; }
.review__acc span { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review__acc b { font-family: var(--font-display); font-size: 32px; }
.review__acc small { font-size: 11px; color: var(--color-slate); text-transform: uppercase; letter-spacing: .05em; }
.review__curve { width: 100%; height: 110px; border-radius: 12px; cursor: pointer; display: block; }
.review__tbl { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 14px; }
.review__tbl td, .review__tbl th { padding: 5px 6px; text-align: center; border-bottom: 1px solid #eee; }
.review__tbl td:first-child, .review__tbl th:first-child { text-align: left; }
.rv-dot { display: inline-grid; place-items: center; min-width: 22px; height: 22px; border-radius: 11px; color: #fff; font-size: 11px; font-weight: 700; margin-right: 8px; padding: 0 4px; }
.review__keys { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.review__note { font-size: 12px; margin: 10px 0 0; }
.rv-mark { font-weight: 700; margin-left: 2px; font-size: .85em; }
.meter { height: 8px; border-radius: 99px; background: var(--color-studio-mist); overflow: hidden; }
.meter i { display: block; height: 100%; border-radius: 99px; background: var(--color-apple-blue); transition: width .3s; }