html, body {
  margin: 0;
  padding: 0;
}

html {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

#viewport {
  flex: 1;
  /* height: 100svh; */
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

body {
  /* font-family: 'Cormorant Garamond', serif;  */
  font-family: "Noto Sans JP", sans-serif;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;

}

#game-outer {
  width: 100vw;
  height: 100%;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

#game-wrapper {
  /* width: 800px;
  height: 900px; */
  /* transform-origin: top center; */
  width: 100vw;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
}

.game-title {
  margin: 8px 0 4px;
  font-size: 1.4rem;
  color: beige;
}

#game-visual {
  /* transform-origin: top center; */
  width: 100%;
  max-width: 800px;
  padding: 12px;
  box-sizing: border-box;

  background:
  radial-gradient(
    circle at 50% 35%,
    rgba(255,255,255,0.06) 0%,
    rgba(255,255,255,0.03) 25%,
    transparent 55%
  ),
  radial-gradient(
    circle at center,
    #135140 0%,
    #0f3d2e 60%,
    #0b2c22 100%
  );
}


.status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;

  padding: 8px 16px;
  margin-bottom: 8px;

  /* max-width: 420px;
  width: 100%; */

  font-size: 18px;
  font-weight: 600;
  color: #ffffff;

  background: rgba(0,0,0,0.25);
  border-radius: 12px;
}

.hand {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;

  width: 100%;
  max-width: calc(140px * 4 + 8px * 3);
  /*
  max-width: 600px;
  margin: 0 auto;

  align-items: center;
  position: relative;
  gap: 4px;
  overflow: visible; */
}

.hand .the-card {
  width: 75%;
  /* max-width: 94px; */
  justify-self: center;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.hand .the-card:first-child {
  margin-left: 0;
}

.the-card {
  width: 100%;
  aspect-ratio: 2 / 3;
  container-type: inline-size;

  position: relative;
  z-index: calc(10 + var(--index));

  background: none;
  border: none;
  box-shadow: none;

  cursor: pointer;
  user-select: none;

  transform: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  font-family: 'Cinzel', serif;

}

.card-visual {
  position: absolute;
  inset: 0;

  background-image: url("./img/card-vine.png");
  background-size: cover;
  background-repeat: no-repeat;
  background-position: center;

  border-radius: 6px;

  box-shadow:
  1px 1px 0 rgba(0,0,0,0.25),
  3px 3px 6px rgba(0,0,0,0.25);

  width: 100%;
  height: 100%;
  font-size: 55cqw;

  /* transition: transform 0.15s ease, box-shadow 0.15s ease; */

  transition:
  transform 180ms cubic-bezier(.22, 1, .36, 1),
  box-shadow 180ms cubic-bezier(.22, 1, .36, 1);
}

/* .card.lifted .card-visual {
  transform: translateY(-12px);
} */

#hand .the-card.lifted:not(.selected) .card-visual {
  /* transform: translateY(-12px); */
  transform: translateY(-14px) scale(1.02);
  box-shadow: 0 6px 12px rgba(0,0,0,0.25);
}

#hand .the-card.selected .card-visual {
  /* transform: translateY(-20px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.35); */

  transform: translateY(-26px) scale(1.04);
  box-shadow:
    0 10px 25px rgba(0,0,0,0.35),
    0 4px 10px rgba(0,0,0,0.25);
}

@media (hover: hover) {
  /* .card:hover .card-visual {
    transform: translateY(-12px);
  } */
  #hand .the-card:not(.selected):hover .card-visual {
    transform: translateY(-12px);
  }
}

.the-card,
.the-card * {
  pointer-events: auto;
}

.card-number {
  position: absolute;
  inset: 0;

  display: flex;
  align-items:center;
  justify-content: center;

  font-family: 'Cinzel', serif;
  /* font-size: 40px; */
  font-weight: 700;
  color: #2a251f;

  text-shadow:
    1px 1px 0 rgba(0,0,0,0.25);

  pointer-events: none;
}

.card-corner {
  position: absolute;

  font-family: 'Cinzel', serif;
  font-size: 14px;
  font-weight: 600;

  color: #3a332c;
  opacity: 0.9;

  text-shadow:
    0.5px 0.5px 0 rgba(0,0,0,0.3);

  pointer-events: none;
}

.card-number,
.card-corner {
  pointer-events: none;
}

.card-corner.top-left {
  top: 6px;
  left: 8px;
}

.card-corner.bottom-right {
  bottom: 6px;
  right: 8px;
  transform: rotate(180deg);
}

/* .hand .card.selected {
  transform: translateY(-18px) scale(1.05);
  z-index: 10;
  box-shadow: 0 8px 20px rgba(0,0,0,0.35);
} */

/* .card:hover,
.card.lifted {
  transform: translateY(-12px);
} */

.card-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
}

#hand-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  min-height: 260px;
}

.action-bar {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 420px;
  margin-top: 30px;
}

.action-bar button {
  flex: 1;
  padding: 14px 0;
  font-size: 18px;
  border-radius: 12px;
}

#controls {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 8px;

  margin: 12px auto;
}

#controls button {
  padding: 8px 12px;
}

#status {
  max-width: 100%;
  box-sizing: border-box;
  padding: 8px;
  word-break: break-word;
  text-align: left;
  font-size: 16px;
  margin: 10px 0;
}

#scoreValue {
  font-weight: bold;
}

#piles {
  /* display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px;
  margin: 0 auto 16px auto; */
  display: grid;
  justify-items: center;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

#piles .pile .the-card {
  width: 100%;
  max-width: 94px;
  aspect-ratio: 2 / 3;
}

.pile {
  position: relative;
  width: 100%;
  aspect-ratio: 140 / 240;
  max-width: 140px;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}

.pile.up {
  background-image: url("./img/pile-up.png");
}

.pile.down {
  background-image: url("./img/pile-down.png");
}

.pile-cards {
  position: absolute;

  display: flex;
  align-items: center;
  justify-content: center;

  /* くぼみの位置に合わせて微調整 */
  top: 18%;
  left: 14%;
  width: 70%;
  height: 70%;

  pointer-events: none; /* pile自体をクリックさせるなら */
}

.pile .the-card {
  position: absolute;
  transform: none;

  cursor: default;
  box-shadow:
    1px 1px 4px rgba(0,0,0,0.3);
}

#replay-button-area {
  padding: 4px 8px;
  line-height: 1.2;

  background: #0b2c22;
  color: #fff;
  flex-shrink: 0;
  width: 100%;
  max-width: 800px;
  margin-top: 6px;
  margin-bottom: 12px;
}

#replay-button-area button {
  padding: 4px 8px;
  flex: 1;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

@media (max-aspect-ratio: 3/4) {
  #controls {
    flex-wrap: wrap;
  }

  button {
    /* font-size: 14px; */
  }

  /* .card {
    width: 80px;
    height: 120px;
  }

  .card-number {
    font-size: 40px;
  }

  .card-corner {
    font-size: 14px;
  }

  #controls button {
    min-width: 46%;
  } */

  
}