* {
  box-sizing: border-box;
}

:root {
  --bg: #080808;
  --panel: #111;
  --panel2: #171717;
  --red: #d20b12;
  --bright-red: #ff2028;
  --dark-red: #5e080b;
  --line: #4a181a;
  --text: #f1eeee;
  --muted: #9b9292;
  --gold: #c99e3d;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", "Yu Mincho", serif;
  background:
    radial-gradient(circle at 50% -10%, #3b090c 0, transparent 35%),
    linear-gradient(135deg, #050505 0%, #120607 48%, #050505 100%);
  color: var(--text);
}

body::before {
  content: "♠     ♦     ♣     ♥";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.035;
  font-size: 18vw;
  letter-spacing: 5vw;
  transform: rotate(-12deg) translate(-5%, 20%);
  white-space: nowrap;
}

.app {
  width: min(1150px, 94vw);
  margin: 26px auto 48px;
  position: relative;
}

.app::before {
  content: "";
  display: block;
  height: 1px;
  margin-bottom: 20px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--dark-red),
    var(--red),
    var(--dark-red),
    transparent
  );
  opacity: 0.8;
}

h1 {
  text-align: center;
  letter-spacing: 0.18em;
  font-size: clamp(36px, 6vw, 64px);
  margin: 0 0 4px;
  color: #fff;
  text-shadow: 0 0 16px #d20b12;
}

.topbar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 17px;
  flex-wrap: nowrap;
  width: fit-content;
  margin: 20px auto;
  padding: 8px 10px;

  max-width: 1050px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(9, 9, 9, 0.76);
  box-shadow:
    0 8px 25px #000,
    inset 0 0 18px rgba(100, 0, 0, 0.12);
}

.topbar .round-button {
  margin-left: 30px;
}

.setting {
  display: contents;
}

.setting label {
  font-size: 15px;
  color: #c4b5b5;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.unit {
  font:
    12px system-ui,
    sans-serif;
  color: #a88c8c;
  margin-left: -4px;
}

button,
input {
  font: inherit;
  height: 48px;
  border: 1px solid #5a2022;
  border-radius: 7px;
}

