@media (max-width: 599px) {
  :root {

    touch-action: manipulation;
  }

  html {
    font-size: 40px;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: none;
    overflow: visible;
    overflow-x: visible;
  }

  input[type="text"],
  textarea {
    font-size: 12px;
    padding: 2px 4px;
  }

  button#zoom-in,
  button#zoom-out,
  button#zoom-reset {
    display: none;
  }

  button#undo { left: 10px; }
  button#redo { left: 55px; }
  button#init_hex { left: 100px; }

  button#view {
    display: none;
    width: 35px;
  }
  button#screenshot {
    display: none !important;
  }

  button#screenshot,
  button#save,
  button#load {
    display: flex;
    align-items: center;
    padding-left: 35px;
  }
  button#screenshot::before {
    content: "";
    display: inline-block;
    position: absolute;
    left: 8px;
    width: 20px;
    height: 20px;
    background: #fff;
    -webkit-mask: url(../img/screenshot.svg);
    mask: url(../img/screenshot.svg);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
  }

  button#hintBtn {
    width: 30px;
    height: 30px;
    padding: 0;
    font-size: 10px;
    position: absolute;
    left: 100%;
    text-align: center;
    top: 0;
    bottom: 0;
    margin: auto;
    margin-left: 5px;
    line-height: 1.3;
    border-radius: 35px;
    background: linear-gradient(339deg, #00c6ff, #0072ff, #00d4ff);
  }
  button#hintBtn::before {
    content: "";
    display: inline-block;
    position: absolute;
    top: 6px;
    left: 6px;
    width: 18px;
    height: 18px;
    background: url(../img/hint.svg);
  }

  header {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000;
    width: 50px;
    display: block;
    left: auto;
    height: auto;
    margin-bottom: 0;
    gap: 0;
    padding: 0;
    pointer-events: auto;
  }

  header img#logo {
    position: absolute;
    right: 10px;
    top: 10px;
    width: auto;
    height: 35px;
    transition: var(--transition);
  }

  section#memoAndColor {
    position: fixed;
    top: 105%;
    display: flex;
    flex-flow: column;
    justify-content: center;
    gap: 10px;
    background: none;
    z-index: 99;
  }
  section#memoAndColor.on {
    right: 0;
    left: 0;
    top: auto;
    bottom: 0;
    z-index: 100;
  }
  section#memoAndColor textarea {
    height: 90px;
    width: 150px;
    resize: none;
    padding: 0 4px;
    line-height: 1.5;
    font-size: 12px;
  }
  section#memoAndColor textarea::placeholder {
    color: #ddd;
  }
  section#memoAndColor div {
    display: flex;
    align-items: center;
  }
  section#memoAndColor div.memo {
    display: none;
  }
  section#memoAndColor div.color {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    flex-wrap: wrap;
  }
  section#memoAndColor div.color div {
    display: flex;
    flex-flow: column;
    width: calc(100% / 6);
  }
  section#memoAndColor div.color input[type="radio"] {
    position: relative;
    width: 100%;
    height: 30px;
    background: #ccc;
    cursor: pointer;
    transition: var(--transition);
  }
  section#memoAndColor.on div.color input[type="radio"]:checked + i::before {
    content: "";
    display: inline-block;
    width: 18px;
    height: 18px;
    position: absolute;
    top: 6px;
    margin: auto;
    left: 0;
    right: 0;
    -webkit-mask: url(../img/check.svg);
    mask: url(../img/check.svg);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background: #fff;
  }
  section#memoAndColor div.color div:nth-of-type(1) span:nth-of-type(1) input[type="radio"]:checked + i::before {
    background: var(--font-color);
  }
  section#memoAndColor div.color div span {
    position: relative;
    display: flex;
    width: 100%;
  }
  section#memoAndColor div.color div span:not(:first-child) {
    display: none;
  }
  section#memoAndColor div.color div:nth-of-type(1) span:nth-of-type(1) input[type="radio"] { background: var(--hex-color1-1); }
  section#memoAndColor div.color div:nth-of-type(1) span:nth-of-type(2) input[type="radio"] { background: var(--hex-color1-2); }
  section#memoAndColor div.color div:nth-of-type(1) span:nth-of-type(3) input[type="radio"] { background: var(--hex-color1-3); }
  section#memoAndColor div.color div:nth-of-type(1) span:nth-of-type(4) input[type="radio"] { background: var(--hex-color1-4); }
  section#memoAndColor div.color div:nth-of-type(1) span:nth-of-type(5) input[type="radio"] { background: var(--hex-color1-5); }
  section#memoAndColor div.color div:nth-of-type(2) span:nth-of-type(1) input[type="radio"] { background: var(--hex-color2-1); }
  section#memoAndColor div.color div:nth-of-type(2) span:nth-of-type(2) input[type="radio"] { background: var(--hex-color2-2); }
  section#memoAndColor div.color div:nth-of-type(2) span:nth-of-type(3) input[type="radio"] { background: var(--hex-color2-3); }
  section#memoAndColor div.color div:nth-of-type(2) span:nth-of-type(4) input[type="radio"] { background: var(--hex-color2-4); }
  section#memoAndColor div.color div:nth-of-type(2) span:nth-of-type(5) input[type="radio"] { background: var(--hex-color2-5); }
  section#memoAndColor div.color div:nth-of-type(3) span:nth-of-type(1) input[type="radio"] { background: var(--hex-color3-1); }
  section#memoAndColor div.color div:nth-of-type(3) span:nth-of-type(2) input[type="radio"] { background: var(--hex-color3-2); }
  section#memoAndColor div.color div:nth-of-type(3) span:nth-of-type(3) input[type="radio"] { background: var(--hex-color3-3); }
  section#memoAndColor div.color div:nth-of-type(3) span:nth-of-type(4) input[type="radio"] { background: var(--hex-color3-4); }
  section#memoAndColor div.color div:nth-of-type(3) span:nth-of-type(5) input[type="radio"] { background: var(--hex-color3-5); }
  section#memoAndColor div.color div:nth-of-type(4) span:nth-of-type(1) input[type="radio"] { background: var(--hex-color4-1); }
  section#memoAndColor div.color div:nth-of-type(4) span:nth-of-type(2) input[type="radio"] { background: var(--hex-color4-2); }
  section#memoAndColor div.color div:nth-of-type(4) span:nth-of-type(3) input[type="radio"] { background: var(--hex-color4-3); }
  section#memoAndColor div.color div:nth-of-type(4) span:nth-of-type(4) input[type="radio"] { background: var(--hex-color4-4); }
  section#memoAndColor div.color div:nth-of-type(4) span:nth-of-type(5) input[type="radio"] { background: var(--hex-color4-5); }
  section#memoAndColor div.color div:nth-of-type(5) span:nth-of-type(1) input[type="radio"] { background: var(--hex-color5-1); }
  section#memoAndColor div.color div:nth-of-type(5) span:nth-of-type(2) input[type="radio"] { background: var(--hex-color5-2); }
  section#memoAndColor div.color div:nth-of-type(5) span:nth-of-type(3) input[type="radio"] { background: var(--hex-color5-3); }
  section#memoAndColor div.color div:nth-of-type(5) span:nth-of-type(4) input[type="radio"] { background: var(--hex-color5-4); }
  section#memoAndColor div.color div:nth-of-type(5) span:nth-of-type(5) input[type="radio"] { background: var(--hex-color5-5); }
  section#memoAndColor div.color div:nth-of-type(6) span:nth-of-type(1) input[type="radio"] { background: var(--hex-color6-1); }
  section#memoAndColor div.color div:nth-of-type(6) span:nth-of-type(2) input[type="radio"] { background: var(--hex-color6-2); }
  section#memoAndColor div.color div:nth-of-type(6) span:nth-of-type(3) input[type="radio"] { background: var(--hex-color6-3); }
  section#memoAndColor div.color div:nth-of-type(6) span:nth-of-type(4) input[type="radio"] { background: var(--hex-color6-4); }
  section#memoAndColor div.color div:nth-of-type(6) span:nth-of-type(5) input[type="radio"] { background: var(--hex-color6-5); }

  footer {
    position: fixed;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 55px;
    z-index: 1000;
    gap: 20px;
    padding: 0 20px;
    z-index: 100;
    top: 0;
    left: 0;
    right: 0;
  }
  footer .counter {
    margin-left: 0;
  }

  section.menu {
    position: absolute;
    top: 25px;
    bottom: auto;
  }
  section.menu .text input {
    width: 150px;
    text-align: center;
  }
  section.menu.view-menu {
    background: #ccebff;
    left: 85%;
    bottom: 85%;
  }
  section.menu.view-menu:before {
    content: "";
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: -15px;
    border: 15px solid transparent;
    border-left: 15px solid #ccebff;
    transform: rotateZ(15deg);
  }
  section.menu.view-menu div {
    width: 170px;
    max-height: 110px;
    padding: 10px;
    font-size: 12px;
    color: var(--font-color);
    white-space: pre-wrap;
    overflow: auto;
    max-height: 90px;
  }
  /* スマホ用 カラー選択 */
  section.menu {
    flex-flow: column;
  }
  section.menu div.color {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    border: solid 1px #ccc;
  }
  section.menu div.color div {
    position: relative;
    display: flex;
  }
  section.menu div.color input[type="radio"] {
    position: relative;
    width: 25px;
    height: 25px;
    background: #ccc;
    cursor: pointer;
    transition: var(--transition);
  }
  section.menu div.color input[type="radio"]:checked + i::before {
    content: "";
    display: inline-block;
    width: 17px;
    height: 17px;
    position: absolute;
    top: 4px;
    left: 4px;
    -webkit-mask: url(../img/check.svg);
    mask: url(../img/check.svg);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background: #fff;
  }
  section.menu div.color div:nth-of-type(1) input[type="radio"]:checked + i::before { background: var(--font-color); }
  section.menu div.color div:nth-of-type(1) input[type="radio"] { background: var(--hex-color1-1); }
  section.menu div.color div:nth-of-type(2) input[type="radio"] { background: var(--hex-color2-1); }
  section.menu div.color div:nth-of-type(3) input[type="radio"] { background: var(--hex-color3-1); }
  section.menu div.color div:nth-of-type(4) input[type="radio"] { background: var(--hex-color4-1); }
  section.menu div.color div:nth-of-type(5) input[type="radio"] { background: var(--hex-color5-1); }
  section.menu div.color div:nth-of-type(6) input[type="radio"] { background: var(--hex-color6-1); }

  section#contents {
    position: relative;
    background: var(--hex-border-color);
    min-width: 100svw;
    min-height: 100svh;
    overflow: visible;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  section#contents #bg {
    background-image: url(img/hex.svg);
    background-repeat: repeat;
    overflow: visible;
    background-size: 2.925rem;
    width: 3000px;
    height: 3000px;
    position: absolute;
    background-position-x: center;
    background-position-y: center;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateY(-50%) translateX(-50%);
    -webkit-transform: translateY(-50%) translateX(-50%);
  }
  section#contents .hex-panel {
    position: relative;
    width: var(--hex-width);
    height: var(--hex-height);
    flex-shrink: 0;
  }

  /* 削除ボタンの挙動変更（hover表示を無効化し、object時のみ表示） */
  section#contents .hex-panel span.group div.set:hover div.deleteBtn {
    display: none;
  }
  section#contents .hex-panel span.group div.set#object div.deleteBtn {
    display: block;
  }
  section#contents .hex-panel span.group div.set div.deleteBtn {
    display: none;
    transition: var(--transition);
    position: absolute;
    top: 4px;
    right: 18px;
    width: 18px;
    height: 18px;
  }
  section#contents .hex-panel span.group div.set div.deleteBtn::before {
    content: "";
    width: 18px;
    height: 18px;
    border: none;
    display: inline-block;
    position: absolute;
    margin: auto 0;
    -webkit-mask: url(../img/xmark.svg);
    mask: url(../img/xmark.svg);
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    background: #fff;
  }
  section#contents .hex-panel span.group div.set.color1-1 div.deleteBtn::before {
    background: var(--font-color);
  }
} 