body {
    background-color:bisque;
    color:brown;
    font-family: "JetBrains Mono", monospace;
    font-optical-sizing: auto;
    font-weight: 600;
    font-style: normal;
    margin:0;
    line-height: 0.8;
    margin-top: 20px;
}

#page {
    text-align: center;
    text-align: -webkit-center;
    text-align: -moz-center;
}

#gamePage {
    width: min(90vw - 72px, 80vh, 500px);

    aspect-ratio: 1 / 1.2;
    border: 2px solid brown;
}

#backgroundCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
}

#board {
    width:100%;
    height:100%;
    touch-action: none;
}

#board,
#board text {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

#board text {
    pointer-events: none;
}
#board circle.multiplier {
    cursor: pointer;
}

#board line {
    transition: stroke-width 0.15s ease-out, filter 0.15s ease-out;
}

#board line.edge-highlight {
    stroke-width: 14;
}

#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 20px;
    margin-bottom: 20px;
}

#header h2 {
    margin: 0;
    line-height: 1.2;
}

.settingButtons {
    flex-shrink: 0;
    width: 36px;
    height: 36px;

    border: 2px solid brown;
    border-radius: 9px;

    background-color: brown;
    color: bisque;
    font-size: 18px;
    padding: 0;
    transition: background-color 0.15s, color 0.15s;

    cursor: pointer;

    font-family: "JetBrains Mono", monospace;
    font-optical-sizing: auto;
    font-weight: 600;
    font-style: normal;
}

.borderlessButtons {
    border: 0px solid brown;
    border-radius: 12px;

    background-color: transparent;
    color:brown;
    font-size: 20px;
    cursor: pointer;

    font-family: "JetBrains Mono", monospace;
    font-optical-sizing: auto;
    font-weight: 600;
    font-style: normal;
}

.rsButtons {

    border: 0px solid brown;
    border-radius: 12px;

    background-color: transparent;
    color:brown;
    font-size: 24px;
    cursor: pointer;

    font-family: "JetBrains Mono", monospace;
    font-optical-sizing: auto;
    font-weight: 600;
    font-style: normal;
}

.rsButtons:hover,
.rsButtons:active {
    font-weight: 800;
}


.settingButtons:hover {
    background-color: bisque;
    color: brown;
}

#gameRow {
    display: flex;
    justify-content: center;
    align-items: stretch;
    gap: 0;
}

.puzzleArrow {
    width: 36px;
    padding: 8px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.puzzleArrow {
    border-radius: 0;
}

#prevPuzzleButton:hover {
    background: linear-gradient(to left, rgba(165, 42, 42, 0.3) 0 33.33%, rgba(165, 42, 42, 0.18) 33.33% 66.67%, rgba(165, 42, 42, 0.08) 66.67%);
}

#nextPuzzleButton:hover {
    background: linear-gradient(to right, rgba(165, 42, 42, 0.3) 0 33.33%, rgba(165, 42, 42, 0.18) 33.33% 66.67%, rgba(165, 42, 42, 0.08) 66.67%);
}

.arrowIcon {
    font-size: 32px;
    line-height: 1;
}

.arrowLabel {
    writing-mode: vertical-rl;
    font-size: 16px;
    line-height: 1;
    white-space: nowrap;
}

#prevPuzzleButton .arrowLabel {
    transform: rotate(180deg);
}

#boardColumn {
    display: flex;
    flex-direction: column;
}

#gameButtons {
    box-sizing: border-box;
    width: 100%;
    padding: 4px 10px;
    border: 2px solid brown;
    border-bottom: none;
    background-color: rgba(165, 42, 42, 0.08);

    display: flex;
    justify-content: space-between;
    align-items:center;
}

#violationText {
    margin: 0;
}

#actionButtons {
    display: flex;
    align-items: center;
}
#resetButton, #submitButton {
    height: 32px;
    padding: 0 10px;
    font-size: 18px;
    box-sizing: border-box;
}

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

.modal-content {
  background-color: bisque;
  color: brown;
  border: 2px solid brown;
  border-radius: 12px;
  margin: 5vh auto;
  padding: 20px;
  width: min(600px, 90vw);
  max-height: 80vh;
  box-sizing: border-box;
  line-height: 1.4;
  overflow-y: auto;
  scrollbar-width: none;
}

.modal-content::-webkit-scrollbar {
  display: none;
}

.modal-content h2 {
  margin: 0;
  font-size: 24px;
}