button {
  padding: 0 22px;
  cursor: pointer;
  color: white;
  background: linear-gradient(#c9141a, #72080c);
  box-shadow:
    inset 0 1px #ff6267,
    0 4px 14px #000;
  font-weight: 700;
}

button:hover:not(:disabled) {
  background: linear-gradient(#ed1a22, #930b10);
  box-shadow:
    inset 0 1px #ff8588,
    0 0 16px #a50d12;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.number-input {
  width: 105px;
  padding: 0 14px;
  color: white;
  background: #090909;
  outline: none;
  text-align: center;
}

input:focus {
  border-color: var(--bright-red);
  box-shadow: 0 0 10px #8c0c11;
}

.reset-button {
  background: linear-gradient(#6c1216, #3f080b);
}

.round-info {
  text-align: center;
  margin: 14px auto 28px;
  min-height: 54px;
  width: 260px;
  padding: 15px 20px;
  border: 1px solid #67181b;
  border-radius: 50%;
  background: radial-gradient(circle, #3c080b 0%, #100505 65%);
  box-shadow:
    0 0 30px #43090c,
    inset 0 0 25px #000;
  color: #c8b3b3;
  letter-spacing: 0.08em;
}

.round-info strong {
  color: #fff;
  font-size: 26px;
  text-shadow: 0 0 12px #ff3036;
}

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

.team {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #1a090a, #090909);
  border: 1px solid #7c171b;
  border-radius: 9px;
  padding: 10px;
  box-shadow:
    0 10px 25px #000,
    inset 0 0 20px #260708;
  transition: 0.18s;
}

.team::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(
      135deg,
      transparent 0 49%,
      rgba(210, 11, 18, 0.05) 50%,
      transparent 51%
    ),
    linear-gradient(
      45deg,
      transparent 0 49%,
      rgba(255, 255, 255, 0.025) 50%,
      transparent 51%
    );
}

.team-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 2px 6px 7px;
}

.team-name {
  font-size: 19px;
  letter-spacing: 0.16em;
  color: #eee;
}

.team-value {
  font-size: 42px;
  line-height: 1;
  font-weight: 700;
  color: white;
  text-shadow: 0 0 14px #ff3036;
}

.meter {
  position: relative;
  height: 28px;
  margin: 22px 8px 13px;
  border: 1px solid #7b383b;
  border-radius: 2px;
  background: #080808;
  box-shadow: inset 0 0 10px #000;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: 1px;
  background: linear-gradient(90deg, #65090d, #d20b12);
  transition:
    width 0.3s,
    background 0.2s;
  box-shadow:
    inset 0 0 12px #ff5258,
    0 0 9px #71080c;
}

.target-line {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 3px;
  background: #fff;
  box-shadow: 0 0 10px #fff;
}

.target-label {
  position: absolute;
  top: -22px;
  right: -1px;
  transform: translateX(50%);
  font:
    10px system-ui,
    sans-serif;
  letter-spacing: 0.08em;
  color: #a88c8c;
  white-space: nowrap;
}

.status {
  height: 27px;
  text-align: center;
  font:
    13px system-ui,
    sans-serif;
  color: #cdbebe;
  letter-spacing: 0.08em;
}

.live-score {
  text-align: center;
  min-height: 30px;
  margin-top: 1px;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}

.live-score span {
  color: #ffb9bb;
  text-shadow: 0 0 8px #d20b12;
}

.input-area {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 13px;
}

.value-input {
  min-width: 0;
  padding: 0 14px;
  color: white;
  background: #090909;
  outline: none;
}

.add-button {
  min-width: 105px;
}

.team.blackjack {
  border-color: #9e7d24;
  box-shadow:
    0 10px 25px #000,
    inset 0 0 20px #352a0d,
    0 0 14px rgba(201, 158, 61, 0.12);
}

.team.blackjack .meter-fill {
  background: linear-gradient(90deg, #725212, #d7b34f);
  box-shadow:
    inset 0 0 12px #ffe58a,
    0 0 10px #977426;
}

.team.blackjack .status,
.team.blackjack .live-score {
  color: #e6c96d;
}

.team.bust {
  border-color: #d20b12;
  background:
    radial-gradient(circle at 50% 45%, rgba(165, 0, 0, 0.22), transparent 47%),
    linear-gradient(145deg, #250708, #080808);
  box-shadow:
    0 10px 25px #000,
    inset 0 0 26px rgba(170, 0, 0, 0.18),
    0 0 22px rgba(210, 11, 18, 0.28);
  animation: fatalPulse 0.75s ease-in-out infinite alternate;
}

.team.bust::after {
  content: "BUST";
  position: absolute;
  top: 13px;
  right: -37px;
  padding: 4px 42px;
  background: linear-gradient(#e21a22, #8c080d);
  color: white;
  font:
    900 11px system-ui,
    sans-serif;
  letter-spacing: 0.18em;
  transform: rotate(45deg);
  box-shadow: 0 0 14px rgba(210, 11, 18, 0.45);
}

.team.bust .meter-fill {
  background: linear-gradient(90deg, #4d0508, #f01820);
  box-shadow:
    inset 0 0 13px #ff6a70,
    0 0 12px #a50d12;
}

.team.bust .status,
.team.bust .live-score {
  color: #ff5b60;
  text-shadow: 0 0 10px rgba(255, 20, 28, 0.45);
}

@keyframes fatalPulse {
  from {
    box-shadow:
      0 10px 25px #000,
      inset 0 0 22px rgba(170, 0, 0, 0.13),
      0 0 16px rgba(210, 11, 18, 0.18);
  }
  to {
    box-shadow:
      0 10px 25px #000,
      inset 0 0 34px rgba(210, 0, 0, 0.22),
      0 0 30px rgba(255, 15, 22, 0.4);
  }
}

.scoreboard {
  margin-top: 22px;
  padding: 13px 16px 16px;
  background: #0b0b0b;
  border: 1px solid #381719;
  border-radius: 8px;
  box-shadow:
    0 10px 25px #000,
    inset 0 0 16px rgba(90, 0, 0, 0.08);
}

.scoreboard h2 {
  margin: 0 0 12px;
  font-size: 19px;
  letter-spacing: 0.15em;
  font-weight: 700;
  color: #eee;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.score-card {
  padding: 11px;
  border: 1px solid #492022;
  border-radius: 6px;
  background: #151010;
  text-align: center;
  box-shadow: inset 0 0 12px rgba(80, 0, 0, 0.08);
}

.score-card .name {
  font-size: 13px;
  color: #a88c8c;
  letter-spacing: 0.12em;
}

.score-card .total {
  margin-top: 4px;
  font-size: 26px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 9px #d20b12;
}

.history {
  margin-top: 16px;
  overflow-x: auto;
}

.history table {
  width: 100%;
  border-collapse: collapse;
  min-width: 650px;
}

.history th,
.history td {
  padding: 8px 10px;
  border-bottom: 1px solid #2f1719;
  text-align: center;
}

.history th {
  font:
    12px system-ui,
    sans-serif;
  letter-spacing: 0.08em;
  color: #a88c8c;
}

.history td {
  font-size: 14px;
}

.bust-text {
  color: #ff5b60;
  text-shadow: 0 0 8px #8d0a0e;
}

.blackjack-text {
  color: #e4c467;
  text-shadow: 0 0 8px rgba(201, 158, 61, 0.25);
}

.note {
  margin-top: 10px;
  color: #776a6a;
  font:
    11px system-ui,
    sans-serif;
  text-align: center;
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr 1fr;
  }

  .setting {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 7px;
  }

  .topbar > .round-button,
  .topbar > .reset-button {
    width: 100%;
  }

  .teams {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app {
    width: min(500px, 94vw);
  }

  .topbar {
    grid-template-columns: 1fr;
  }

  .setting {
    display: grid;
    grid-template-columns: auto 1fr auto;
  }

  .score-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .team-value {
    font-size: 38px;
  }
}
