/* COUNT-UP: styles; managed only in countup/. */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scrollbar-gutter: stable;
}

:root {
  --blue: #c3d825;
  color-scheme: dark;
  --page: #090a0b;
  --panel: #191b1d;
  --soft: #24282a;
  --line: #454748;
  --ink: #f4f4f0;
  --muted: #bfc5c7;
  --shadow: none;
  --game-title-height: calc(clamp(10px,1.2dvmax,16px) * 1.5 + clamp(6px,1.2dvmin,14px) + clamp(6px,1.2dvmin,14px));
}

body {
  margin: 0px;
  min-height: 100vh;
  color: var(--ink);
  font-family: Meiryo, メイリオ, "Noto Sans JP", sans-serif;
  background: var(--page);
}

.app {
  width: min(760px, 100%);
  margin: 0px auto;
  padding: 12px;
}

.panel {
  border-radius: 0px;
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  background: var(--panel);
  border: 1px solid var(--line);
}

.box {
  border-radius: 0px;
  padding: 10px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.title {
  font-size: 11px;
  color: var(--ink);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-align: center;
  margin-bottom: 6px;
}

select {
  width: 100%;
  min-height: 44px;
  border-radius: 0px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
  text-align: center;
  border: 1px solid var(--line);
  background: var(--page);
  font-family: Meiryo, メイリオ, "Noto Sans JP", sans-serif;
}

button {
  min-height: 44px;
  border-radius: 0px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 900;
  box-shadow: none;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--page);
  font-family: Meiryo, メイリオ, "Noto Sans JP", sans-serif;
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: rgb(195, 216, 37) solid 2px;
  outline-offset: 2px;
}

select:focus-visible {
  outline: rgb(195, 216, 37) solid 2px;
  outline-offset: 2px;
}

.primary {
  color: rgb(23, 37, 44);
  border: 1px solid rgb(195, 216, 37);
  box-shadow: none;
  background: rgb(195, 216, 37);
}

.orange {
  color: rgb(23, 37, 44);
  border: 1px solid rgb(195, 216, 37);
  box-shadow: none;
  background: rgb(195, 216, 37);
}

.danger {
  color: rgb(255, 177, 186);
  background: rgb(48, 29, 34);
  border-color: rgb(117, 65, 74);
}

#game .scorePanel {
  text-align: center;
  overflow: visible;
  padding: 0px;
  position: static;
  background: transparent;
  border: 0px;
  margin: 0px;
}

#game .scoreHead {
  display: grid;
  grid-template-columns: 1fr 1fr;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 20%;
  border: 0px;
  background: rgb(52, 54, 56);
}

#game .mini {
  min-width: 0px;
  padding: clamp(4px, 1cqh, 12px);
  border: 0px;
  background: transparent;
  text-align: left;
}

#game .mini span {
  display: block;
  color: rgb(170, 170, 170);
  font-size: clamp(8px, 1cqw, 13px);
  font-weight: 900;
  letter-spacing: 0px;
}

#game .mini strong {
  display: block;
  color: rgb(255, 255, 255);
  font-size: clamp(11px, 1.4cqw, 20px);
  white-space: nowrap;
  margin-top: 2px;
}

#game .totals {
  display: grid;
  position: absolute;
  left: 0px;
  right: 0px;
  bottom: 0px;
  height: var(--footer-height);
  background: rgb(5, 5, 5);
}

#game .playerTotal {
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(6px, 1.5cqw, 24px);
  border-right: 1px solid rgb(52, 54, 56);
  min-width: 0px;
}

#game .playerTotal.active {
  background: rgb(210, 10, 19);
}

#game .totalLabel {
  font-size: clamp(10px, 1.8cqw, 26px);
  color: rgb(255, 255, 255);
  font-weight: 900;
  letter-spacing: 0px;
}

#game .totalValue {
  font-size: clamp(22px, 4.5cqw, 68px);
  line-height: 1.2;
  font-weight: 600;
  color: rgb(255, 255, 255);
  letter-spacing: -0.06em;
  margin: 0px;
}

