:root {
  color-scheme: dark;
  font-family: "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body,
#game {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #61798b;
  color: #f5f7f8;
  user-select: none;
}

canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.panel {
  border: 1px solid rgb(226 238 241 / 22%);
  border-radius: 11px;
  background: rgb(12 29 40 / 84%);
  box-shadow: 0 8px 24px rgb(5 15 22 / 20%);
  backdrop-filter: blur(12px);
}

.intro {
  position: absolute;
  top: 16px;
  left: 12px;
  width: fit-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 11px;
  font-size: 12px;
  line-height: 1.4;
  pointer-events: auto;
}

.intro details {
  position: relative;
}

.intro summary {
  width: fit-content;
  color: #e7f0f3;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

.intro summary::-webkit-details-marker {
  display: none;
}

.intro summary span {
  margin-right: 5px;
  color: #8ed3d7;
}

.intro p {
  max-width: 290px;
  margin: 5px 0 0;
  color: #d3e0e5;
}

.intro details[open] {
  width: min(300px, calc(100vw - 40px));
}

kbd {
  display: inline-block;
  min-width: 17px;
  margin-right: 2px;
  padding: 1px 4px;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 4px;
  background: rgb(255 255 255 / 8%);
  font: inherit;
  text-align: center;
}

.needs {
  position: absolute;
  top: 16px;
  right: 12px;
  display: grid;
  width: 238px;
  gap: 8px;
  padding: 13px 15px;
}

.need {
  display: grid;
  grid-template-columns: 62px 1fr 34px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.need b {
  font-size: 11px;
  font-weight: 500;
  text-align: right;
}

.meter {
  height: 7px;
  overflow: hidden;
  border-radius: 8px;
  background: rgb(255 255 255 / 20%);
}

.meter i {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: #f0bf5c;
  transition: width 180ms ease;
}

#thirst {
  background: #54c7e4;
}

#health {
  background: #f07278;
}

#stamina {
  background: #62d28b;
}

.supplies {
  position: absolute;
  top: 145px;
  right: 12px;
  display: flex;
  gap: 9px;
  padding: 8px 12px;
  font-size: 12px;
}

.inventory-panel {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgb(3 12 18 / 58%);
  backdrop-filter: blur(5px);
  pointer-events: auto;
}

.inventory-panel[hidden] {
  display: none;
}

.inventory-card {
  width: min(390px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px;
  border: 1px solid rgb(226 238 241 / 24%);
  border-radius: 18px;
  background: linear-gradient(155deg, rgb(20 43 54 / 97%), rgb(9 24 33 / 97%));
  box-shadow: 0 24px 70px rgb(0 0 0 / 40%);
}

.inventory-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 19px;
}

.inventory-eyebrow {
  color: #8ed3d7;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.inventory-header h2 {
  margin: 4px 0 0;
  font-size: 24px;
  font-weight: 650;
}

.inventory-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgb(226 238 241 / 18%);
  border-radius: 9px;
  background: rgb(255 255 255 / 5%);
  color: inherit;
  font: inherit;
  font-size: 22px;
  cursor: pointer;
}

.inventory-close:hover {
  background: rgb(255 255 255 / 12%);
}

.inventory-list {
  display: grid;
  gap: 8px;
}

.inventory-item {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  min-height: 48px;
  padding: 7px 11px;
  border: 1px solid rgb(226 238 241 / 10%);
  border-radius: 10px;
  background: rgb(255 255 255 / 4%);
  color: #dce7ea;
  font-size: 14px;
}

.inventory-item b {
  min-width: 34px;
  color: #fff;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.inventory-icon {
  font-size: 18px;
  text-align: center;
}

