* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #000;
  color: #fff;
  font-family: 'Courier New', 'PingFang SC', 'Microsoft YaHei', monospace;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: rgba(4, 10, 30, 0.82);
  text-align: center;
}

.overlay[hidden],
#toolbar[hidden] {
  display: none;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 56px);
  letter-spacing: 4px;
  color: #fff;
  text-shadow:
    3px 3px 0 #d97757,
    6px 6px 0 #7b3fe4;
}

h2 {
  margin: 0;
  font-size: clamp(22px, 5vw, 36px);
  color: #ffd23f;
  text-shadow: 3px 3px 0 #000;
}

.sub {
  margin: 0;
  color: #bfe0ff;
  font-size: 15px;
}

.hint {
  margin: 0;
  color: #7a8fb0;
  font-size: 12px;
}

.chars {
  display: flex;
  gap: 16px;
}

.char {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 12px;
  border: 3px solid #334;
  border-radius: 10px;
  background: #0c1630;
  color: #fff;
  cursor: pointer;
  font: inherit;
}

.char canvas {
  image-rendering: pixelated;
}

.char span {
  font-weight: bold;
  font-size: 16px;
}

.char small {
  color: #8aa0c8;
  font-size: 11px;
}

.char[aria-checked='true'] {
  border-color: #ffd23f;
  box-shadow: 0 0 12px rgba(255, 210, 63, 0.6);
}

.char[data-char='kiro'][aria-checked='true'] {
  border-color: #b48cff;
  box-shadow: 0 0 12px rgba(180, 140, 255, 0.7);
}

.buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.buttons button {
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: #d97757;
  color: #fff;
  font: inherit;
  font-size: 17px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: 0 4px 0 #8a3f25;
}

.buttons button small {
  display: block;
  font-size: 11px;
  font-weight: normal;
  opacity: 0.85;
}

.buttons button.secondary {
  background: #2b3a66;
  box-shadow: 0 4px 0 #141c38;
}

.buttons button.alt {
  background: #7b3fe4;
  box-shadow: 0 4px 0 #3f1a85;
}

.buttons button:focus-visible,
.char:focus-visible,
#toolbar button:focus-visible {
  outline: 3px solid #ffd23f;
  outline-offset: 2px;
}

.help-list {
  margin: 0;
  padding: 0;
  list-style: none;
  text-align: left;
  font-size: 14px;
  line-height: 1.9;
  max-width: 560px;
}

kbd {
  display: inline-block;
  min-width: 20px;
  padding: 0 5px;
  margin: 0 1px;
  border: 1px solid #667;
  border-radius: 4px;
  background: #1b2340;
  font: inherit;
  font-size: 12px;
  text-align: center;
}

#toolbar {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}

#toolbar button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: rgba(20, 30, 60, 0.7);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}

#touch {
  display: none;
  justify-content: space-between;
  padding: 8px 14px 14px;
}

#touch .pad {
  display: flex;
  gap: 10px;
}

#touch button {
  width: 60px;
  height: 60px;
  border: 2px solid #445;
  border-radius: 50%;
  background: rgba(40, 60, 110, 0.6);
  color: #fff;
  font: inherit;
  font-size: 20px;
  touch-action: none;
}

#touch button.on {
  background: rgba(217, 119, 87, 0.8);
}

@media (pointer: coarse) {
  #touch {
    display: flex;
  }
}

.scores {
  min-width: 260px;
  max-height: 30vh;
  overflow-y: auto;
}

.scores h3 {
  margin: 4px 0;
  color: #ffd23f;
  font-size: 14px;
}

#score-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  line-height: 1.6;
}

#score-list li {
  display: grid;
  grid-template-columns: 2em 1fr 6em 3.5em;
  gap: 6px;
  text-align: left;
}

#score-list li .pts {
  text-align: right;
  color: #ffd23f;
}

#score-list li.empty {
  display: block;
  text-align: center;
  color: #7a8fb0;
}

#name-input {
  padding: 8px 10px;
  border: 2px solid #ffd23f;
  border-radius: 6px;
  background: #0c1630;
  color: #fff;
  font: inherit;
  font-size: 20px;
  text-align: center;
  letter-spacing: 2px;
}

.modes {
  display: flex;
  gap: 8px;
}

.mode {
  padding: 6px 16px;
  border: 2px solid #334;
  border-radius: 20px;
  background: #0c1630;
  color: #bfe0ff;
  font: inherit;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
}

.mode[aria-checked='true'] {
  border-color: #ffd23f;
  background: #2b3a66;
  color: #fff;
}

.mode:focus-visible {
  outline: 3px solid #ffd23f;
  outline-offset: 2px;
}

.chars[hidden] {
  display: none;
}
