* {
  box-sizing: border-box;
}

:root {
  --terracotta-surface: radial-gradient(
    circle at 10% 5%,
    #bf7466 0%,
    #944d55 48%,
    #5d303a 100%
  );
}

html,
body,
#game-shell,
#pixiCanvas {
  width: 100%;
  height: 100%;
}

html,
body {
  margin: 0;
  overflow: hidden;
  user-select: none;
  background: #944d55;
}

#pixiCanvas {
  display: block;
  touch-action: none;
}

#scorecard,
#resumeGame,
#unplayedCards,
#revealCards,
#stats,
#fastForward {
  position: fixed;
  width: min(420px, calc(100vw - 32px));
  margin: 0;
  padding: 20px;
  border: 2px solid #6bd66b;
  border-radius: 16px;
  color: #fff;
  background: var(--terracotta-surface);
  box-shadow: 0 10px 30px rgb(0 0 0 / 45%);
}

#scorecard,
#scorecard *,
#resumeGame,
#resumeGame *,
#unplayedCards,
#unplayedCards * {
  color: #fff;
}

#revealCards,
#revealCards * {
  color: #fff;
}

#stats,
#stats *,
#fastForward,
#fastForward * {
  color: #fff;
}

#scorecard::backdrop,
#resumeGame::backdrop,
#unplayedCards::backdrop,
#revealCards::backdrop {
  background: rgb(0 0 0 / 55%);
}

#stats::backdrop {
  background: rgb(0 0 0 / 55%);
}

#fastForward::backdrop {
  background: rgb(0 0 0 / 55%);
}

#scorecard h2,
#scorecard p,
#resumeGame h2,
#resumeGame p,
#unplayedCards h2,
#revealCards h2,
#revealCards p {
  margin: 0 0 14px;
}

#stats h2,
#stats h3,
#fastForward h2 {
  margin: 0 0 10px;
}

#fastForward p {
  margin: 0 0 14px;
}

#stats[open],
#unplayedCards[open] {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 8px);
  overflow: hidden;
}

#stats h2,
#statsAction,
#unplayedCards h2,
#unplayedCardsAction {
  flex: 0 0 auto;
}

#statsContent,
#unplayedCardsHands {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#statsContent {
  overflow-x: hidden;
}

#scorecard table {
  width: 100%;
  margin-bottom: 18px;
  border-collapse: collapse;
}

#scorecard th,
#scorecard td {
  padding: 9px 6px;
  border-bottom: 1px solid rgb(107 214 107 / 45%);
  text-align: right;
}

#scorecard th:first-child {
  text-align: left;
}

#scorecardLastTrick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  font-weight: 700;
}

#scorecardLastTrick[hidden] {
  display: none;
}

#scorecardLastTrickCards {
  display: flex;
  gap: 4px;
}

#scorecardLastTrick .scorecard-last-trick-card {
  width: 30px;
  height: 40px;
  flex: 0 0 30px;
  background-image: url('assets/cards/60x80-en.png');
  background-size: 420px 160px;
}

#scorecardLastTrick.scorecard-last-trick--ru .scorecard-last-trick-card {
  background-image: url('assets/cards/60x80-ru.png');
}

#scorecard button,
#resumeGame button,
#unplayedCards button,
#revealCards button {
  width: 100%;
  padding: 10px;
  border: 1px solid #caf5ce;
  border-radius: 8px;
  color: #fff;
  background: var(--terracotta-surface);
  font:
    700 16px Arial,
    sans-serif;
  cursor: pointer;
}

#stats button,
#fastForward button {
  width: 100%;
  padding: 10px;
  border: 1px solid #caf5ce;
  border-radius: 8px;
  color: #fff;
  background: var(--terracotta-surface);
  font:
    700 16px Arial,
    sans-serif;
  cursor: pointer;
}
.stats-chart {
  margin: 0 0 18px;
}

.resume-game-actions {
  display: grid;
  gap: 10px;
}

.dialog-actions {
  display: grid;
  gap: 10px;
}
.stats-chart canvas {
  display: block;
  max-width: 100%;
  max-height: 180px;
  width: 100%;
}

.stats-chart--points {
  height: 780px;
}

.points-chart-frame,
.points-chart-frame canvas {
  height: 100%;
}

.points-chart-frame {
  height: calc(100% - 34px);
}

.points-chart-frame canvas {
  max-height: none;
}

.unplayed-cards-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
}

#unplayedCards .unplayed-card {
  width: 30px;
  height: 40px;
  flex: 0 0 30px;
  background-image: url('assets/cards/60x80-en.png');
  background-size: 420px 160px;
}

#unplayedCards .unplayed-cards-grid--ru .unplayed-card {
  background-image: url('assets/cards/60x80-ru.png');
}

@media (orientation: portrait) {
  #scorecard.bottom-sheet-dialog,
  #resumeGame.bottom-sheet-dialog,
  #unplayedCards.bottom-sheet-dialog,
  #revealCards.bottom-sheet-dialog,
  #stats.bottom-sheet-dialog,
  #fastForward.bottom-sheet-dialog {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-width: none;
    max-height: 80dvh;
    margin: 0;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 18px 18px 0 0;
  }
}
