:root {
  font-family: ui-rounded, 'Hiragino Maru Gothic ProN', 'Yu Gothic', system-ui, sans-serif;
  color: #24364b;
  background: #f7f3e9;
  font-synthesis: none;
  font-weight: 650;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overscroll-behavior: none;
}
body {
  height: 100dvh;
}
button {
  font: inherit;
  border: 2px solid #263b51;
  border-radius: 12px;
  background: #fffdf8;
  color: #24364b;
  min-height: 44px;
  padding: 7px 10px;
  cursor: pointer;
  box-shadow: 0 3px 0 #24364b14;
  touch-action: manipulation;
}
button:active {
  transform: translateY(2px);
  box-shadow: none;
}
button:disabled {
  opacity: 0.38;
  cursor: default;
}
button:focus-visible,
canvas:focus-visible {
  outline: 3px solid #1678d4;
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
#app {
  height: 100%;
  width: min(100%, 900px);
  margin: auto;
  padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right))
    max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: 52px minmax(0, 1fr) 104px;
  gap: 6px;
  position: relative;
}
header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.brand {
  font-size: 19px;
  letter-spacing: -0.7px;
  flex: 1;
  line-height: 1.15;
  white-space: nowrap;
}
.brand small {
  display: block;
  font-size: 10px;
  letter-spacing: 0.1px;
  margin-top: 4px;
  color: #64717e;
}
header button {
  font-size: 12px;
  min-width: 44px;
  padding: 6px;
}
#workspace {
  min-height: 0;
  display: grid;
  grid-template-rows: 24px minmax(0, 1fr) 32px;
  gap: 4px;
}
#stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  padding: 0 3px;
}
#timer {
  font-size: 11px;
  color: #64717e;
}
#canvas-wrap {
  position: relative;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 16px;
  background: #e5edf0;
  border: 2px solid #263b51;
  overflow: clip;
}
canvas {
  display: block;
  touch-action: none;
  user-select: none;
  background: #e8f4f8;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}
#hint {
  margin: 0;
  font-size: 11px;
  line-height: 1.4;
  display: flex;
  align-items: center;
  padding: 0 3px;
}
#controls {
  display: grid;
  grid-template-rows: 48px 48px;
  gap: 6px;
}
#selection-controls,
#main-controls {
  display: flex;
  align-items: stretch;
  gap: 5px;
}
#selected-name {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  font-size: 11px;
}
#selection-controls button {
  font-size: 11px;
  min-width: 44px;
  padding: 5px;
}
#main-controls button {
  flex: 1;
  font-size: 14px;
}
#main-controls .primary {
  flex: 1.7;
  background: #ffcd53;
}
#link {
  background: #fceab2;
}
dialog {
  color: inherit;
  max-width: calc(100% - 20px);
  width: 410px;
  max-height: calc(100dvh - 24px);
  border: 2px solid #24364b;
  border-radius: 20px;
  padding: 14px;
  background: #fffdf7;
  overflow: visible;
  box-shadow: 0 12px 50px #13263a33;
}
dialog::backdrop {
  background: #182f4b70;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.dialog-head button {
  width: 44px;
  font-size: 24px;
}
.tool-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.tool-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  min-height: 104px;
  padding: 8px 4px;
}
.tool-button img {
  width: 64px;
  height: 60px;
  object-fit: contain;
}
.tool-button small {
  font-size: 10px;
  color: #637081;
}
.dialog-copy {
  font-size: 13px;
  line-height: 1.65;
  margin: 0 0 14px;
}
.stage-list {
  display: grid;
  gap: 8px;
}
.stage-list button {
  text-align: left;
  padding: 12px;
  min-height: 62px;
}
.stage-list small {
  display: block;
  font-size: 11px;
  margin-top: 4px;
  font-weight: 500;
}
.result-art {
  display: block;
  width: 140px;
  height: 120px;
  object-fit: contain;
  margin: 0 auto;
}
.result-text {
  text-align: center;
  font-size: 14px;
  line-height: 1.6;
  margin: 8px 0 16px;
}
.result-buttons {
  display: flex;
  gap: 8px;
}
.result-buttons button {
  flex: 1;
}
.result-buttons .primary {
  background: #ffcd53;
}
#loading {
  position: absolute;
  inset: 0;
  background: #f7f3e9;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 15px;
  z-index: 5;
  border-radius: 12px;
}
#loading progress {
  width: 200px;
  accent-color: #26b8ac;
}
#loading p {
  font-size: 12px;
  text-align: center;
  margin: 0 16px;
}
#loading button {
  min-width: 160px;
}
@media (max-height: 650px) and (orientation: portrait) {
  #app {
    grid-template-rows: 46px minmax(0, 1fr) 98px;
    gap: 4px;
  }
  #controls {
    gap: 4px;
    grid-template-rows: 46px 46px;
  }
  .brand {
    font-size: 17px;
  }
  #workspace {
    grid-template-rows: 22px minmax(0, 1fr) 30px;
    gap: 2px;
  }
}
@media (orientation: landscape) and (max-height: 600px) {
  #app {
    width: min(100%, 1100px);
    grid-template-columns: minmax(0, 1fr) 215px;
    grid-template-rows: 46px minmax(0, 1fr);
    gap: 6px;
  }
  header {
    grid-column: 1/3;
  }
  #workspace {
    grid-column: 1;
    grid-row: 2;
  }
  #controls {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 16px;
  }
  #selection-controls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
  #selected-name {
    grid-column: 2/4;
  }
  #main-controls {
    display: grid;
    grid-template-columns: 1fr;
  }
  dialog {
    padding: 10px;
    width: 510px;
  }
  .dialog-head {
    margin-bottom: 6px;
  }
  .tool-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }
  .tool-button {
    min-height: 82px;
  }
  .tool-button img {
    height: 38px;
  }
  .result-art {
    height: 65px;
  }
  .result-text {
    margin: 4px 0 8px;
  }
  .stage-list {
    gap: 5px;
  }
  .stage-list button {
    min-height: 50px;
    padding: 7px;
  }
  .dialog-copy {
    font-size: 12px;
    line-height: 1.45;
    margin-bottom: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  button:active {
    transform: none;
  }
}