.splitRow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-top: 20px;
}

.splitText {
  flex: 1;
  text-align: left;
  line-height: 1.4;
}

.splitImage {
  width: 150px;
  max-width: 40%;
  height: auto;
}

.closeButton {
  color: brown;
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
}
.closeButton:hover {
  color: #000;
}

#popUpMessage {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 16px 24px;
    border-radius: 8px;
    font-size: 18px;
    text-align: center;
    max-width: 80vw;
    opacity: 0;
    pointer-events: none;
    z-index: 100;
}

#popUpMessage.show {
    opacity: 1;
}

#popUpMessage.error {
    background: rgba(160, 30, 30, 0.9);
}


.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  align-items: center;
  justify-content: center;
  z-index: 1000;
  overflow-x: hidden;
  overflow-y:hidden;
}

.modal-card {

  position: relative;
  background-color: bisque;
  color: brown;
  border: 2px solid brown;
  border-radius: 12px;
  padding: 20px;
  width: min(500px, 90vw);
  max-height: 90vh;
  box-sizing: border-box;
  line-height: 1.4;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.modal-card::-webkit-scrollbar {
  display: none;
}

.modal-card h2 {
  margin: 0 40px 0 0;
  font-size: 24px;
}

.chart-box {
  position: relative;
  height: 240px;
  margin-top: 16px;
}

#statsText {
  margin-top: 12px;
  font-size: 14px;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 28px;
  font-weight: 600;
  color: brown;
  background: none;
  border: none;
  cursor: pointer;
}

.modal-close:hover {
  color: #000;
}
.modal-card {
  text-align: center;
}

.modal-card h2 {
  margin: 0;
  font-size: 24px;
}

.confirmButtons {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.barRow { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.barLabel { width: 28px; text-align: right; }
.barTrack { flex: 1; }
.bar {
  box-sizing: border-box;
  min-width: 0;
  padding: 4px 6px;
  text-align: right;
  border-radius: 1px;
  background-color: brown;
  color: bisque;
}
.bar.current { background-color: brown; color: bisque; }

.winDivider {
  position: relative;
  margin: 16px 0 12px;
  border-top: 2px dashed brown;
  font-size: 11px;
  line-height: 13px;
}
.winDivider span {
  position: absolute;
  left: 0;
  width: 28px;
  text-align: right;
}
.winDivider .winLabel { top: -16px; }
.winDivider .failLabel { top: 2px; }

#shareButton {
  position: absolute;
  top: 26px;
  padding: 4px;
  border: none;
  background: transparent;
  color: brown;
  cursor: pointer;
  line-height: 0;
}
#shareButton { left: 18px; }
#shareButton svg line { stroke: currentColor; stroke-width: 2; }
#shareButton svg circle { fill: currentColor; }
#shareButton:hover { color: #000; }

#shareCopied {
  position: absolute;
  top: 30px;
  left: 54px;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: brown;
  color: bisque;
  font-size: 13px;
  font-weight: 700;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.2s, transform 0.2s;
}
#shareCopied.show {
  opacity: 1;
  transform: translateX(0);
}

#puzzleLabel {
    font-size: 0.5em;
    margin-left: 12px;
    white-space: nowrap;   
}

@media (max-width: 600px) {
    html, body {
        overflow: hidden;
        overscroll-behavior: none;
        height: 100%;
    }

    body {
        position: fixed;
        inset: 0;
    }

    * {
        -webkit-user-select: none;
        user-select: none;
        -webkit-touch-callout: none;
    }
    #gameRow {
        flex-wrap: wrap;
        row-gap: 6px;
        width: min(100vw - 24px, (100vh - 200px) / 1.2);
        margin: 0 auto;
    }

    #boardColumn {
        order: 1;
        flex-basis: 100%;
        width: 100%;
    }

    #gamePage {
        width: 100%;
        box-sizing: border-box;
    }

    .puzzleArrow {
        flex: 1;
        width: auto;
        height: 40px;
        padding: 0 8px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 8px;
    }

    #nextPuzzleButton {
        flex-direction: row-reverse;
    }

    .arrowIcon {
        font-size: 28px;
    }

    .arrowLabel,
    #prevPuzzleButton .arrowLabel {
        writing-mode: horizontal-tb;
        transform: none;
    }

    #prevPuzzleButton:hover,
    #nextPuzzleButton:hover {
        background: linear-gradient(to top, rgba(165, 42, 42, 0.3) 0 33.33%, rgba(165, 42, 42, 0.18) 33.33% 66.67%, rgba(165, 42, 42, 0.08) 66.67%);
    }

    #gameButtons {
        gap: 8px;
    }

    .rsButtons {
        font-size: 18px;
    }

    #resetButton, #submitButton {
        padding: 0 6px;
        font-size: 15px;
    }

    #violationText {
        flex: 1;
        min-width: 0;
        font-size: 18px;
        line-height: 1.2;
        text-align: left;
    }

    .splitRow {
        gap: 12px;
    }

    .splitImage {
        width: 90px;
        max-width: 30%;
    }

    .modal-content {
        font-size: 14px;
    }

    .modal-content h1 {
        font-size: 22px;
    }

    .modal-content h2 {
        font-size: 18px;
    }

    .modal-content h3 {
        font-size: 15px;
    }
}

