/* ===== Durak Arena — DOM overlay styles (dark fantasy-casino) ===== */

:root {
  --felt: #0f2f25;
  --felt-2: #123f31;
  --panel: rgba(8, 28, 22, 0.72);
  --panel-2: rgba(12, 40, 32, 0.82);
  --panel-border: rgba(212, 175, 55, 0.28);
  --gold: #d4af37;
  --gold-2: #f1d27a;
  --teal: #2ea58a;
  --teal-2: #4ecca3;
  --red: #d64545;
  --red-2: #ff7a7a;
  --text: rgba(255, 250, 235, 0.92);
  --muted: rgba(220, 230, 220, 0.6);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --font:
    system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--felt);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

#app {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#pixi-container {
  position: absolute;
  inset: 0;
}

#pixi-container canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---- overlay root: click-through except on panels ---- */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  font-size: 15px;
}

#ui [hidden] {
  display: none !important;
}

/* ---- generic ---- */
.panel {
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: auto;
}

.muted {
  color: var(--muted);
}
.small {
  font-size: 12.5px;
}
.gold {
  color: var(--gold-2);
}
.nick {
  font-weight: 600;
}

.brand-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.04em;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 60%, #9a7a1f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
}
.brand-title.sm {
  font-size: 20px;
}
.brand-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.section-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--gold-2);
  letter-spacing: 0.02em;
}
.section-title.sm {
  font-size: 14px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  font: inherit;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.2);
}
.input-num {
  width: 90px;
}

.btn {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition:
    transform 0.08s,
    background 0.15s,
    border-color 0.15s,
    opacity 0.15s,
    box-shadow 0.15s;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.24);
}
.btn:active:not(:disabled) {
  transform: translateY(1px);
}
.btn:disabled,
.btn.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn-primary {
  background: linear-gradient(180deg, #e3c35a, #b8922a);
  border-color: #f1d27a;
  color: #1a1403;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.25);
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
}
.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #f1d27a, #c9a235);
  border-color: #fff0b3;
}
.btn-secondary {
  background: linear-gradient(180deg, #2f8f78, #1f6b58);
  border-color: var(--teal-2);
}
.btn-ghost {
  background: transparent;
}
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}
.btn-xs {
  padding: 2px 8px;
  font-size: 12px;
}
.btn-lg {
  padding: 12px 22px;
  font-size: 16px;
}
.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 14px;
}

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--muted);
}
.pill-waiting {
  color: var(--teal-2);
  background: rgba(78, 204, 163, 0.12);
}
.pill-in_progress {
  color: var(--gold-2);
  background: rgba(212, 175, 55, 0.14);
}
.pill-finished {
  color: var(--muted);
}

.form-error {
  color: var(--red-2);
  font-size: 13px;
  margin: 8px 0 0;
}

.card-code {
  font-weight: 700;
  padding: 0 3px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.9);
  color: #111;
  font-size: 0.92em;
}
.card-code.red {
  color: #c62828;
}

/* ---- login ---- */
.login-panel {
  width: min(420px, 100%);
  padding: 32px 30px 28px;
  text-align: center;
}
.login-form {
  margin-top: 24px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-form .btn {
  margin-top: 6px;
}

/* ---- lobby ---- */
.lobby-panel {
  width: min(760px, 100%);
  max-height: calc(100% - 16px);
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
  gap: 18px;
  overflow: hidden;
}
.lobby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.lobby-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lobby-section.grow {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.create-form {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-top: 10px;
}
.create-form .field.grow {
  flex: 1 1 200px;
}
.room-list {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: 46vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
}
.room-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.room-row:hover {
  background: rgba(255, 255, 255, 0.07);
}
.room-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-meta {
  display: flex;
  gap: 6px;
}
.empty {
  padding: 24px;
  text-align: center;
}

/* ---- waiting room ---- */
.waiting-panel {
  width: min(520px, 100%);
  padding: 20px 22px;
}
.player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 14px 0 10px;
}
.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
}
.player-row.me {
  border: 1px solid rgba(212, 175, 55, 0.35);
}
.player-row.empty {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.1);
}
.player-row .tag {
  font-size: 14px;
}
.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  flex: 0 0 auto;
}
.dot.on {
  background: var(--teal-2);
  box-shadow: 0 0 8px rgba(78, 204, 163, 0.8);
}
.dot.off {
  background: var(--red);
}
.conn-badge {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(214, 69, 69, 0.18);
  color: var(--red-2);
}
.conn-badge.ok {
  background: rgba(78, 204, 163, 0.14);
  color: var(--teal-2);
}
.hint {
  font-size: 13px;
}