.wood-icon { color: #e6b56f; }
.stone-icon { color: #b7c8ce; }
.fiber-icon { color: #8fd7a7; }
.wool-icon { color: #ecedf2; }
.iron-icon { color: #a9bfd5; }
.planks-icon { color: #d7a977; }
.crate-icon { color: #c99a68; }

.crafting-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 18px;
  padding: 13px;
  border: 1px solid rgb(142 211 215 / 20%);
  border-radius: 12px;
  background: rgb(142 211 215 / 5%);
}

.crafting-section h3 {
  margin: 3px 0;
  font-size: 15px;
}

.crafting-section p {
  margin: 0;
  color: #a9bbc1;
  font-size: 12px;
}

.crafting-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.crafting-actions .craft-button:last-child {
  grid-column: 1 / -1;
}

.craft-button {
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid rgb(142 211 215 / 38%);
  border-radius: 9px;
  background: rgb(42 89 96 / 72%);
  color: #f5f7f8;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: normal;
}

.craft-button:not(:disabled):hover {
  border-color: #8ed3d7;
  background: rgb(52 111 117 / 88%);
}

.craft-button:disabled {
  color: #a9bac0;
  cursor: not-allowed;
  opacity: 0.62;
}

.inventory-hint {
  margin: 16px 0 0;
  color: #a9bbc1;
  font-size: 11px;
  text-align: center;
}

.divider {
  color: #9eb4bd;
}

.top-controls {
  position: absolute;
  top: 16px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 7px;
  transform: translateX(-50%);
  pointer-events: none;
}

.island-label {
  padding: 9px 13px;
  color: #eff7f8;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.day-night-toggle,
.raft-upgrade {
  position: relative;
  z-index: 1;
  padding: 8px 11px;
  color: inherit;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  pointer-events: auto;
  white-space: nowrap;
}

.top-controls button {
  border-color: rgb(226 238 241 / 18%);
  background: rgb(12 29 40 / 78%);
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.top-controls button:hover {
  transform: translateY(-1px);
  border-color: rgb(142 211 215 / 55%);
  background: rgb(23 53 66 / 94%);
}

.raft-upgrade {
  position: absolute;
  top: 190px;
  right: 12px;
}

.raft-upgrade:not(:disabled):hover {
  background: rgb(35 70 86 / 94%);
}

.raft-upgrade:disabled {
  color: #a9bac0;
  cursor: not-allowed;
  opacity: 0.76;
}

.objective {
  position: absolute;
  bottom: 116px;
  left: 50%;
  padding: 10px 15px;
  transform: translateX(-50%);
  font-size: 14px;
  text-align: center;
  white-space: nowrap;
}

.toast {
  position: absolute;
  top: 18%;
  left: 50%;
  padding: 9px 14px;
  transform: translate(-50%, -6px);
  border-radius: 8px;
  background: rgb(16 39 52 / 88%);
  font-size: 13px;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.prompt {
  position: absolute;
  bottom: 205px;
  left: 50%;
  padding: 9px 12px;
  transform: translateX(-50%);
  font-size: 13px;
  white-space: nowrap;
}

#crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 5px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 4px #142632;
}

.hotbar {
  position: absolute;
  bottom: 18px;
  left: 50%;
  display: flex;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: auto;
}

.slot {
  position: relative;
  display: grid;
  width: 69px;
  height: 69px;
  justify-items: center;
  align-content: center;
  gap: 3px;
  border: 1px solid rgb(226 238 241 / 26%);
  border-radius: 10px;
  background: rgb(12 29 40 / 88%);
  box-shadow: 0 6px 20px rgb(5 15 22 / 18%);
  backdrop-filter: blur(10px);
  font-size: 10px;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.slot[data-tool]:hover {
  border-color: rgb(142 211 215 / 60%);
  background: rgb(23 53 66 / 94%);
}

.slot[data-tool]:focus-visible {
  outline: 2px solid #8ed3d7;
  outline-offset: 3px;
}

.slot.selected {
  border: 2px solid #ffd16b;
  box-shadow: 0 0 0 2px rgb(255 209 107 / 30%), 0 0 14px rgb(255 209 107 / 35%);
}

.slot small {
  position: absolute;
  top: 4px;
  left: 7px;
  color: #d8e1e4;
  font-size: 9px;
}

.slot b {
  font-weight: 500;
}

.tool {
  height: 30px;
  font-size: 25px;
  line-height: 30px;
}

.axe {
  color: #ff6d9d;
}

.pick {
  color: #f0f3f5;
}

.empty {
  height: 30px;
}

#error {
  position: absolute;
  z-index: 5;
  inset: 50% auto auto 50%;
  width: min(520px, calc(100% - 32px));
  padding: 18px;
  transform: translate(-50%, -50%);
  border: 1px solid #ef8a8a;
  border-radius: 12px;
  background: #351e24;
  color: #fff;
  line-height: 1.5;
}

@media (max-width: 600px) {
  .intro {
    top: 10px;
    left: 10px;
    padding: 7px 9px;
    font-size: 10px;
  }

  .needs {
    width: 185px;
    gap: 5px;
    padding: 9px;
  }

  .need {
    grid-template-columns: 38px 1fr 28px;
    gap: 5px;
    font-size: 10px;
  }

  .supplies {
    top: 128px;
    right: 10px;
    font-size: 10px;
  }

  .top-controls {
    top: 154px;
    left: 10px;
    right: auto;
    gap: 5px;
    flex-direction: column;
    align-items: stretch;
    transform: none;
  }

  .island-label,
  .top-controls button {
    padding: 7px 9px;
    font-size: 10px;
  }

  .raft-upgrade {
    top: 166px;
    font-size: 10px;
  }

  .prompt {
    bottom: 230px;
  }

  .objective {
    bottom: 174px;
    max-width: calc(100vw - 24px);
    font-size: 11px;
    white-space: normal;
  }

  .slot {
    width: 56px;
    height: 61px;
  }
}

@media (max-width: 390px) {
  .top-controls {
    left: 10px;
  }

  .island-label,
  .top-controls button {
    max-width: 154px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