#sideMenu {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: min(280px, 80vw);
    box-sizing: border-box;
    padding: 0;
    z-index: 1100;

    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;

    background-color: bisque;
    color: brown;
    border-right: 2px solid brown;
    line-height: 1.4;
    font-family: "JetBrains Mono", monospace;

    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.3s ease, visibility 0s linear 0.3s;
}

#sideMenu.open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.3s ease, visibility 0s;
}

#sideMenu h2 {
    margin: 0;
    padding: 12px;
    text-align: left;
    border-bottom: 2px solid brown;
    background-color: rgba(165, 42, 42, 0.08);
}

#menuOverlay {
    position: fixed;
    inset: 0;
    z-index: 1050;
    background-color: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

#menuOverlay.open {
    opacity: 1;
    pointer-events: auto;
}

.menuItem {
    padding: 12px;
    border: none;
    border-bottom: 2px solid brown;
    border-radius: 0;
    background-color: transparent;
    color: brown;
    font-family: "JetBrains Mono", monospace;
    font-size: 20px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.menuItem:hover {
    background-color: brown;
    color: bisque;
}

@media (pointer: coarse) {
    #board circle.piece {
        stroke: transparent;
        stroke-width: 16px;
    }
}

#menuLinks {
    margin-top: auto;
    padding: 8px 12px;
    display: flex;
    gap: 16px;
    font-size: 14px;
}

#menuLinks a {
    color: brown;
    text-decoration: none;
}

#menuLinks a:hover {
    text-decoration: underline;
}

#accountButton {
    border-top: 2px solid brown;
    border-bottom: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#signInForm {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 16px;
    text-align: left;
}

#signInForm input {
    padding: 8px 10px;
    margin-bottom: 8px;
    border: 2px solid brown;
    border-radius: 9px;
    background-color: transparent;
    color: brown;
    font-family: "JetBrains Mono", monospace;
    font-size: 16px;
    -webkit-user-select: text;
    user-select: text;
}

#signInForm input:focus {
    outline: none;
    background-color: rgba(165, 42, 42, 0.08);
}

#signInError {
    min-height: 1.4em;
    margin: 0;
    color: red;
    font-size: 14px;
}

#signInSubmit {
    align-self: center;
}

#signInSubmit:disabled {
    opacity: 0.5;
    cursor: default;
}

#signInModal [hidden] {
    display: none !important;
}

#forgotPasswordButton {
    align-self: flex-end;
    margin-top: -4px;
}

#signInInfo {
    margin: 0 0 8px 0;
    font-size: 14px;
    word-break: break-word;
}

#signInSwitch {
    margin: 12px 0 0 0;
    font-size: 14px;
}

.linkButton {
    padding: 0;
    border: none;
    background: none;
    color: brown;
    font-family: "JetBrains Mono", monospace;
    font-size: 14px;
    font-weight: 800;
    text-decoration: underline;
    cursor: pointer;
}

.highlighting .bar:not(.current) {
    background-color: rgba(165, 42, 42, 0.3);
    color: brown;
}

.statsTotals {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px 32px;
    margin-top: 16px;
}

.statNumber {
    font-size: 32px;
    font-weight: 800;
}

.statLabel {
    font-size: 14px;
}

#todayResult {
    display: flex;
    align-items: stretch;
    gap: 16px;
    margin-top: 16px;
}

#todayDetails {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-align: left;
}

#todayCounts {
    display: flex;
    gap: 16px;
    font-size: 14px;
}

#todayResult .statBox {
    text-align: center;
    margin-right: 24px;
}

#scoreComment {
    font-size: 14px;
    font-style: italic;
    margin: 0;
}