/* ---- HUD ---- */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.hud-panel {
  position: absolute;
  pointer-events: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px) saturate(1.2);
  -webkit-backdrop-filter: blur(12px) saturate(1.2);
  padding: 10px 14px;
}

.hud-info {
  top: 12px;
  left: 12px;
  min-width: 220px;
  max-width: 320px;
}
.hud-room {
  font-weight: 700;
  color: var(--gold-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hud-info-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 4px;
  font-size: 14px;
}
.hud-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.hud-trump {
  font-size: 26px;
  line-height: 1;
  font-weight: 700;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
  color: #111;
}
.hud-trump.red {
  color: #c62828;
}
.hud-deck-count {
  font-weight: 700;
  color: var(--gold-2);
}
.hud-conn {
  margin-top: 6px;
  font-size: 12px;
  color: var(--red-2);
}

.hud-leave {
  left: 12px;
  top: 96px;
  padding: 4px;
  opacity: 0.85;
}
.leave-icon {
  display: none;
}

/* actions + spells (bottom-right) */
.hud-actions {
  right: 12px;
  bottom: 12px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hud-status {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.3;
  min-height: 18px;
}
.hud-status.active {
  color: var(--gold-2);
  font-weight: 600;
}
.action-row {
  display: flex;
  gap: 8px;
}
.btn-action {
  flex: 1 1 0;
  padding: 11px 10px;
  font-size: 16px;
  letter-spacing: 0.02em;
}
.btn-pass:not(:disabled) {
  background: linear-gradient(180deg, #2f8f78, #1f6b58);
  border-color: var(--teal-2);
  box-shadow: 0 4px 14px rgba(46, 165, 138, 0.35);
}
.btn-take:not(:disabled) {
  background: linear-gradient(180deg, #c44d4d, #8f2c2c);
  border-color: var(--red-2);
  box-shadow: 0 4px 14px rgba(214, 69, 69, 0.35);
}

.mana-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.mana-pips {
  display: flex;
  gap: 3px;
}
.pip {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(120, 160, 255, 0.25);
}
.pip.on {
  background: radial-gradient(circle at 35% 35%, #9fc3ff, #3b7bff 70%);
  border-color: #9fc3ff;
  box-shadow: 0 0 6px rgba(80, 140, 255, 0.7);
}
.mana-text {
  color: #9fc3ff;
  font-weight: 700;
}
.hp-text {
  margin-left: auto;
  color: var(--red-2);
  font-weight: 600;
}

.spell-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.spell-btn {
  flex-direction: column;
  gap: 2px;
  padding: 7px 4px;
  position: relative;
  font-size: 11.5px;
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.1);
}
.spell-icon {
  font-size: 20px;
  line-height: 1.1;
}
.spell-cost {
  position: absolute;
  top: 3px;
  right: 4px;
  min-width: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #2b57b8;
  color: #fff;
  font-size: 10px;
  line-height: 16px;
}
.spell-fireball:not(:disabled) {
  background: linear-gradient(
    180deg,
    rgba(255, 120, 50, 0.35),
    rgba(160, 40, 20, 0.35)
  );
}
.spell-heal:not(:disabled) {
  background: linear-gradient(
    180deg,
    rgba(80, 220, 120, 0.3),
    rgba(20, 120, 60, 0.3)
  );
}
.spell-shield:not(:disabled) {
  background: linear-gradient(
    180deg,
    rgba(120, 170, 255, 0.3),
    rgba(40, 80, 170, 0.3)
  );
}
.spell-hex:not(:disabled) {
  background: linear-gradient(
    180deg,
    rgba(190, 110, 255, 0.3),
    rgba(90, 30, 150, 0.3)
  );
}

.spell-picker {
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  padding: 8px;
}
.picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.picker-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 160px;
  overflow-y: auto;
}
.picker-target {
  justify-content: space-between;
  padding: 7px 10px;
  font-weight: 500;
}

/* log + chat (top-right) */
.hud-log-wrap {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  pointer-events: none;
}
.log-toggle {
  pointer-events: auto;
  background: var(--panel);
  border-color: var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.log-toggle.active {
  color: var(--gold-2);
}
.hud-log {
  position: absolute;
  right: 0;
  top: 46px;
  width: 280px;
  height: min(40vh, 320px);
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  gap: 6px;
}
.log-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.log-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.35;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding-right: 2px;
}
.log-line {
  padding: 2px 4px;
  border-radius: 4px;
}
.log-line.strong {
  font-weight: 700;
  color: var(--gold-2);
}
.log-line.round {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed rgba(255, 255, 255, 0.12);
  color: var(--gold-2);
}
.log-line.damage {
  color: var(--red-2);
}
.log-line.heal {
  color: #7ee2a8;
}
.log-line.shield {
  color: #9fc3ff;
}
.log-line.spell {
  color: #e0b4ff;
}
.log-line.chat {
  background: rgba(255, 255, 255, 0.05);
}
.log-line.chat.mine {
  background: rgba(212, 175, 55, 0.12);
}
.chat-nick {
  font-weight: 700;
  color: var(--teal-2);
}
.chat-row {
  display: flex;
  gap: 6px;
}
.input-chat {
  padding: 7px 10px;
  font-size: 13px;
}

/* ---- toasts ---- */
.toast-stack {
  position: absolute;
  top: 150px;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  pointer-events: none;
  z-index: 50;
  max-width: min(90vw, 480px);
}
.toast {
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(10, 30, 24, 0.85);
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(-8px);
  transition:
    opacity 0.25s,
    transform 0.25s;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
.toast.hide {
  opacity: 0;
  transform: translateY(-8px);
}
.toast-error {
  background: rgba(120, 25, 25, 0.9);
  border-color: var(--red-2);
}
.toast-success {
  border-color: var(--teal-2);
}
.toast-spell {
  border-color: #e0b4ff;
}

/* ---- modal / game over ---- */
.modal-backdrop {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: auto;
  z-index: 40;
  padding: 16px;
}
.modal {
  width: min(420px, 100%);
  padding: 28px 26px;
  text-align: center;
  background: var(--panel-2);
}
.gameover-title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.03em;
}
.gameover-win .gameover-title {
  color: var(--gold-2);
  text-shadow: 0 0 24px rgba(212, 175, 55, 0.6);
}
.gameover-lose .gameover-title {
  color: var(--red-2);
}
.gameover-reason {
  color: var(--muted);
  margin-top: 6px;
}
.result-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 18px 0 22px;
}
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

/* ---- responsive ---- */
@media (max-width: 900px) {
  .hud-log {
    width: min(300px, calc(100vw - 24px));
    height: min(38vh, 300px);
  }
}
/* Phones and any portrait viewport: compact top bar, action bar docked at the bottom. */
@media (max-width: 700px), (max-aspect-ratio: 1/1) {
  #ui {
    font-size: 14px;
  }
  .hud-leave {
    top: 8px;
    left: 8px;
    padding: 0;
    opacity: 1;
  }
  .btn-leave {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    font-size: 16px;
  }
  .leave-text {
    display: none;
  }
  .leave-icon {
    display: inline;
  }
  .hud-info {
    top: 8px;
    left: 50px;
    height: 36px;
    min-width: 0;
    max-width: calc(100vw - 150px);
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .hud-room {
    display: none;
  }
  .hud-info-row {
    margin-top: 0;
    gap: 10px;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .hud-trump {
    font-size: 18px;
    padding: 0 4px;
  }
  /* The trump badge speaks for itself; keep the row on one line. */
  .hud-stat[title="Козырь"] .muted {
    display: none;
  }
  .hud-conn {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    white-space: nowrap;
  }
  .hud-log-wrap {
    top: 8px;
    right: 8px;
  }
  .log-toggle {
    height: 36px;
  }
  .hud-log {
    position: fixed;
    top: 50px;
    left: 8px;
    right: 8px;
    width: auto;
    height: min(52vh, 360px);
  }
  .hud-actions {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    padding: 6px 10px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 5px;
    border-radius: 14px 14px 0 0;
    border-bottom: none;
  }
  .hud-status {
    font-size: 12.5px;
    min-height: 16px;
    text-align: center;
  }
  .action-row {
    align-items: center;
  }
  .btn-action {
    padding: 8px 6px;
    font-size: 14px;
  }
  .mana-row {
    font-size: 12px;
  }
  .pip {
    width: 10px;
    height: 10px;
  }
  .spell-title {
    display: none;
  }
  .spell-btn {
    padding: 4px 2px;
    min-height: 36px;
  }
  .spell-icon {
    font-size: 18px;
  }
  .spell-picker {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: calc(100% + 6px);
    background: rgba(8, 28, 22, 0.96);
    box-shadow: var(--shadow);
  }
  .toast-stack {
    top: 50px;
    left: 8px;
    max-width: calc(100vw - 16px);
  }
  .toast {
    font-size: 13px;
    padding: 6px 12px;
  }
  .lobby-panel,
  .waiting-panel,
  .login-panel {
    padding: 16px 14px;
  }
  .room-row {
    grid-template-columns: 1fr auto;
  }
  .room-row .room-meta {
    grid-column: 1 / -1;
  }
}
