:root {
  --green-900: #063d27;
  --green-800: #07502f;
  --green-700: #0b6039;
  --green-500: #178b54;
  --cream: #fffaf0;
  --gold: #d7ad4f;
  --red: #b5222a;
  --shadow: 0 12px 35px rgba(0, 0, 0, .25);
  --card-width: clamp(68px, 7.4vw, 102px);
  --card-height: calc(var(--card-width) * 1.42);
  font-family: Arial, Helvetica, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -20%, rgba(255,255,255,.13), transparent 38%),
    linear-gradient(145deg, var(--green-700), var(--green-900));
  color: white;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 4px solid #ffd56a; outline-offset: 3px; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; }

.topbar {
  min-height: 70px;
  padding: 10px clamp(14px, 3vw, 34px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: rgba(3, 37, 23, .88);
  border-bottom: 1px solid rgba(255,255,255,.14);
  position: relative;
  z-index: 20;
}

.brand-button {
  border: 0;
  background: transparent;
  color: white;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 700;
}
.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #2e2310;
  background: linear-gradient(145deg, #f3d98e, var(--gold));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.6);
}

.player-chip {
  min-width: 190px;
  padding: 8px 14px;
  border-radius: 12px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.16);
  text-align: right;
  cursor: pointer;
}
.player-chip .player-label { display: block; font-size: 13px; opacity: .75; }
.player-chip strong { font-size: 18px; }

.screen { min-height: calc(100vh - 70px); }

.home-screen {
  padding: 30px 16px;
  display: grid;
  place-items: center;
}

