@media (pointer: coarse), (max-width: 760px) {
  #joystick {
    display: block;
  }
  .location {
    bottom: 165px;
    left: 18px;
  }
  .worldbuttons {
    bottom: 35px;
    right: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 155px;
  }
  .worldbuttons .primary {
    grid-column: 1/-1;
  }
  #hint {
    bottom: 175px;
    font-size: 10px;
    max-width: 95%;
    white-space: normal;
    text-align: center;
  }
  .herobar {
    top: 8px;
    left: 8px;
    width: 245px;
  }
  .questbar {
    top: 88px;
    left: 8px;
    width: 245px;
    padding: 10px;
  }
  .topright {
    top: 8px;
    right: 8px;
    width: 125px;
  }
  .topright canvas {
    width: 110px;
    height: 80px;
  }
  .topright button {
    font-size: 10px;
    padding: 6px 8px;
    min-height: 32px;
  }
  .questbar .eyebrow {
    font-size: 8px;
  }
  .questbar strong {
    font-size: 11px;
  }
  .questbar small {
    font-size: 10px;
  }
  .screen {
    padding: 12px;
  }
  .titlebox {
    gap: 8px;
  }
  .titlebox .eyebrow {
    font-size: 8px;
  }
  .titlebox p {
    font-size: 13px;
  }
  .titlebox .logo {
    max-height: 24dvh;
  }
  .creatorbody {
    grid-template-columns: 1fr;
    padding: 10px;
  }
  .preview {
    display: grid;
    grid-template-columns: 120px 1fr;
    grid-template-rows: 40px 70px;
    align-items: center;
  }
  .preview canvas {
    grid-row: 1/3;
    width: 115px;
    height: 120px;
  }
  .preview h2 {
    font-size: 21px;
  }
  .preview p {
    margin: 0;
    font-size: 11px;
    line-height: 1.4;
  }
  .panelhead {
    padding: 12px 16px;
  }
  h1 {
    font-size: 23px;
  }
  form {
    padding: 10px;
    gap: 10px;
  }
  .creator {
    max-height: 96dvh;
  }
  .modal {
    padding: 8px;
  }
  .modal > .panel {
    height: 96dvh;
    border-radius: 15px;
  }
  #modalBody {
    padding: 14px;
  }
  nav {
    padding: 8px;
    gap: 4px;
  }
  nav button {
    min-height: 40px;
    padding: 7px 10px;
  }
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(145px, 1fr));
    gap: 8px;
  }
  .card {
    padding: 11px;
  }
  .statuslayout {
    grid-template-columns: 1fr;
  }
  .statuslayout canvas {
    width: 130px;
    height: 160px;
    margin: auto;
  }
  .statgrid {
    grid-template-columns: repeat(3, 1fr);
  }
  .stat {
    padding: 8px;
  }
  .stat span {
    font-size: 10px;
  }
  .stat b {
    font-size: 17px;
  }
  .dialogcard {
    left: 3%;
    width: 94%;
    bottom: 3%;
    grid-template-columns: 80px 1fr;
    gap: 10px;
    padding: 14px;
  }
  .dialogcard canvas {
    width: 80px;
    height: 110px;
  }
  .dialogcard p {
    font-size: 14px;
    max-height: 40dvh;
    margin: 10px 0;
  }
  .dialogcard h2 {
    font-size: 20px;
  }
  #choices {
    flex-direction: column;
  }
  #choices button {
    min-height: 42px;
  }
  .enemybar {
    top: 92px;
    right: 8px;
    width: 210px;
    padding: 10px;
  }
  .enemybar > span {
    font-size: 12px;
  }
  .enemybar small {
    font-size: 10px;
  }
  .battlebottom {
    bottom: 8px;
    left: 8px;
    right: 8px;
    padding: 10px;
  }
  .battlebottom #commands {
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
  }
  .battlebottom button {
    min-height: 42px;
    padding: 8px 3px;
    font-size: 10px;
  }
  .battlebottom #battleLog {
    font-size: 11px;
    line-height: 1.4;
    margin-bottom: 8px;
  }
  .battlebottom #battleSub {
    grid-template-columns: 1fr 1fr;
    max-height: 27dvh;
  }
  .battlebottom #battleSub button {
    padding: 8px;
    font-size: 11px;
  }
  body.battling .questbar,
  body.battling .topright,
  body.battling .location,
  body.battling .worldbuttons,
  body.battling #joystick,
  body.battling #hint {
    display: none;
  }
  #banner {
    font-size: 25px;
  }
}
@media (max-height: 500px) {
  .titlebox {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 620px;
    gap: 8px;
  }
  .titlebox .logo {
    grid-row: 1/5;
    max-height: 65dvh;
    max-width: 280px;
    grid-column: 1;
  }
  .titlebox .eyebrow,
  .titlebox p,
  .titlebox small {
    display: none;
  }
  .titlebox > button,
  .titlebox .pair {
    grid-column: 2;
    width: 100%;
  }
  .creatorbody {
    grid-template-columns: 30% 70%;
  }
  .preview {
    display: flex;
  }
  .preview canvas {
    height: 155px;
    width: 140px;
  }
  .preview h2 {
    font-size: 18px;
  }
  .preview p {
    font-size: 10px;
  }
  form {
    grid-template-columns: repeat(3, 1fr);
  }
  .creatorbody {
    padding: 6px;
  }
  .creator {
    max-height: 98dvh;
  }
  .panelhead {
    padding: 8px 14px;
  }
  .questbar {
    top: 85px;
    width: 235px;
  }
  .topright canvas {
    width: 105px;
    height: 65px;
  }
  .location {
    bottom: 140px;
  }
  .worldbuttons {
    bottom: 16px;
  }
  .worldbuttons button {
    min-height: 38px;
  }
  #joystick {
    bottom: 15px;
    width: 100px;
    height: 100px;
  }
  #stick {
    left: 26px;
    top: 26px;
  }
  #hint {
    bottom: 125px;
  }
  .dialogcard {
    grid-template-columns: 90px 1fr;
    bottom: 4%;
    padding: 12px;
  }
  .dialogcard canvas {
    width: 85px;
    height: 100px;
  }
  .dialogcard p {
    font-size: 13px;
    max-height: 28dvh;
  }
  .dialogcard h2 {
    font-size: 18px;
  }
  .dialogcard button {
    min-height: 38px;
    padding: 7px 14px;
  }
  #choices {
    flex-direction: row;
  }
  .enemybar {
    top: 8px;
    right: 8px;
    width: 250px;
  }
  .battlebottom #commands {
    grid-template-columns: repeat(7, 1fr);
  }
  .battlebottom #battleSub {
    max-height: 25dvh;
    grid-template-columns: repeat(4, 1fr);
  }
  .battlebottom {
    padding: 8px;
  }
  .battlebottom #battleLog {
    min-height: 16px;
    margin-bottom: 5px;
  }
  .statgrid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (pointer: coarse), (max-width: 760px) {
  .worldbuttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .worldbuttons button {
    min-width: 0;
    padding: 8px 6px;
    font-size: 12px;
  }
}
@media (max-width: 600px) and (min-height: 501px) {
  body.battling .battlebottom {
    left: 8px;
    bottom: 8px;
  }
  body.battling .battlebottom #commands {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  #commands .keycap {
    display: none;
  }
  body.battling .battlebottom #battleLog {
    min-height: 28px;
    font-size: 10px;
    margin-bottom: 5px;
    max-height: 30px;
    overflow: hidden;
  }
  .battle-move {
    position: static;
    width: 100%;
    margin-bottom: 6px;
  }
  .battle-move button {
    min-height: 44px;
  }
  .battle-move small {
    display: none;
  }
  body.battling #battleSub {
    inset: 15% 4% 5%;
    grid-template-columns: 1fr 1fr;
    padding: 10px;
  }
  #battleMode {
    font-size: 9px;
    margin-bottom: 4px;
  }
}
@media (max-height: 500px) {
  body.battling .battlebottom {
    left: 180px;
    right: 8px;
    bottom: 8px;
  }
  body.battling .battlebottom #commands {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 4px;
  }
  body.battling .battlebottom button {
    min-height: 36px;
    font-size: 10px;
    padding: 4px;
  }
  #commands .keycap {
    display: none;
  }
  body.battling .battlebottom #battleLog {
    min-height: 13px;
    margin-bottom: 3px;
    font-size: 10px;
    max-height: 15px;
    overflow: hidden;
  }
  #battleMode {
    font-size: 9px;
    margin-bottom: 3px;
  }
  .battle-move {
    left: -168px;
    bottom: 10px;
    width: 155px;
  }
  .battle-move button {
    min-height: 46px;
  }
  body.battling #battleSub {
    inset: 8% 5% 5%;
    grid-template-columns: repeat(3, 1fr);
  }
}
