:root {
  --bg: #1b110a;
  --bg2: #2a1a0f;
  --ink: #f3e6cc;
  --muted: #bfa982;
  --gold: #d6ae5c;
  --gold2: #b48a3a;
  --felt: #20402c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: radial-gradient(ellipse at top, #3a2414 0%, var(--bg) 70%) fixed;
  background-color: var(--bg);
  color: var(--ink);
  font: 15px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
#app {
  max-width: 1180px; margin: 0 auto; height: 100%; height: 100dvh;
  display: flex; flex-direction: column;
  padding: max(6px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}
.bar { display: flex; align-items: center; gap: 8px; padding: 2px 0 8px; }
.brand { font-family: Georgia, "Times New Roman", serif; font-size: 20px; color: var(--gold); letter-spacing: .5px; }
.info {
  margin: 0 auto; display: flex; gap: 12px; align-items: center; white-space: nowrap;
  background: rgba(0,0,0,.3); border: 1px solid rgba(214,174,92,.35); padding: 4px 12px; border-radius: 20px;
}
.info b { color: #fff; font-size: 16px; font-variant-numeric: tabular-nums; }
.info .clk { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); }
.info .mv { color: var(--muted); }
.tools { display: flex; gap: 6px; align-items: center; }
button, select {
  font: inherit; color: var(--ink); background: var(--bg2);
  border: 1px solid rgba(214,174,92,.45); border-radius: 10px; padding: 6px 10px; cursor: pointer;
}
select { padding: 6px 6px; }
button.icon { width: 36px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: linear-gradient(#e2bd6d, #b48a3a); color: #2a1708; border-color: #f0d08a; font-weight: 700; }
button.secondary { background: rgba(0,0,0,.25); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Стол: сукно в деревянной раме */
.table {
  flex: 1; min-height: 0; position: relative;
  border-radius: 14px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, #2d5a3c 0%, #1f4029 60%, #142b1b 100%);
  box-shadow: inset 0 0 0 3px #5b3a22, inset 0 0 0 5px rgba(214,174,92,.35), inset 0 0 40px rgba(0,0,0,.5), 0 12px 40px rgba(0,0,0,.5);
}
#board {
  position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.igc-slotg.hint .igc-slot { stroke: #ffd36b; stroke-opacity: 1; stroke-dasharray: none; stroke-width: 3; }
.toast {
  position: absolute; left: 50%; bottom: 12px; transform: translate(-50%, 8px);
  max-width: calc(100% - 24px); width: max-content; text-align: center;
  background: rgba(20,12,6,.92); border: 1px solid var(--gold2); color: var(--ink);
  padding: 8px 14px; border-radius: 12px; font-size: 15px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.alert { color: #ffcf7a; }

.actions { display: flex; gap: 10px; justify-content: center; padding-top: 8px; }
.actions button { min-width: 140px; padding: 10px 14px; font-size: 16px; }

/* Модальное окно */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.card { background: linear-gradient(#3a2414, #24160c); border: 1px solid var(--gold2); border-radius: 16px; padding: 18px 20px; max-width: 480px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.card h2 { margin: 0 0 10px; font-family: Georgia, serif; color: var(--gold); font-size: 22px; }
.card h3 { margin: 14px 0 4px; font-family: Georgia, serif; color: var(--gold); font-size: 17px; }
.card p { margin: 6px 0; }
.rules { padding-left: 18px; margin: 0; } .rules li { margin: 6px 0; }
.modalBtns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.modalBtns button { padding: 9px 16px; font-size: 16px; }
.big { font-size: 24px; font-weight: 800; color: #fff; }
.rec { color: #ffd36b; font-weight: 700; }
.stats { border-collapse: collapse; margin: 8px 0 2px; min-width: 240px; }
.stats td { padding: 3px 0; border-bottom: 1px solid rgba(214,174,92,.18); }
.stats td + td { text-align: right; padding-left: 24px; color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.hintSmall { color: var(--muted); font-size: 13px; }

/* Телефон, портрет: стол почти во всю ширину, кнопки внизу под большой палец */
@media (max-width: 560px) {
  #app { padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .brand { display: none; }
  .bar { gap: 6px; padding-bottom: 6px; }
  .info { margin: 0 auto 0 0; gap: 10px; padding: 4px 10px; }
  .table { border-radius: 10px; }
  .actions { gap: 6px; padding-top: 6px; }
  .actions button { min-width: 0; flex: 1; padding: 11px 6px; }
  .toast { font-size: 14px; }
}
@media (max-width: 360px) { .info .mv { display: none; } }

/* Телефон, ландшафт: всё управление в одну строку сверху, стол — на всю оставшуюся высоту */
@media (orientation: landscape) and (max-height: 540px) {
  #app { max-width: none; display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; column-gap: 8px;
    padding-top: max(4px, env(safe-area-inset-top)); padding-bottom: max(4px, env(safe-area-inset-bottom)); }
  .bar { grid-column: 1; grid-row: 1; padding: 0 0 4px; }
  .actions { grid-column: 2; grid-row: 1; padding: 0 0 4px; gap: 6px; }
  .actions button { min-width: 0; padding: 6px 10px; font-size: 15px; }
  .table { grid-column: 1 / 3; grid-row: 2; border-radius: 10px; }
  .brand { display: none; }
  .info { margin: 0 auto 0 0; }
}

/* Паук: подпись запаса, кнопка сдачи */
.dealLbl { fill: #f3e6cc; fill-opacity: .85; font-family: Arial, Helvetica, sans-serif; font-weight: 700; pointer-events: none; }
.dealLbl.blocked { fill: #ffcf7a; }
#btnDeal.blocked { background: rgba(0,0,0,.25); color: var(--muted); border-color: rgba(214,174,92,.45); font-weight: 600; }
#btnDeal span { font-variant-numeric: tabular-nums; }
.actions button { min-width: 120px; }
@media (max-width: 560px) {
  .actions button { min-width: 0; padding: 11px 4px; font-size: 15px; }
  #suits { max-width: 98px; }
}
@media (orientation: landscape) and (max-height: 540px) {
  .actions button { min-width: 0; padding: 6px 9px; font-size: 14px; }
}