#game .playerTotal.active .totalLabel {
  color: rgb(255, 255, 255);
  font-size: clamp(10px, 1.8cqw, 26px);
  letter-spacing: 0px;
}

#game .playerTotal.active .totalValue {
  color: rgb(255, 255, 255);
  font-size: clamp(22px, 4.5cqw, 68px);
  font-weight: 600;
  line-height: 1.2;
  margin: 0px;
}

.mobileOnly {
  display: none;
}

.hidden {
  display: none !important;
}

#game .roundStrip {
  padding: 0px 10px;
  position: absolute;
  left: 0px;
  top: clamp(68px, 20cqh, 130px);
  bottom: calc(var(--footer-height) + 10px);
  width: 20%;
  overflow: auto;
  border: 0px;
}

#game .roundCells {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0px;
}

#game .roundCell {
  min-width: 0px;
  border-radius: 0px;
  padding: clamp(2px, 0.6cqh, 8px) 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-width: 0px 0px 1px;
  border-style: none none solid;
  border-color: currentcolor currentcolor rgb(69, 71, 72);
  border-image: none;
}

#game .roundCell span {
  display: block;
  font-size: clamp(10px, 1.3cqw, 18px);
  color: rgb(170, 170, 170);
}

#game .roundCell strong {
  display: block;
  font-size: clamp(16px, 2.1cqw, 30px);
  margin: 0px;
  font-weight: 600;
}

#game .roundCell.current {
  background: rgba(255, 255, 255, 0.094);
  border-left: 3px solid rgb(210, 10, 19);
}

#saveStatus {
  margin-top: 8px;
  font-size: 12px;
  color: rgb(255, 177, 186);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

body:has(#game:not(.hidden)) {
  overflow: hidden;
}

#game {
  position: fixed;
  inset: 0px;
  width: 100dvw;
  height: 100dvh;
  z-index: 5;
  container-type: size;
  --footer-height: clamp(64px,16cqh,130px);
  background: radial-gradient(at 52% 25%, rgb(41, 43, 44), rgb(11, 13, 14) 65%, rgb(5, 6, 7));
}

#game #gamePlay {
  display: block;
  height: 100%;
  margin: 0px;
}

#game .mainScore {
  position: absolute;
  left: 20%;
  right: 34%;
  top: 0px;
  bottom: var(--footer-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

#game .mainScore span {
  color: rgb(170, 170, 170);
  font-size: clamp(12px, 1.6cqw, 22px);
  letter-spacing: 0.1em;
}

#game .mainScore strong {
  font-size: min(17cqw, 40cqh);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.015em;
  font-variant-numeric: tabular-nums;
  text-shadow: rgba(170, 170, 170, 0.24) 0px 3px 6px;
}

#game .playerTotal.active:nth-child(2) {
  background: rgb(24, 83, 181);
}

#game .playerTotal.active:nth-child(3) {
  background: rgb(38, 123, 71);
}

#game .playerTotal.active:nth-child(4) {
  background: rgb(140, 78, 176);
}

#game .mobileOnly.panel {
  display: none;
}

.mobileGameHeader {
  display: block;
}

.shortPlayerName {
  display: none;
}

.playerAverage {
  display: none;
}

.round-start-overlay {
  position: absolute;
  inset: 0px;
  z-index: 40;
  overflow: hidden;
  pointer-events: none;
}

.round-start-overlay[hidden] {
  display: none;
}

.round-start-position {
  position: absolute;
  text-align: center;
  transform: translate(-50%, -50%);
}

.round-start-position[data-placement="below"] {
  transform: translateX(-50%);
}

.round-start-overlay .round-start-text {
  display: block;
  color: rgb(255, 255, 255);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.1;
  letter-spacing: 0.06em;
  white-space: nowrap;
  text-shadow: rgb(0, 0, 0) 0px 2px 18px, rgb(0, 0, 0) 0px 0px 40px;
  animation: 1.3s ease-in-out 0s 1 normal both running iwashi-round-pass;
  font-weight: 900;
}

