:root {
  /* colors */
  --color-highlight: #fff700;
  --color-header: #2e4f6a;
  --color-alt-row: #b8d4e5;
  --color-black: #221e1e;
  --color-button: #1aadc6;
  --color-button-border: #d7cde6;

  /* fonts */
  --font-header: "Audiowide", sans-serif;
  --font-table: "Exo 2", sans-serif;
}

/* reset box-sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* body layout */
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-family: var(--font-table);
}

/* main container */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 98%; /* almost full width */
  margin: 0 auto;
  padding: clamp(0.5rem, 1vw, 1rem) clamp(0.5rem, 1vw, 1rem) 0;
}

/* headings */
h1,
h2,
h3 {
  font-family: var(--font-header);
  text-transform: uppercase;
  color: var(--color-header);
  margin: 0;
}

h1 {
  text-align: center;
  font-size: clamp(0.65rem, 1.5vw, 1.5rem);
}
h2 {
  font-size: clamp(0.45rem, 1.125vw, 1.125rem);
}
h3 {
  text-align: center;
  font-size: clamp(0.65rem, 0.85vw, 1rem);
}

/* dice section */

#dice-section header {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dice-result {
  display: flex;
  width: 100%;
  justify-content: center;
  align-items: center;
  gap: clamp(1rem, 5vw, 3rem);
}

.dice {
  display: flex;
  justify-content: center;
  align-items: center;
  width: clamp(2rem, 5vw, 3rem);
  height: clamp(2rem, 5vw, 3rem);
  font-size: clamp(1.25rem, 4.5vw, 2rem);
  font-family: var(--font-header);
  letter-spacing: 0.1em;
  color: var(--color-button);
  text-shadow: 0 0 4px var(--color-button), 0 0 8px rgba(255, 255, 255, 0.4);
  transition: color 0.2s ease;
}

@keyframes dicePulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.dice.roll {
  animation: dicePulse 0.3s ease;
}

/* hidden output for screen readers */

#dice-total {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* roll button */

#rollButton {
  display: block;
  margin: clamp(0.125rem, 0.25vw, 0.25rem) auto;
  position: relative;
  overflow: hidden;
  color: var(--color-header);
  font-weight: bolder;
  font-family: var(--font-table);
  letter-spacing: 2px;
  padding: clamp(0.25rem, 0.5vw, 0.5rem) clamp(0.5rem, 1vw, 1.25rem);
  font-size: clamp(0.85rem, 1.35vw, 1.35rem);
  border: 0.25rem solid var(--color-alt-row);
  background: linear-gradient(
    135deg,
    var(--color-button) 0%,
    var(--color-alt-row) 100%
  );
  width: clamp(8rem, 18vw, 14rem);
  cursor: pointer;
  box-shadow: 0 0 12px var(--color-alt-row), inset 0 0 6px var(--color-alt-row);
  transition: all 0.2s ease;
  transform: skew(-20deg);
}

#rollButton span {
  display: inline-block;
  transform: skew(20deg);
}

#rollButton:hover {
  color: var(--color-header);
  border-color: var(--color-button);
  transform: skew(-20deg) scale(1.05);
  box-shadow: 0 0 16px var(--color-button), inset 0 0 8px var(--color-alt-row);
}

#rollButton:active,
#rollButton.is-active {
  transform: skew(-20deg) scale(0.95);
  box-shadow: 0 0 6px var(--color-button) inset;
  color: var(--color-black);
  border-color: var(--color-header);
}

#rollButton::after {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    120deg,
    transparent,
    rgba(255, 255, 255, 0.4),
    transparent
  );
  transform: skew(20deg);
  transition: 0.5s;
}

#rollButton:hover::after {
  left: 100%;
}

/* Table container */
#table-section {
  flex: 1;
  /* min-height: */
  width: 100%;
  overflow-y: auto;
  padding: 0;
  box-sizing: border-box;
}

/* Table styling */
table {
  font-family: var(--font-table);
  width: 100%;
  border-spacing: 0;
  color: var(--color-black);
  table-layout: auto;
  border-collapse: collapse;
}

th {
  font-family: var(--font-table);
  color: white;
  letter-spacing: 2px;
  padding: clamp(4px, 0.5vw, 8px);
  background-color: var(--color-header);
}

td.number,
td.text {
  padding: clamp(4px, 0.5vw, 10px);
  font-size: clamp(0.7rem, 0.9vw, 1.1rem);
}

th.number,
td.number {
  font-family: var(--font-header);
  text-align: center;
  width: clamp(1.5rem, 2vw, 2rem); /* narrow */
  padding: 0 2px;
  letter-spacing: 0;
  white-space: nowrap;
}

td.text {
  word-break: break-word;
  min-width: clamp(120px, 15%, 180px);
  padding-left: clamp(5px, 0.5vw, 10px);
}

td.text:not(:last-child) {
  border-right: 1px solid var(--color-black);
}

tbody tr:nth-child(odd) {
  background-color: var(--color-alt-row);
}
tbody tr:nth-child(even) {
  background-color: white;
}

.highlight {
  background-color: var(--color-highlight);
  font-weight: bold;
}

/* -------------------------
   SECTION HEADER (H2 + CUP LINK)
-------------------------- */

.section-header {
  display: flex;
  justify-content: space-between; /* h2 left, link right */
  align-items: center;
  margin-bottom: 0.5rem;
}

.section-header h2 {
  margin: 0;
  font-family: var(--font-header);
  font-size: clamp(0.45rem, 1.125vw, 1.125rem);
  text-transform: uppercase;
  color: var(--color-header);
}

#cup-link {
  font-size: clamp(0.7rem, 1vw, 0.9rem);
  color: var(--color-header, #333);
  text-decoration: underline;
  cursor: pointer;
}

#cup-link:hover,
#cup-link:focus {
  color: var(--color-accent, #0077cc);
}

/* -------------------------
   MODAL OVERLAY + CONTENT
-------------------------- */

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.6);
}

.modal-content {
  background: #fff;
  margin: 10% auto;
  padding: 1.5rem;
  border-radius: 0.75rem;
  width: clamp(300px, 60%, 700px);
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
  position: relative;
}

.modal-content h2 {
  margin-top: 0;
  font-size: clamp(1rem, 1.5vw, 1.5rem);
  color: var(--color-header, #333);
}

.modal-content p {
  font-size: clamp(0.85rem, 1vw, 1rem);
  line-height: 1.4;
  margin: 0.5rem 0;
}

.modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  border: none;
  background: none;
  padding: 0;
  color: #333;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s ease, transform 0.15s ease;
  outline: none;
}

.modal-close:hover,
.modal-close:focus {
  color: var(--color-button);
}

.modal-close:active {
  transform: scale(0.9);
  color: var(--color-header);
}
