:root {
  --felt: #17644f;
  --felt-dark: #0b3f34;
  --felt-line: rgba(255, 255, 255, 0.12);
  --paper: #fff9ed;
  --ink: #17211f;
  --muted: #d7eadf;
  --gold: #ffd166;
  --mint: #66f0c2;
  --danger: #dd3f5b;
  --shadow: 0 18px 42px rgba(2, 19, 16, 0.34);
  --radius: 8px;
  --card-width: 92px;
  --card-height: calc(var(--card-width) * 1.4);
  --stack-gap: 24px;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: #f7fbf8;
  background:
    linear-gradient(115deg, rgba(255, 209, 102, 0.12), transparent 32%),
    linear-gradient(225deg, rgba(102, 240, 194, 0.12), transparent 30%),
    linear-gradient(180deg, #12352f 0%, #08231f 100%);
  font-family: Inter, "Apple SD Gothic Neo", "Malgun Gothic", Arial, sans-serif;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

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

.screen {
  min-height: 100vh;
  display: none;
}

.screen.is-active {
  display: block;
}

.menu-screen {
  place-items: center;
  padding: 28px;
}

.menu-screen.is-active {
  display: grid;
}

.menu-panel {
  width: min(680px, 100%);
  padding: clamp(28px, 6vw, 54px);
  border: 1px solid var(--felt-line);
  border-radius: var(--radius);
  background: rgba(11, 63, 52, 0.8);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--mint);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: var(--paper);
  font-size: clamp(2.45rem, 10vw, 5rem);
  line-height: 0.95;
}

h2 {
  color: var(--paper);
  font-size: clamp(1.8rem, 5vw, 3rem);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 32px;
}

.difficulty-button,
.control-button {
  min-height: 54px;
  border: 0;
  border-radius: var(--radius);
  color: #08231f;
  background: var(--gold);
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.difficulty-button {
  display: grid;
  gap: 3px;
  padding: 16px 12px;
  text-align: left;
}

.difficulty-button span {
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  font-weight: 900;
}

.difficulty-button small {
  color: rgba(8, 35, 31, 0.72);
  font-weight: 800;
}

.difficulty-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  line-height: 1.2;
}

.difficulty-button .difficulty-meta > span:first-child {
  font-size: 0.82rem;
}

.suit-pattern {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}

.pattern-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.16);
}

.pattern-dot.is-black {
  background: #111615;
}

.pattern-dot.is-red {
  background: #dd3f5b;
}

.difficulty-button:hover,
.control-button:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.04);
}

.control-button:disabled {
  cursor: default;
  opacity: 0.45;
}

.ghost-button {
  color: var(--paper);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid var(--felt-line);
}