@keyframes iwashi-round-pass { 
  0% { transform: translateX(-150%); opacity: 0; }
  24%, 70% { transform: translateX(0px); opacity: 1; }
  100% { transform: translateX(150%); opacity: 0; }
}

#game .countUpTitle {
  box-sizing: border-box;
  height: var(--game-title-height);
  min-height: var(--game-title-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-block: 0px;
}

body #game .mobileGameHeader {
  display: block;
  position: absolute;
  top: 0px;
  left: 0px;
  width: 20%;
}

body #game .countUpTitle {
  background: rgb(0, 123, 187);
  color: rgb(255, 255, 255);
  padding-inline: clamp(6px, 1.2cqh, 14px);
  text-align: left;
  font-weight: 700;
  white-space: nowrap;
}

body #game {
  --rail-title-height: var(--game-title-height);
}

@media (max-width: 540px) {
  .app {
    padding: 6px;
  }

  .panel {
    border-radius: 0px;
    padding: 10px;
  }

  #game .totalValue {
    font-size: 58px;
  }
}

@media (max-width: 1024px), (hover: none) and (pointer: coarse) {
  .desktopOnly {
    display: none;
  }

  .mobileOnly {
    display: block;
  }
}

@media (hover: hover) {
  button:not(:disabled):hover {
    filter: brightness(1.15);
  }
}

@media (orientation: portrait) {
  #game {
    inset: 50% auto auto 50%;
    width: 100dvh;
    height: 100dvw;
    transform: translate(-50%, -50%) rotate(90deg);
  }
}

@media (max-width: 920px), (pointer: coarse) {
  #game {
    --input-width: 31%;
    --input-inset: clamp(6px,1cqw,18px);
    --rail-title-height: clamp(28px,8cqh,48px);
  }

  #game .scoreHead {
    display: none;
  }

  #game .mobileGameHeader {
    position: absolute;
    top: 0px;
    left: 0px;
    width: 20%;
    display: block;
  }

  #game .countUpTitle {
    display: flex;
    align-items: center;
    min-height: var(--rail-title-height);
    background: rgb(0, 123, 187);
    color: rgb(255, 255, 255);
    font-size: clamp(12px, 1.8cqw, 24px);
    font-weight: 700;
    white-space: nowrap;
  }

  #game .mobileRoundHeading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 3px;
    height: 26px;
    padding: 2px 6px;
    font-size: clamp(10px, 1.4cqw, 18px);
    white-space: nowrap;
  }

  #game .mobilePlayerHeading {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 3px;
    height: 24px;
    margin: 0px 6px;
    border-bottom: 3px solid rgb(210, 10, 19);
    font-size: clamp(9px, 1.25cqw, 16px);
    white-space: nowrap;
  }

  #game .mobilePlayerHeading span {
    color: rgb(221, 221, 221);
    font-size: clamp(8px, 1.15cqw, 15px);
  }

  #game .roundStrip {
    top: calc(var(--rail-title-height) + 56px);
    bottom: calc(var(--footer-height) + 2px);
    padding-inline: 6px;
  }

  #game .roundCells {
    min-height: 100%;
    grid-template-rows: repeat(8, minmax(28px, 1fr));
  }

  #game .roundCell span {
    font-size: clamp(12px, 1.5cqw, 20px);
  }

  #game .roundCell strong {
    font-size: clamp(18px, 2.4cqw, 34px);
  }

  #game .mainScore span {
    display: none;
  }

  #game .totals {
    right: calc(var(--input-width) + 2 * var(--input-inset));
  }

  #game .playerTotal {
    flex-direction: column;
    gap: 0px;
    padding: 2px;
    container-type: inline-size;
  }

  #game .totalLabel {
    line-height: 1.15;
    white-space: nowrap;
  }

  #game .playerTotal.active .totalLabel {
    line-height: 1.15;
    white-space: nowrap;
  }

  #game .totalValue {
    line-height: 1.05;
  }

  #game .playerTotal.active .totalValue {
    line-height: 1.05;
  }

  #game .totalLabel .shortPlayerName {
    display: none;
  }
}