.hero-card {
  width: min(600px, 100%);
  padding: clamp(28px, 5vw, 50px);
  text-align: center;
  border-radius: 24px;
  color: #1d241f;
  background: rgba(255, 250, 240, .97);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255,255,255,.7);
}
.hero-symbol {
  margin: 0 auto 12px;
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-size: 62px;
  color: var(--green-900);
  background: linear-gradient(145deg, #f6dda1, var(--gold));
  box-shadow: 0 8px 20px rgba(95,70,19,.22);
}
.hero-card h1 { margin: 8px 0; font-size: clamp(34px, 6vw, 52px); }
.hero-card p { margin: 0 0 28px; font-size: clamp(20px, 3vw, 26px); }

.home-actions, .modal-actions { display: grid; gap: 12px; }
.big-button, .difficulty-button, .toolbar-button, .modal-close {
  border: 0;
  border-radius: 13px;
  min-height: 56px;
  padding: 13px 20px;
  color: #17201a;
  background: #eef0ec;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.08);
  font-size: 20px;
  font-weight: 700;
}
.big-button:hover, .difficulty-button:hover, .toolbar-button:hover, .modal-close:hover { filter: brightness(.96); }
.big-button.primary { background: var(--green-700); color: white; }
.big-button.install { background: #d9b55a; color: #2a210d; }
.big-button.danger { background: #a9262d; color: white; }
.big-button:disabled { opacity: .48; cursor: not-allowed; }
.text-button { border: 0; background: transparent; text-decoration: underline; font-size: 18px; color: #33453b; padding: 12px; }

.game-screen { padding: 0 0 24px; }
.game-toolbar {
  padding: 12px clamp(10px, 2vw, 24px);
  background: rgba(5, 56, 34, .86);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  position: sticky;
  top: 0;
  z-index: 15;
  box-shadow: 0 5px 16px rgba(0,0,0,.18);
}
.game-info { display: flex; flex-wrap: wrap; gap: clamp(10px, 2vw, 26px); }
.game-info div { min-width: 72px; }
.game-info span { display: block; opacity: .75; font-size: 13px; }
.game-info strong { font-size: clamp(18px, 2vw, 24px); }
.toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.toolbar-button { min-height: 46px; padding: 9px 14px; font-size: 16px; }
.toolbar-button:disabled { opacity: .45; cursor: not-allowed; }

.message-bar {
  width: min(760px, calc(100% - 24px));
  margin: 12px auto 0;
  padding: 12px 18px;
  text-align: center;
  border-radius: 12px;
  background: #fff4c8;
  color: #3d3115;
  font-weight: 700;
  box-shadow: 0 5px 18px rgba(0,0,0,.16);
  position: relative;
  z-index: 14;
}

.table-wrap { padding: 18px clamp(6px, 1vw, 14px); min-width: 760px; }
.tableau {
  min-height: 520px;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(3px, .7vw, 10px);
  align-items: start;
}
.column {
  min-height: 430px;
  position: relative;
  border-radius: 8px;
  background: rgba(255,255,255,.035);
  border: 1px dashed rgba(255,255,255,.09);
}
.column.drop-target { background: rgba(255, 220, 115, .18); border-color: #ffd86d; }
.column.empty::after {
  content: "♠";
  position: absolute;
  inset: 12px;
  height: var(--card-height);
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 2px dashed rgba(255,255,255,.23);
  color: rgba(255,255,255,.2);
  font-size: 44px;
}

.card {
  width: calc(100% - 4px);
  max-width: var(--card-width);
  height: var(--card-height);
  position: absolute;
  left: 2px;
  border-radius: 9px;
  background: linear-gradient(150deg, #fffef9, #eee9df);
  color: #111;
  border: 1px solid rgba(0,0,0,.28);
  box-shadow: 0 3px 7px rgba(0,0,0,.26);
  user-select: none;
  touch-action: none;
  overflow: hidden;
  transition: box-shadow .12s, transform .12s;
}
.card.face-down {
  background:
    linear-gradient(45deg, rgba(255,255,255,.1) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.1) 75%),
    linear-gradient(45deg, rgba(255,255,255,.1) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.1) 75%),
    linear-gradient(145deg, #173f72, #0c274d);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px, 0 0;
  border: 3px solid #e4d49d;
}
.card.face-down::after {
  content: "♠";
  position: absolute;
  inset: 7px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.45);
  color: rgba(255,255,255,.8);
  font-size: clamp(26px, 4vw, 42px);
}
.card.selected {
  box-shadow: 0 0 0 4px #ffd568, 0 8px 18px rgba(0,0,0,.4);
  transform: translateY(-3px);
  z-index: 1000 !important;
}
.card.hint-source { animation: hintPulse .75s ease-in-out 3; }
.column.hint-target { animation: targetPulse .75s ease-in-out 3; }
.card.dragging { opacity: .65; }

@keyframes hintPulse {
  0%,100% { box-shadow: 0 3px 7px rgba(0,0,0,.26); }
  50% { box-shadow: 0 0 0 5px #ffe17b, 0 10px 24px rgba(0,0,0,.45); }
}
@keyframes targetPulse {
  0%,100% { background: rgba(255,255,255,.035); }
  50% { background: rgba(255,225,120,.32); }
}

.card-corner {
  position: absolute;
  left: 7px;
  top: 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: .9;
  font-weight: 700;
  font-size: clamp(17px, 2vw, 25px);
}
.card-suit { font-size: .88em; margin-top: 3px; }
.card-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: clamp(34px, 5vw, 58px);
  opacity: .92;
}
.red { color: #b11320; }
.black { color: #111; }

.bottom-area {
  min-height: 145px;
  margin-top: 18px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 0 18px;
}
.completed-area { display: flex; gap: 7px; min-height: 105px; align-items: end; }
.completed-card {
  width: 58px;
  height: 82px;
  border-radius: 8px;
  border: 2px solid #e6d79d;
  background: linear-gradient(145deg, #173f72, #0c274d);
  display: grid;
  place-items: center;
  font-size: 35px;
  box-shadow: 0 4px 10px rgba(0,0,0,.28);
}
.stock-button {
  border: 0;
  background: transparent;
  color: white;
  min-width: 110px;
  display: grid;
  justify-items: center;
  gap: 7px;
  font-weight: 700;
}
.stock-card-back {
  width: 74px;
  height: 104px;
  border-radius: 9px;
  border: 3px solid #e4d49d;
  background:
    linear-gradient(45deg, rgba(255,255,255,.1) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.1) 75%),
    linear-gradient(45deg, rgba(255,255,255,.1) 25%, transparent 25%, transparent 75%, rgba(255,255,255,.1) 75%),
    linear-gradient(145deg, #173f72, #0c274d);
  background-size: 14px 14px;
  background-position: 0 0, 7px 7px, 0 0;
  display: grid;
  place-items: center;
  font-size: 42px;
  box-shadow: 0 5px 14px rgba(0,0,0,.3);
}
.stock-button:disabled { opacity: .38; cursor: not-allowed; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0,0,0,.62);
  backdrop-filter: blur(3px);
}
.modal {
  position: fixed;
  z-index: 100;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, calc(100% - 28px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 28px;
  color: #172019;
  background: var(--cream);
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,.42);
}
.modal.wide { width: min(720px, calc(100% - 28px)); }
.modal h2 { margin: 0 0 14px; font-size: 30px; text-align: center; }
.modal > p { font-size: 19px; text-align: center; }
.modal-close { width: 100%; margin-top: 18px; }
.difficulty-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.difficulty-button { display: grid; gap: 5px; min-height: 100px; background: #e5ebe6; }
.difficulty-button strong { font-size: 21px; }
.difficulty-button span { font-weight: 400; }

.players-list { display: grid; gap: 9px; margin: 15px 0 22px; }
.player-row {
  padding: 12px 14px;
  border-radius: 11px;
  background: #e8ede9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.player-row.active { background: #d8eadf; box-shadow: inset 0 0 0 2px var(--green-500); }
.player-row strong { font-size: 20px; }
.player-row button { border: 0; border-radius: 9px; padding: 9px 14px; background: var(--green-700); color: white; font-weight: 700; }
.add-player-form label { display: block; margin-bottom: 8px; font-weight: 700; }
.add-player-form > div { display: flex; gap: 8px; }
.add-player-form input { flex: 1; min-width: 0; padding: 12px; border-radius: 9px; border: 2px solid #bfc9c1; font-size: 18px; }
.add-player-form button { border: 0; border-radius: 9px; padding: 10px 16px; background: var(--green-700); color: white; font-weight: 700; }

.history-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0 20px;
}
.history-summary div { padding: 12px 8px; text-align: center; background: #e8ede9; border-radius: 10px; }
.history-summary span { display: block; font-size: 13px; color: #5a645d; }
.history-summary strong { font-size: 24px; }
.history-list { display: grid; gap: 8px; }
.history-item {
  display: grid;
  grid-template-columns: 1.2fr .8fr .8fr .8fr;
  gap: 8px;
  align-items: center;
  padding: 11px 13px;
  border-radius: 10px;
  background: #edf0ed;
}
.history-item.win { border-left: 5px solid #26834f; }
.history-item.abandoned { border-left: 5px solid #9d6d24; }
.empty-state { padding: 30px; text-align: center; color: #657168; }
.rules-content { font-size: 18px; line-height: 1.45; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.win-symbol { text-align: center; font-size: 76px; }

@media (max-width: 900px) {
  body { overflow-x: auto; }
  .topbar { min-width: 760px; }
  .game-toolbar { min-width: 760px; }
}

@media (max-width: 620px) {
  .difficulty-grid { grid-template-columns: 1fr; }
  .history-summary { grid-template-columns: repeat(2, 1fr); }
  .history-item { grid-template-columns: 1fr 1fr; }
  .add-player-form > div { flex-direction: column; }
}
