/* Ctrl+Alt+Deal: contents of the Account and Cards windows. Window chrome,
   colors and the Files toolbar/sidebar/status come from ../os/os.css and
   ../os/site.css; this file only adds the game's own pieces. */

:root {
  /* four-color deck: spades black, hearts red, diamonds blue, clubs green */
  --suit-S: #1d2329;
  --suit-H: #c8202f;
  --suit-D: #1f5fc4;
  --suit-C: #1d7f3a;
  --good: #1a7f37;
  --bad: #c4314b;
  --gate: #b35c00;
  --gold: #e8b931;
  --gold-edge: #b8860b;
  --gold-fg: #3d2b00;
}
[data-theme='dark'] {
  --suit-S: #e6e8eb;
  --suit-H: #ff7b7b;
  --suit-D: #7fb0ff;
  --suit-C: #7fd99a;
  --good: #8fdc9a;
  --bad: #ff8f8f;
  --gate: #f5b056;
  --gold: #d4a52a;
  --gold-edge: #f0c75e;
  --gold-fg: #241900;
}
/* No color (Display setting): the game's colored text uses the plain text color */
body.no-color {
  --suit-S: var(--w-fg);
  --suit-H: var(--w-fg);
  --suit-D: var(--w-fg);
  --suit-C: var(--w-fg);
  --good: var(--w-fg);
  --bad: var(--w-fg);
  --gate: var(--w-fg);
}

.muted { color: var(--w-muted); }

/* ---------------------------------------------------------------------------
   Account window: a properties sheet */

.acct { flex: 1; overflow: auto; padding: 14px 16px 16px; }

.acct-sheet {
  display: grid;
  gap: 6px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--w-line);
}
.acct-row { display: grid; grid-template-columns: 92px 1fr; align-items: baseline; gap: 10px; }
.acct-label { color: var(--w-muted); }
.acct-bankroll { font-variant-numeric: tabular-nums; }
.gate-tag { color: var(--gate); }


.acct-group { margin-bottom: 16px; }
.acct-group h3 { margin-bottom: 6px; font-size: 12px; font-weight: 600; }
[data-os='value'] .acct-group {
  padding: 10px 12px 12px;
  border: 1px solid var(--w-line);
  border-radius: 4px;
}
[data-os='value'] .acct-group h3 { margin-top: -18px; margin-bottom: 8px; width: max-content; padding: 0 4px; background: var(--w-bg); font-weight: 400; }
[data-os='value'] .acct-group { margin-top: 18px; }
[data-os='quality'] .acct-group h3 { color: var(--w-muted); font-size: 11px; }
[data-os='power'] .acct-group h3 { font-weight: 700; }


.kg-btn.mini { padding: 3px 9px; font-size: 12px; min-width: 0; }
.kg-btn:disabled { opacity: 0.5; cursor: default; filter: none; }