@container (max-width: 90px) {
  #game .totalLabel .fullPlayerName {
    display: none;
  }

  #game .totalLabel .shortPlayerName {
    display: inline;
  }
}

@media (pointer: coarse), (hover: none) {
  body[data-setup-fit-game="countup"] #game #micBtn {
    grid-area: 5 / 4 / 6 / 7;
    height: 100%;
    min-height: 0px;
  }

  body[data-setup-fit-game="countup"] #game #finishNow {
    grid-area: 6 / 1 / 7 / 4;
  }
}

@media (orientation: landscape) and (pointer: coarse), (orientation: landscape) and (hover: none) {
  body[data-setup-fit-game="countup"] #game .totals {
    left: 20%;
  }

  body[data-setup-fit-game="countup"] #game .roundStrip {
    bottom: 6px;
  }
}

@media (min-width: 921px) and (hover: hover) and (pointer: fine) {
  body[data-setup-fit-game="countup"] #game .scorePanel {
    display: grid;
    grid-template-columns: 20% minmax(0px, 1fr);
    grid-template-rows: auto minmax(0px, 1fr);
    row-gap: 10px;
    height: calc(100% - var(--footer-height));
  }

  body[data-setup-fit-game="countup"] #game .scoreHead {
    position: static;
    grid-area: 1 / 1;
    width: 100%;
  }

  body[data-setup-fit-game="countup"] #game .roundStrip {
    position: static;
    grid-area: 2 / 1;
    width: 100%;
    min-height: 0px;
    overflow: hidden;
  }

  body[data-setup-fit-game="countup"] #game .roundCells {
    height: 100%;
    grid-template-rows: repeat(8, minmax(0px, 1fr));
  }

  body[data-setup-fit-game="countup"] #game .roundCell {
    min-height: 0px;
  }

  body[data-setup-fit-game="countup"] #game .mainScore {
    left: 20%;
    right: 20%;
    top: 0px;
  }

  body[data-setup-fit-game="countup"] #game #mainScoreValue {
    font-size: min(14cqw, 32cqh, 240px);
  }

  body[data-setup-fit-game="countup"] #game #finishNow {
    grid-area: 6 / 3 / 7 / 5;
  }
}

@media (max-width: 920px), (pointer: coarse), (hover: none) {
  body[data-setup-fit-game="countup"] #game .mobilePlayerHeading {
    display: none;
  }

  body[data-setup-fit-game="countup"] #game .roundStrip {
    top: calc(var(--rail-title-height) + 28px);
    overflow: hidden;
  }

  body[data-setup-fit-game="countup"] #game .roundCells {
    height: 100%;
    min-height: 0px;
    grid-template-rows: repeat(8, minmax(0px, 1fr));
  }

  body[data-setup-fit-game="countup"] #game .roundCell {
    min-height: 0px;
    padding-block: 0px;
    line-height: 1.15;
  }

  body[data-setup-fit-game="countup"] #game .playerTotal {
    gap: 2px;
  }

  body[data-setup-fit-game="countup"] #game .totalValue {
    display: none;
  }

  body[data-setup-fit-game="countup"] #game .playerAverage {
    display: block;
    color: rgb(255, 255, 255);
    font-size: clamp(11px, 1.6cqw, 22px);
    font-weight: 600;
    line-height: 1.2;
  }
}

@media (prefers-reduced-motion: reduce) {
  .round-start-overlay .round-start-text {
    animation: auto ease 0s 1 normal none running none;
  }
}

@media (min-width: 921px) and (hover: hover) and (pointer: fine) {
  body #game .mobileGameHeader > :is(.mobileRoundHeading, .mobilePlayerHeading) {
    display: none;
  }

  body #game .scoreHead {
    margin-top: var(--game-title-height);
  }
}

@media (max-height: 550px), (pointer: coarse) {
  :root {
    --game-title-height: calc(clamp(9px,1.15dvmax,12px) * 1.5 + 6px);
  }
}
