:root {
  --ink: #2b2140;
  --pink: #ff8fb8;
  --lemon: #ffe066;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body,
#game-root {
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #9ad8ff;
  font-family: "Gowun Dodum", sans-serif;
  color: var(--ink);
  overscroll-behavior: none;
}

#view {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

button,
.back,
.mute,
.ghost {
  touch-action: manipulation;
}

.back,
.mute {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  z-index: 8;
  border: 3px solid var(--ink);
  background: #fffdf8;
  color: var(--ink);
  text-decoration: none;
  font-family: "Jua", sans-serif;
  border-radius: 14px;
  padding: 6px 12px;
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
}

.back {
  left: max(12px, env(safe-area-inset-left));
}

.mute {
  right: max(12px, env(safe-area-inset-right));
  font-size: 16px;
}

.hud {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(520px, calc(100% - 180px));
}

.hud-card {
  display: flex;
  gap: 18px;
  align-items: baseline;
  background: #fffdf8;
  border: 3px solid var(--ink);
  border-radius: 18px;
  padding: 6px 16px;
  box-shadow: 4px 4px 0 var(--ink);
}

.rank {
  font-family: "Jua", sans-serif;
  font-size: 28px;
}

.rank small {
  font-size: 16px;
  color: #6d5a7a;
}

.time {
  font-family: "Jua", sans-serif;
  font-size: 22px;
}

.progress-wrap {
  width: 100%;
  height: 14px;
  background: rgba(255, 253, 248, 0.7);
  border: 3px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
}

.progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pink), var(--lemon));
}

.keys {
  font-size: 13px;
  color: #2b2140;
  text-shadow: 0 1px 0 #fff;
}

.slide-cd {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fffdf8;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 13px;
}

.slide-bar {
  width: 88px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  overflow: hidden;
  background: #efe6ff;
}

.slide-bar > div {
  height: 100%;
  width: 100%;
  background: var(--pink);
}

.slide-cd.ready .slide-bar > div {
  background: #7ce7c4;
}

.slide-cd small {
  font-family: "Jua", sans-serif;
  min-width: 44px;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  background: rgba(80, 140, 190, 0.28);
  backdrop-filter: blur(6px);
}

.panel {
  width: min(500px, calc(100% - 32px));
  background: #fffdf8;
  border: 4px solid var(--ink);
  border-radius: 28px;
  padding: 28px 26px 24px;
  box-shadow: 10px 12px 0 var(--ink);
  text-align: center;
}

.kicker {
  font-size: 13px;
  letter-spacing: 0.08em;
}

.panel h1,
.panel h2,
#count-num {
  font-family: "Jua", sans-serif;
}

.panel h1 {
  font-size: 56px;
  line-height: 1;
  margin: 4px 0 8px;
}

.panel h2 {
  font-size: 36px;
  margin-bottom: 8px;
}

.lead {
  color: #6d5a7a;
  line-height: 1.55;
}

.controls {
  list-style: none;
  text-align: left;
  margin: 16px 0 14px;
  display: grid;
  gap: 8px;
}

.controls li {
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 8px 10px;
  font-size: 14px;
}

kbd {
  font-family: "Jua", sans-serif;
  background: var(--lemon);
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 1px 6px;
}

button,
.ghost {
  font-family: "Jua", sans-serif;
  font-size: 18px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  color: var(--ink);
}

.diff-label {
  font-family: "Jua", sans-serif;
  font-size: 14px;
  margin-bottom: 8px;
}

.diff-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.diff-btn {
  font-size: 16px;
  padding: 8px 6px 6px;
  background: #fff;
  box-shadow: 3px 3px 0 var(--ink);
  line-height: 1.15;
}

.diff-btn small {
  display: block;
  font-family: "Gowun Dodum", sans-serif;
  font-size: 12px;
  color: #6d5a7a;
  font-weight: 400;
}

.diff-btn.selected {
  background: var(--lemon);
}

.diff-btn[data-diff="easy"].selected {
  background: #7ce7c4;
}

.diff-btn[data-diff="hard"].selected {
  background: var(--pink);
}

#btn-start,
#btn-retry {
  background: var(--pink);
  box-shadow: 4px 4px 0 var(--ink);
}

.ghost {
  background: #efe6ff;
}

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

.hidden {
  display: none !important;
}

#count-num {
  font-size: min(28vw, 180px);
  color: #fff;
  text-shadow: 6px 8px 0 var(--ink);
}

.board {
  list-style: none;
  margin-top: 14px;
  display: grid;
  gap: 6px;
  text-align: left;
}

.board li {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 8px;
  align-items: center;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 12px;
  padding: 6px 10px;
}

.board li.me {
  background: #ffe3f0;
}

.board .place {
  font-family: "Jua", sans-serif;
}

.touch-only {
  display: none;
}

.touch-ui {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 max(16px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  pointer-events: none;
}

.stick {
  pointer-events: auto;
  width: 124px;
  height: 124px;
  border-radius: 50%;
  border: 3px solid var(--ink);
  background: rgba(255, 253, 248, 0.5);
  position: relative;
  touch-action: none;
  box-shadow: 3px 3px 0 var(--ink);
}

.stick-knob {
  position: absolute;
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--pink);
  border: 3px solid var(--ink);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 3px 3px 0 var(--ink);
}

.touch-actions {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.touch-btn {
  min-width: 86px;
  height: 70px;
  font-size: 16px;
  background: var(--lemon);
  box-shadow: 3px 3px 0 var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

.touch-btn.slide {
  background: var(--pink);
}

.touch-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 var(--ink);
}

@media (hover: none), (pointer: coarse) {
  .touch-ui:not(.hidden) {
    display: flex;
  }
  .touch-only {
    display: list-item;
  }
  .kb-only,
  #hud-keys {
    display: none !important;
  }
  .hud {
    top: max(56px, calc(env(safe-area-inset-top) + 44px));
    width: min(520px, calc(100% - 20px));
  }
  .panel {
    padding: 20px 16px 18px;
  }
  .panel h1 {
    font-size: 44px;
  }
}

@media (hover: none) and (orientation: landscape), (pointer: coarse) and (orientation: landscape) {
  .hud {
    top: max(12px, env(safe-area-inset-top));
    width: min(520px, calc(100% - 176px));
  }
  .stick {
    width: 108px;
    height: 108px;
  }
  .touch-btn {
    min-width: 76px;
    height: 58px;
    font-size: 15px;
  }
}

@media (max-width: 640px) and (pointer: fine) {
  .hud {
    width: min(520px, calc(100% - 24px));
  }
}
