#app {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

#app > * {
  width: min(100%, 560px);
}

header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 56px;
  padding: 0 100px 0 64px;
}

h1 {
  font-size: clamp(24px, 7vw, 34px);
  letter-spacing: 3px;
  font-weight: 800;
}

h1 span {
  color: #4cc38a;
}

.tools {
  position: absolute;
  right: 0;
  display: flex;
  gap: 8px;
}

.tools button,
.modes button {
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  min-width: 44px;
  height: 44px;
  font-size: 18px;
  font-weight: 700;
}

.modes {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.modes button {
  padding: 0 18px;
  font-size: 15px;
}

.modes button.on {
  background: #f1f3f8;
  color: #14213d;
}

.shape {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 18px;
  aspect-ratio: 1;
  max-height: 42vh;
  display: grid;
  place-items: center;
}

.shape svg {
  width: 100%;
  height: 100%;
  max-height: 42vh;
}

.shape path {
  fill: #f1f3f8;
  transition: fill 0.4s;
}

.shape.won path {
  fill: #4cc38a;
}

.shape.lost path {
  fill: #e5484d;
}

#guess-form {
  display: flex;
  gap: 8px;
}

.field {
  flex: 1;
  position: relative;
}

#guess {
  width: 100%;
  height: 52px;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: #0d1730;
  color: inherit;
  padding: 0 14px;
  font-size: 18px;
  outline: none;
}

#guess:focus {
  border-color: #4cc38a;
}

#guess-form > button,
.end-buttons button,
dialog button {
  border: none;
  border-radius: 12px;
  background: #4cc38a;
  color: #0b1a14;
  font-weight: 800;
  font-size: 17px;
  height: 52px;
  padding: 0 18px;
}

#guess-form > button:disabled {
  opacity: 0.4;
}

#suggest {
  list-style: none;
  position: absolute;
  z-index: 10;
  left: 0;
  right: 0;
  top: 56px;
  max-height: 260px;
  overflow-y: auto;
  touch-action: pan-y;
  background: #f1f3f8;
  color: #14213d;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#suggest li {
  padding: 12px 14px;
  font-size: 17px;
  border-bottom: 1px solid #dde2ee;
}

#suggest li.active,
#suggest li:active {
  background: #c9f0dc;
}

#suggest mark {
  background: none;
  font-weight: 800;
  color: inherit;
}

#rows,
.example {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#rows li,
.example li {
  display: grid;
  grid-template-columns: 1fr 92px 44px 60px;
  gap: 6px;
  height: 44px;
}

#rows li > *,
.example li > * {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 6px;
}

#rows li > :first-child,
.example li > :first-child {
  justify-items: start;
  padding-left: 12px;
}

#rows li.empty > * {
  background: rgba(255, 255, 255, 0.04);
}

#rows li.new > * {
  animation: flip 0.45s both;
}

#rows li.new > :nth-child(2) { animation-delay: 0.08s; }
#rows li.new > :nth-child(3) { animation-delay: 0.16s; }
#rows li.new > :nth-child(4) { animation-delay: 0.24s; }

#rows li.correct > * {
  background: #2b7a55;
}

@keyframes flip {
  from { transform: rotateX(90deg); }
  to { transform: rotateX(0); }
}

#end {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#end-msg {
  font-size: 20px;
  font-weight: 700;
}

.end-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

#share-btn {
  background: #f1f3f8;
}

#toast {
  text-align: center;
  font-size: 15px;
  opacity: 0.85;
}

dialog {
  margin: auto;
  width: min(92vw, 440px);
  border: none;
  border-radius: 18px;
  background: #1d2c52;
  color: inherit;
  padding: 22px;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

dialog h2 {
  margin-bottom: 12px;
}

dialog h3 {
  margin: 18px 0 8px;
  font-size: 15px;
}

dialog p {
  margin-bottom: 10px;
  line-height: 1.4;
}

dialog .example {
  margin: 12px 0;
}

dialog .small {
  font-size: 13px;
  opacity: 0.7;
}

dialog form {
  margin-top: 16px;
  text-align: right;
}

.numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
  font-size: 12px;
}

.numbers b {
  display: block;
  font-size: 28px;
}

#st-dist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 14px;
}

#st-dist li {
  display: flex;
  gap: 8px;
  align-items: center;
}

#st-dist span {
  background: #4c5a80;
  min-width: 24px;
  padding: 2px 6px;
  text-align: right;
  font-weight: 700;
  border-radius: 4px;
}

#st-dist li.today span {
  background: #4cc38a;
  color: #0b1a14;
}