/* Deal sits at the left of the Cards toolbar, where a file browser's path would be. */
.files-toolbar .deal { margin-right: auto; padding: 4px 22px; font-weight: 600; background: var(--good); border-color: var(--good); color: #ffffff; }
[data-theme='dark'] .files-toolbar .deal { color: #000000; }
.files-toolbar .deal.boss { background: var(--gold); border-color: var(--gold-edge); color: var(--gold-fg); }
/* After a hand pays out: Deal goes plain and Edit deck turns green */
.files-toolbar .deal.after-hand { background: var(--w-btn); border-color: var(--w-btn-border); color: var(--w-fg); }
.files-toolbar .tool-btn.go:not(:disabled) { background: var(--good); border-color: var(--good); color: #ffffff; }
[data-theme='dark'] .files-toolbar .tool-btn.go:not(:disabled) { color: #000000; }
.files-toolbar .tool-btn.go:hover:not(:disabled) { filter: brightness(0.95); }
/* With every shop tool on, the toolbar wraps onto a second row. */
.files-toolbar { flex-wrap: wrap; height: auto; min-height: 40px; padding-top: 6px; padding-bottom: 6px; }
/* Double bet sits right after Deal, so it takes over Deal's push to the left. */

/* Achievements are off on Easy: the Account row, setup warning and dialogs say so in this colour. */
.ach-off { color: var(--gate); font-weight: 600; }
.acct-note { margin-top: 8px; color: var(--w-muted); font-size: 12px; line-height: 1.45; }
.acct-note:empty { display: none; }
.acct-note b { color: var(--w-fg); }
.acct-note .kg-btn { margin-left: 4px; }

.last-cards { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.mini-card {
  padding: 2px 6px;
  border: 1px solid var(--w-line);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 12px;
}
/* The cards a boss put in the deck, listed under a result or the boss note */
.boss-cards { display: block; margin-top: 4px; color: var(--gate); }
.boss-cards span { font-weight: 600; }
.boss-cards .suit-S { color: var(--suit-S); }
.boss-cards .suit-H { color: var(--suit-H); }
.boss-cards .suit-D { color: var(--suit-D); }
.boss-cards .suit-C { color: var(--suit-C); }

.mini-card.suit-S { color: var(--suit-S); }
.mini-card.suit-H { color: var(--suit-H); }
.mini-card.suit-D { color: var(--suit-D); }
.mini-card.suit-C { color: var(--suit-C); }
.mini-card.drawn { border-style: dashed; }
.mini-card.unscored { opacity: 0.45; }
.last-result .interest { color: var(--w-muted); }

/* Deck properties: card counts by rank and suit */
#deck-info p { margin-bottom: 6px; }
.deck-counts { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.deck-counts span { display: inline-flex; gap: 3px; padding: 1px 5px; border: 1px solid var(--w-line); border-radius: 4px; font-size: 12px; }
.deck-counts span.none { opacity: 0.4; }
.deck-counts b { font-family: var(--mono); }
.deck-counts .suit-S b { color: var(--suit-S); }
.deck-counts .suit-H b { color: var(--suit-H); }
.deck-counts .suit-D b { color: var(--suit-D); }
.deck-counts .suit-C b { color: var(--suit-C); }
.last-result { line-height: 1.45; }
.good b:last-of-type, .last-result.good b { color: var(--good); }
.bad b:last-of-type, .last-result.bad b { color: var(--bad); }
.last-result b:first-child { color: var(--w-fg); }

.paytable { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.paytable th, .paytable td { padding: 3px 6px; text-align: right; font-weight: 400; }
.paytable th[scope='row'], .paytable thead th:first-child { text-align: left; }
.paytable thead th { color: var(--w-muted); font-size: 11.5px; border-bottom: 1px solid var(--w-line); }
.paytable tbody tr:nth-child(even) { background: rgba(127, 127, 127, 0.06); }
.paytable td.neg { color: var(--w-muted); }
.paytable td.even { color: var(--w-muted); font-style: italic; }
.paytable td.pass { color: var(--good); font-weight: 600; }
.paytable tr.last th[scope='row'] { font-weight: 600; }
.paytable .ups { margin-left: 4px; color: var(--w-accent); font-size: 11px; font-weight: 600; }
.paytable tr.last { box-shadow: inset 3px 0 0 var(--w-accent); }
.paytable td.odds { color: var(--w-muted); font-size: 12px; }


.acct-foot { display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 8px; }
.acct-top { margin-bottom: 16px; }

/* ---------------------------------------------------------------------------
   Cards window: a file browser */

.tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--w-fg);
  font: inherit;
  cursor: default;
}
.tool-btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tool-btn:hover:not(:disabled) { background: var(--w-hover); }
.tool-btn:disabled { opacity: 0.4; }
.tool-btn.primary:not(:disabled) { color: var(--w-accent); border-color: var(--w-accent); }
.tool-btn.shop:disabled { opacity: 0.55; }
.tool-btn.shop b { font-weight: 600; }
.tool-btn.danger.primary:not(:disabled) { color: var(--w-danger); border-color: var(--w-danger); }
[data-os='power'] .tool-btn { background: var(--w-btn); font-weight: 700; }

.files-side a em { margin-left: auto; color: var(--w-muted); font-size: 11px; font-style: normal; }

.banner {
  flex: none;
  padding: 8px 14px;
  border-bottom: 1px solid var(--w-line);
  background: var(--w-side);
  line-height: 1.45;
}
.banner:empty { display: none; }
.banner.help { display: flex; align-items: flex-start; gap: 8px; }
.banner.help > span { flex: 1; }
.banner-x {
  flex: none;
  width: 22px;
  height: 22px;
  margin: -1px -6px 0 0;
  border: 0;
  border-radius: 4px;
  background: none;
  color: var(--w-muted);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}
.banner-x:hover { background: var(--w-select); color: var(--w-fg); }
.banner.good b:last-of-type { color: var(--good); }
.banner.bad { color: var(--bad); }
.banner.bad b { color: inherit; }
.banner .kg-btn { margin-left: 6px; }

.icon-view {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(106px, 1fr));
  align-content: start;
  gap: 4px;
  padding: 12px;
  overflow: auto;
  outline: none;
}
.icon-view .empty { grid-column: 1 / -1; padding: 10px 4px; color: var(--w-muted); }

.file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px 6px;
  border: 1px solid transparent;
  border-radius: 5px;
  text-align: center;
  cursor: default;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  outline: none;
}
.file:hover { background: var(--w-hover); }
.file:focus-visible { border-color: var(--w-accent); }
.file.selected { background: var(--w-select); border-color: color-mix(in srgb, var(--w-accent) 45%, transparent); }
[data-os='quality'] .file.selected { border-color: transparent; }
[data-os='quality'] .file.selected .file-label { background: var(--w-accent); color: var(--w-accent-fg); }
.file.done { cursor: default; }
.file.unscored { opacity: 0.45; }
.file.done:hover { background: none; }

.file-label {
  max-width: 100%;
  padding: 0 4px;
  border-radius: 3px;
  font-size: 12px;
  line-height: 1.3;
  overflow-wrap: break-word;
}

/* a card file: a page with a folded corner */
.card-icon {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 54px;
  background: #ffffff;
  border: 1px solid #a9b2bc;
  border-radius: 3px 10px 3px 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  color: #1d2329;
  font-family: var(--mono);
  line-height: 1;
}
.card-icon::after {
  content: '';
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  background: linear-gradient(225deg, var(--w-bg) 50%, #dfe4ea 50%);
  border-bottom: 1px solid #a9b2bc;
  border-left: 1px solid #a9b2bc;
  border-radius: 0 0 0 3px;
}
.card-icon { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
/* the card icon is always white paper, so it keeps the light-theme colors */
.card-icon.suit-H { color: #c8202f; }
.card-icon.suit-D { color: #1f5fc4; }
.card-icon.suit-C { color: #1d7f3a; }
body.no-color .card-icon { color: #1d2329; }
body.no-color .paytable .ups { color: var(--w-fg); }
.file.selected .card-icon::after { background: linear-gradient(225deg, var(--w-select) 50%, #dfe4ea 50%); }
.file:hover:not(.selected) .card-icon::after { background: linear-gradient(225deg, var(--w-hover) 50%, #dfe4ea 50%); }
.file.done:hover .card-icon::after { background: linear-gradient(225deg, var(--w-bg) 50%, #dfe4ea 50%); }

/* A card with Add 2x carries a small gold tag */
.card-bonus {
  position: absolute;
  bottom: -5px;
  right: -7px;
  padding: 0 3px;
  background: var(--gold);
  border: 1px solid var(--gold-edge);
  border-radius: 3px;
  color: var(--gold-fg);
  font-size: 10px;
  line-height: 1.3;
}

/* Draw odds: a strip under the banner during a hand */
.draw-odds {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--w-line);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
.draw-odds b { font-family: var(--mono); }
.draw-odds .sep { width: 1px; align-self: stretch; background: var(--w-line); }
.draw-odds .suit-S b { color: var(--suit-S); }
.draw-odds .suit-H b { color: var(--suit-H); }
.draw-odds .suit-D b { color: var(--suit-D); }
.draw-odds .suit-C b { color: var(--suit-C); }

.file.fresh .card-icon { animation: arrive 0.5s ease-out; }
@keyframes arrive {
  from { transform: translateY(-6px); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .file.fresh .card-icon { animation: none; }
}

/* ---------------------------------------------------------------------------
   Context menu */

.ctx {
  position: fixed;
  z-index: 4000;
  min-width: 230px;
  padding: 4px;
  background: var(--w-bg);
  border: 1px solid var(--w-border);
  border-radius: calc(var(--radius) * 0.75);
  box-shadow: var(--w-shadow);
  color: var(--w-fg);
}
.ctx button {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: 100%;
  padding: 6px 10px;
  background: none;
  border: none;
  border-radius: 4px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: default;
}
.ctx button:hover:not(:disabled), .ctx button:focus-visible { background: var(--w-hover); outline: none; }
[data-os='quality'] .ctx button:hover:not(:disabled) { background: var(--w-accent); color: var(--w-accent-fg); }
.ctx button:disabled { color: var(--w-muted); opacity: 0.6; }
.ctx button.danger:not(:disabled) { color: var(--w-danger); }
[data-os='quality'] .ctx button.danger:hover:not(:disabled) { color: var(--w-accent-fg); }
.ctx kbd { color: var(--w-muted); font: inherit; font-size: 12px; }
.ctx hr { margin: 4px 6px; border: none; border-top: 1px solid var(--w-line); }
.ctx-hint { max-width: 240px; padding: 4px 10px 6px; color: var(--w-muted); font-size: 12px; }

/* ---------------------------------------------------------------------------
   Dialog */

.cad-modal .kg-dialog { width: min(400px, 100%); }
.dlg-body { padding: 18px 20px 8px; line-height: 1.5; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; }
.kg-primary.danger { background: var(--w-danger); border-color: var(--w-danger); color: #ffffff; }
[data-theme='dark'] .kg-primary.danger { color: #000000; }

/* End-of-run achievements */
.dlg-ach { margin-top: 10px; }
.dlg-ach-list { margin: 4px 0 0; padding-left: 1.3em; }

/* New run setup */
.cad-setup .kg-dialog { display: flex; flex-direction: column; width: min(520px, 100%); }
.cad-setup .dlg-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.setup-selects { display: grid; gap: 10px; margin-bottom: 14px; }
.setup-field label { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 3px; font-weight: 600; }
.setup-field label .muted { font-size: 12px; font-weight: 400; }
.setup-field select {
  width: 100%;
  padding: 5px 8px;
  background: var(--w-bg);
  border: 1px solid var(--w-btn-border);
  border-radius: 5px;
  color: var(--w-fg);
  font: inherit;
}
.setup-hint { margin-top: 3px; color: var(--w-muted); font-size: 12px; }
.setup-group { margin: 0 0 12px; padding: 0; border: none; }
.setup-group legend { margin-bottom: 4px; padding: 0; font-weight: 600; }
.setup-toggle { display: flex; align-items: flex-start; gap: 8px; padding: 4px 0; cursor: pointer; }
.setup-toggle input { margin-top: 3px; }
.setup-toggle > span { display: grid; }
.setup-toggle .muted { font-size: 12px; }
.setup-toggle.locked { cursor: default; }
.setup-toggle.locked b { color: var(--w-muted); font-weight: 400; }
.setup-warn { margin: -6px 0 14px; }
.setup-intro { margin: 0 0 12px; font-size: 13px; }

/* Achievements list */
.cad-achievements .kg-dialog { display: flex; flex-direction: column; width: min(520px, 100%); }
.cad-achievements .dlg-body { flex: 1 1 auto; min-height: 0; overflow: auto; }
.ach-banner { margin-bottom: 8px; }
.ach-count { margin-bottom: 8px; color: var(--w-muted); }
.ach-list { margin: 0; padding: 0; list-style: none; }
.ach-list li { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; border-top: 1px solid var(--w-line); }
.ach-list li > span:last-child { display: grid; }
.ach-list .muted { font-size: 12px; }
.ach-list li:not(.got) b { font-weight: 400; }
.ach-check {
  flex: none;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  border: 1px solid var(--w-line);
  border-radius: 4px;
  color: var(--good);
  font-size: 12px;
  font-weight: 700;
}
.ach-list li.got .ach-check { border-color: var(--good); }

/* Achievement toasts, bottom right */
.cad-toasts { position: fixed; right: 16px; bottom: 72px; z-index: 5000; display: grid; gap: 8px; width: min(320px, calc(100vw - 32px)); pointer-events: none; }
.cad-toast {
  display: grid;
  gap: 2px;
  padding: 10px 14px;
  background: var(--w-bg);
  border: 1px solid var(--gold-edge);
  border-left: 4px solid var(--gold);
  border-radius: 6px;
  box-shadow: var(--w-shadow);
  color: var(--w-fg);
  animation: arrive 0.3s ease-out;
}
.cad-toast span { color: var(--w-muted); font-size: 12px; }
[data-os='phone'] .cad-toasts { top: 56px; bottom: auto; }

/* How to play: a Notes window (site.css) shown as a modal */
.cad-howto .kg-dialog { display: flex; flex-direction: column; width: min(460px, 100%); }
.cad-howto .notes-page,
[data-os='value'] .cad-howto .notes-page { flex: 0 1 auto; min-height: 0; padding: 16px 20px; font-size: 16px; }
.cad-howto .notes-page li + li { margin-top: 12px; }
.cad-howto .notes-page li ul { margin: 4px 0 0; list-style: disc; }
.cad-howto .notes-page h2 { margin: 16px 0 4px; font-size: 1em; }
.cad-howto .notes-page h2:first-of-type { margin-top: 0; }
.cad-howto .notes-page p { margin-bottom: 6px; }
.cad-howto .notes-page ol,
.cad-howto .notes-page ul { margin: 0 0 6px; padding-left: 1.6em; }
.cad-howto .notes-status { align-items: center; }
.cad-howto .notes-status .kg-btn { margin-left: auto; }
[data-os='quality'] .cad-howto .notes-status,
[data-os='phone'] .cad-howto .notes-status { display: flex; }

/* ---------------------------------------------------------------------------
   Phones: one window at a time, switched with tabs along the top */

.screen-tabs { display: none; }

[data-os='phone'] .screen-tabs {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  gap: 4px;
  height: 48px;
  padding: 6px 12px;
  background: var(--w-chrome);
  border-bottom: 1px solid var(--w-line);
}
[data-os='phone'] .screen-tabs button {
  flex: 1;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--w-muted);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
}
[data-os='phone'] .screen-tabs button[aria-selected='true'] { background: var(--w-select); color: var(--w-fg); }

[data-os='phone'] .window.account,
[data-os='phone'] .window.cards { inset: 48px 0 var(--tabbar-h, 64px) 0; }
[data-os='phone'] .window.account .titlebar,
[data-os='phone'] .window.cards .titlebar { display: none; }
[data-os='phone'] .window:not(.on-screen):not(.kg-dialog) { display: none; }

[data-os='phone'] .files-side {
  display: flex;
  flex: none;
  gap: 2px;
  width: auto;
  padding: 6px 8px;
  overflow-x: auto;
  border-right: none;
  border-bottom: 1px solid var(--w-line);
}
[data-os='phone'] .files-side h2 { display: none; }
[data-os='phone'] .files-side a { flex: none; padding: 6px 10px; white-space: nowrap; }
[data-os='phone'] .files-side a em { margin-left: 4px; }
[data-os='phone'] .files-body { flex-direction: column; }
[data-os='phone'] .tool-btn span { display: none; }
[data-os='phone'] .tool-btn.primary span,
[data-os='phone'] .tool-btn.shop span { display: inline; }
[data-os='phone'] .tool-btn { padding: 0 7px; }
[data-os='phone'] .files-toolbar { flex-wrap: wrap; justify-content: flex-end; height: auto; min-height: 40px; padding: 6px 10px; }
[data-os='phone'] .icon-view { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
[data-os='phone'] .file-label { padding: 0 1px; font-size: 11px; }
[data-os='phone'] .files-status { font-size: 11px; }
[data-os='phone'] .acct { padding: 14px 16px 20px; }
[data-os='phone'] .kg-btn.mini { width: auto; padding: 6px 10px; border-radius: 8px; font-size: 14px; }
[data-os='phone'] .acct-note .kg-btn, [data-os='phone'] .banner .kg-btn { width: auto; padding: 4px 10px; font-size: 13px; }
[data-os='phone'] .dlg-foot .kg-btn { width: auto; flex: 1; }
[data-os='phone'] .banner-x { width: 32px; height: 32px; margin: -6px -10px -6px 0; font-size: 20px; }
[data-os='phone'] .files-toolbar .deal { width: auto; padding: 4px 16px; }
[data-os='phone'] .cad-setup .kg-dialog,
[data-os='phone'] .cad-achievements .kg-dialog { max-height: calc(100vh - 112px); }

/* Every game button shows the pointer on hover (the shell's OS-style buttons default to the arrow) */
.window button:not(:disabled),
.screen-tabs button,
#ctx button:not(:disabled) { cursor: pointer; }
