#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: #fc8d59;
}

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

.tools button,
.modes button,
.zoom button,
#give-up {
  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;
}

.globe {
  position: relative;
  aspect-ratio: 1;
  max-height: 50vh;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

#globe {
  width: 100%;
  height: 100%;
  max-height: 50vh;
  touch-action: none;
  cursor: grab;
}

.zoom {
  position: absolute;
  right: 4px;
  bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.zoom button {
  font-size: 22px;
  background: rgba(20, 33, 61, 0.75);
}

#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: #fc8d59;
}

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

#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: #fde3d3;
}

#closest,
#toast {
  text-align: center;
  font-size: 15px;
}

#closest b {
  font-size: 17px;
}

#toast {
  opacity: 0.85;
}

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

#rows li {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 16px;
  font-weight: 700;
}

#rows li.new {
  animation: pop 0.4s both;
}

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

#rows li i {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

#rows li b {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#rows li span {
  font-variant-numeric: tabular-nums;
  opacity: 0.85;
}

@keyframes pop {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

#give-up {
  width: auto;
  padding: 0 20px;
  font-size: 15px;
  opacity: 0.8;
}

#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;
}

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 p {
  margin-bottom: 10px;
  line-height: 1.4;
}

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

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

.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 14px;
  font-size: 13px;
}

.legend i {
  flex: 1;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, #fff7ec, #fdd49e, #fc8d59, #d7301f, #7f0000);
}

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

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