.game-screen {
  position: relative;
  width: min(1280px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
}

.stats {
  display: flex;
  gap: 10px;
}

.header-actions {
  display: flex;
  align-items: end;
  gap: 10px;
}

.sound-toggles {
  display: flex;
  gap: 8px;
}

.sound-toggle {
  min-width: 82px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid rgba(102, 240, 194, 0.34);
  border-radius: var(--radius);
  color: var(--paper);
  background: rgba(102, 240, 194, 0.16);
  font-weight: 900;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
}

.sound-toggle:hover {
  border-color: var(--mint);
  background: rgba(102, 240, 194, 0.24);
}

.sound-toggle.is-off {
  color: var(--muted);
  border-color: var(--felt-line);
  background: rgba(255, 255, 255, 0.08);
}

.stats div {
  min-width: 112px;
  padding: 11px 13px;
  border: 1px solid var(--felt-line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}

.stats span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.stats strong {
  display: block;
  margin-top: 4px;
  color: var(--paper);
  font-size: 1.3rem;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.play-table {
  height: min(70vh, 760px);
  min-height: 520px;
  padding: clamp(12px, 2vw, 20px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, transparent 0 48%, rgba(255, 255, 255, 0.035) 48% 52%, transparent 52%),
    linear-gradient(0deg, transparent 0 48%, rgba(255, 255, 255, 0.03) 48% 52%, transparent 52%),
    var(--felt);
  background-size: 42px 42px;
  box-shadow: var(--shadow);
}

.tableau-area {
  display: grid;
  gap: 12px;
}

.tableau-area {
  grid-template-columns: repeat(var(--tableau-columns), minmax(76px, 1fr));
  align-items: start;
  height: 100%;
}

.tableau-column {
  min-width: 0;
  border-radius: var(--radius);
}

.tableau-column {
  min-height: 180px;
  padding: 8px;
  cursor: pointer;
}

.column-cards {
  display: grid;
  gap: 0;
  justify-items: center;
}

.empty-column {
  width: min(100%, var(--card-width));
  aspect-ratio: 2.5 / 3.5;
  display: grid;
  place-items: center;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  color: rgba(255, 255, 255, 0.32);
  font-weight: 900;
}

.card-button {
  position: relative;
  width: min(100%, var(--card-width));
  aspect-ratio: 2.5 / 3.5;
  overflow: hidden;
  border: 0;
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transform-origin: center;
  transition: transform 140ms ease, box-shadow 140ms ease, outline-color 140ms ease;
}

.card-back {
  width: min(100%, var(--card-width));
  aspect-ratio: 2.5 / 3.5;
  border-radius: var(--radius);
  border: 2px solid rgba(255, 249, 237, 0.72);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(225deg, rgba(255, 255, 255, 0.16) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(135deg, #245c9f, #17335f);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
}

.card-button.is-stacked,
.card-back.is-stacked {
  margin-top: calc((var(--card-height) - var(--stack-gap)) * -1);
}

.card-button:hover:not(.is-locked) {
  transform: translateY(-2px);
}

.card-button.is-locked {
  cursor: default;
}

.card-button.is-dragging-source {
  opacity: 0.35;
}

.drag-stack-ghost {
  position: fixed;
  z-index: 30;
  width: var(--card-width);
  margin-top: 0 !important;
  pointer-events: none;
}

.drag-ghost-card {
  width: var(--card-width);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.32);
}

.card-button.is-selected {
  outline: 4px solid var(--mint);
  box-shadow: 0 0 0 5px rgba(102, 240, 194, 0.22), 0 13px 24px rgba(0, 0, 0, 0.22);
}

.card-button.is-red {
  color: var(--danger);
}

.card-media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
}

.card-button.is-image-ready .card-media {
  opacity: 1;
}

.card-button.is-image-ready .card-text {
  opacity: 0;
}

.card-text {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: 24px 1fr 24px;
  padding: 8px 9px;
  font-weight: 900;
}

.card-corner {
  display: flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  justify-self: start;
  align-self: start;
  font-size: clamp(0.78rem, 1.5vw, 1rem);
  line-height: 0.92;
}

.card-corner:last-child {
  align-items: flex-start;
  justify-self: end;
  align-self: end;
  transform: rotate(180deg);
}

.card-center {
  display: grid;
  place-items: center;
  align-self: center;
  font-size: clamp(1.45rem, 3.1vw, 2.25rem);
  line-height: 1;
}

.card-button.is-diamond .card-corner span:last-child {
  font-size: 1.16em;
  line-height: 0.86;
}

.card-button.is-diamond .card-center {
  font-size: clamp(1.8rem, 3.8vw, 2.75rem);
}

.clear-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 20, 17, 0.72);
  pointer-events: auto;
}

.clear-panel {
  position: relative;
  z-index: 101;
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(11, 63, 52, 0.96);
  box-shadow: var(--shadow);
  text-align: center;
}

.clear-panel p {
  margin: 0 0 22px;
  color: var(--gold);
  font-size: clamp(3rem, 16vw, 5.8rem);
  font-weight: 1000;
  letter-spacing: 0;
  line-height: 0.9;
}

.clear-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

@media (max-width: 760px) {
  :root {
    --card-width: 108px;
    --stack-gap: 28px;
  }

  .difficulty-grid,
  .controls,
  .clear-actions {
    grid-template-columns: 1fr;
  }

  .game-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .sound-toggles {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats div {
    min-width: 0;
  }

  .tableau-area {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .card-button,
  .card-back,
  .empty-column {
    width: min(100%, var(--card-width));
  }

}

@media (max-width: 420px) {
  .game-screen {
    width: min(100% - 18px, 1280px);
  }

  .play-table {
    padding: 9px;
  }

  .tableau-area {
    gap: 9px;
  }

  .card-text {
    padding: 7px;
  }
}
