html {
  touch-action     : manipulation;
}

:root {
  --color-primary          : #336633;
  --color-primary-dark     : #224422;
  --color-accent-orange    : #ff9d4d;
  --color-accent-blue      : #4f9dff;
  --color-surface          : #ffffff;
  --button-radius          : 999px;
  --button-shadow          : 0 6px 16px rgba(0, 0, 0, 0.18);
  --button-shadow-hover    : 0 10px 22px rgba(0, 0, 0, 0.2);
}

body {
  background-color : #E1DAC3;
  font-size        : 20px;
  display          : flex;
  flex-direction   : column;
  align-items      : center;
  font-family      : "Hiragino Maru Gothic ProN", "Meiryo", sans-serif;
  user-select      : none;
  margin           : 0;
  min-height       : 100vh;
  padding          : 16px 12px 32px;
}

h2 {
  margin           : 0;
  font-size        : 22px;
}

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

.view {
  width            : 100%;
  max-width        : 420px;
  display          : flex;
  flex-direction   : column;
  align-items      : center;
  text-align       : center;
}

.view.wide-view {
  max-width        : 960px;
  align-items      : stretch;
  text-align       : left;
  gap              : 12px;
}

.hidden {
  display          : none !important;
}

.app-title {
  margin           : 0;
  font-size        : 36px;
  font-weight      : bold;
}

.time-panel {
  width            : 85%;
  border           : 2px solid #336633;
  border-radius    : 8px;
  padding          : 4px 16px 4px;
  background-color : rgba(255, 255, 255, 0.8);
  margin-top       : 16px;
  max-width        : 320px;
}

.time-panel-title {
  margin           : 0 0 10px;
  font-size        : 22px;
  text-align       : left;
  color            : #1f3a1f;
}

.offline-note {
  font-size        : 12px;
  color            : #2b2b2b;
  margin           : 8px 0 0;
  opacity          : 0.85;
}

.author-credit {
  font-size        : 12px;
  color            : #444444;
  margin           : 4px 0 0;
  opacity          : 0.8;
}

.author-credit a {
  color            : #2f6fed;
  text-decoration  : underline;
  text-underline-offset: 3px;
}

.time-history {
  list-style       : none;
  width            : 100%;
  margin           : 0;
  padding          : 0;
}

.time-entry,
.time-history-empty {
  padding          : 8px 0;
  border-bottom    : 1px solid rgba(51, 102, 51, 0.2);
  display          : flex;
  justify-content  : space-between;
  align-items      : center;
  font-size        : 18px;
}

.time-entry:last-child,
.time-history-empty:last-child {
  border-bottom    : none;
}

.time-entry-label {
  font-weight      : bold;
  color            : #2b2b2b;
}

.time-entry-value {
  color            : #003300;
}

.time-history-empty {
  justify-content  : center;
  color            : #555555;
}

.time-row {
  display          : flex;
  justify-content  : space-between;
  align-items      : center;
  margin-bottom    : 8px;
}

.time-row:last-child {
  margin-bottom    : 0;
}

.time-label {
  font-weight      : bold;
  color            : #333333;
}

.time-value {
  font-size        : 28px;
  color            : #003300;
}

.info-text {
  font-size        : 18px;
  margin           : 0;
  color            : #333333;
}

#image-container {
  max-width        : 300px;
  height           : auto;
  display          : flex;
  align-items      : center;
  justify-content  : center;
  overflow         : hidden;
}

#image-container img {
  max-width        : 85%;
  max-height       : 85%;
}

img {
  max-width        : 100%;
  max-height       : 100%;
  transform-origin : center;
  cursor           : pointer;
}

button {
  color            : #FFFFFF;
  background-color : #336633;
  border           : none;
  border-radius    : 0.3rem;
  font-size        : medium;
  width            : 100%;
  max-width        : 320px;
  padding          : 0.5rem 1rem;
  font-size        : 22px;
  cursor           : pointer;
}

.button-container {
  padding-top      : 10px;
  width            : 100%;
  display          : flex;
  justify-content  : center;
}

.action-button {
  display          : flex;
  align-items      : center;
  justify-content  : center;
  gap              : 10px;
  font-weight      : bold;
  letter-spacing   : 0.04em;
  border-radius    : var(--button-radius);
  padding          : 0.6rem;
  min-height       : 60px;
  transition       : transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow       : var(--button-shadow);
}

.action-button:hover,
.action-button:focus-visible {
  transform        : translateY(-2px);
  box-shadow       : var(--button-shadow-hover);
}

.action-button-icon {
  display          : inline-flex;
  align-items      : center;
  justify-content  : center;
  width            : 42px;
  height           : 42px;
  border-radius    : 50%;
  font-size        : 20px;
  background-color : rgba(255, 255, 255, 0.2);
}

.action-button--study {
  background       : linear-gradient(130deg, #2f6fed, #4f9dff);
}

.action-button--settings {
  background       : linear-gradient(130deg, #278b69, #5dc08e);
}

.action-button--start {
  background       : linear-gradient(130deg, #d46b43, #ff9d4d);
}

.action-button--reveal {
  background       : linear-gradient(130deg, #e38421, #ffcb5d);
}

.action-button--return {
  background       : linear-gradient(130deg, #258457, #6aca8a);
}

.action-button--goro {
  background       : linear-gradient(125deg, #3b74ff, var(--color-accent-blue));
  color            : #ffffff;
  box-shadow       : 0 8px 20px rgba(59, 116, 255, 0.4);
}

.action-button--reveal.action-button--goro {
  background       : linear-gradient(125deg, #3b74ff, var(--color-accent-blue));
}

.action-button:disabled {
  background       : #9E9E9E;
  box-shadow       : none;
  transform        : none;
}

.action-button:disabled .action-button-icon {
  background-color : rgba(255, 255, 255, 0.2);
}

button.secondary {
  background       : linear-gradient(130deg, #536853, #6f8770);
  border-radius    : 18px;
  font-weight      : bold;
  letter-spacing   : 0.02em;
  box-shadow       : var(--button-shadow);
  transition       : transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
  width            : 100%;
  max-width        : none;
}

button.secondary.all-on-button {
  background       : linear-gradient(130deg, #2f8e4e, #5ec078);
}

button.secondary.danger {
  background       : linear-gradient(130deg, #c74444, #f17373);
}

button.secondary:hover,
button.secondary:focus-visible {
  transform        : translateY(-2px);
  box-shadow       : var(--button-shadow-hover);
}

.floating-button {
  background       : linear-gradient(130deg, #2f7a3c, #56b56e);
  color            : #FFFFFF;
  border           : none;
  border-radius    : var(--button-radius);
  padding          : 10px 26px;
  font-size        : 18px;
  font-weight      : bold;
  letter-spacing   : 0.03em;
  display          : inline-flex;
  align-items      : center;
  justify-content  : center;
  gap              : 8px;
  box-shadow       : var(--button-shadow);
  width            : auto;
  max-width        : none;
  cursor           : pointer;
  transition       : transform 0.15s ease, box-shadow 0.15s ease, filter 0.2s ease;
}

.floating-button:hover,
.floating-button:focus-visible {
  transform        : translateY(-2px);
  box-shadow       : var(--button-shadow-hover);
}

.floating-button:disabled {
  background-color : #8BA08B;
  color            : #F1F1F1;
  cursor           : not-allowed;
  transform        : none;
  box-shadow       : none;
}

.study-floating-bar {
  position         : sticky;
  top              : 0;
  z-index          : 5;
  display          : flex;
  justify-content  : left;
  gap              : 10px;
  width            : 100%;
  padding-top      : 8px;
}

.study-floating-bar.detail {
  margin-bottom    : 12px;
  justify-content  : center;
}

button:disabled {
  background-color : #9E9E9E;
  color            : #f5f5f5;
  cursor           : not-allowed;
  box-shadow       : none;
  transform        : none;
}

#kimariji {
  font-size        : 40px;
  font-weight      : bold;
  color            : #cc0000;
  margin           : 0;
  display          : none;
}

.modal-overlay {
  position         : fixed;
  top              : 0;
  left             : 0;
  width            : 100%;
  height           : 100%;
  background-color : rgba(0, 0, 0, 0.4);
  z-index          : 10;
}

.modal {
  position         : fixed;
  top              : 50%;
  left             : 50%;
  transform        : translate(-50%, -50%);
  width            : min(100vw, 480px);
  max-height       : 90vh;
  z-index          : 20;
}

.modal-content {
  background-color : #fff;
  border-radius    : 12px;
  padding          : 8px;
  box-shadow       : 0 8px 24px rgba(0, 0, 0, 0.2);
  display          : flex;
  flex-direction   : column;
  max-height       : 75vh;
}

.modal-header {
  display          : flex;
  justify-content  : space-between;
  align-items      : center;
  padding-bottom   : 8px;
}

.modal-close-button {
  background       : linear-gradient(130deg, #2f6fed, #5d9dff);
  color            : #fff;
  border-radius    : var(--button-radius);
  width            : auto;
  font-size        : 18px;
  padding          : 8px 18px;
  font-weight      : bold;
  letter-spacing   : 0.05em;
  display          : inline-flex;
  align-items      : center;
  justify-content  : center;
  gap              : 6px;
  box-shadow       : var(--button-shadow);
  transition       : transform 0.15s ease, box-shadow 0.15s ease;
}

.modal-close-button:hover,
.modal-close-button:focus-visible {
  transform        : translateY(-2px);
  box-shadow       : var(--button-shadow-hover);
}

.modal-description {
  margin           : 6px 0 12px;
  text-align       : left;
}

.modal-footer {
  margin-top       : 12px;
  display          : flex;
  flex-direction   : column;
  gap              : 8px;
  width            : 100%;
}

#goro-modal-overlay {
  z-index          : 30;
}

#goro-modal {
  z-index          : 40;
  width            : min(100vw, 600px);
}

.goro-modal-frame {
  background-color : #fff;
  border-radius    : 16px;
  padding          : 48px 0px 18px;
  box-shadow       : 0 8px 24px rgba(0, 0, 0, 0.25);
  position         : relative;
  max-height       : calc(90vh - 24px);
  display          : flex;
  align-items      : center;
  justify-content  : center;
  width            : min(600px, calc(100vw));
  box-sizing       : border-box;
}

.goro-modal-image {
  display          : block;
  width            : 100%;
  max-width        : 100%;
  height           : auto;
  max-height       : calc(90vh - 120px);
  object-fit       : contain;
  border-radius    : 8px;
  background-color : #fff;
}

.goro-modal-close-button {
  position         : absolute;
  top              : 12px;
  right            : 12px;
  width            : 44px;
  height           : 44px;
  max-width        : none;
  border-radius    : 50%;
  background-color : rgba(0, 0, 0, 0.7);
  color            : #fff;
  font-size        : 24px;
  font-weight      : bold;
  padding          : 0;
  line-height      : 1;
  box-shadow       : none;
}

.goro-modal-close-button:hover,
.goro-modal-close-button:focus-visible {
  background-color : rgba(0, 0, 0, 0.85);
  transform        : none;
  box-shadow       : none;
}

#settings-list {
  overflow-y       : auto;
  padding-right    : 2px;
  width            : 100%;
}

.option-card {
  display          : flex;
  justify-content  : space-between;
  align-items      : center;
  gap              : 12px;
  padding          : 12px;
  border-radius    : 10px;
  border           : 1px solid rgba(51, 102, 51, 0.2);
  background-color : rgba(51, 102, 51, 0.05);
  margin-bottom    : 12px;
}

.option-card-text {
  display          : flex;
  flex-direction   : column;
  text-align       : left;
  gap              : 2px;
}

.option-card-title {
  font-weight      : bold;
  color            : #1f3a1f;
}

.option-card-caption {
  font-size        : 14px;
  color            : #555;
}

.option-toggle {
  min-width        : 84px;
  border-radius    : var(--button-radius);
  border           : 2px solid rgba(51, 102, 51, 0.3);
  background       : linear-gradient(130deg, rgba(255, 255, 255, 0.95), rgba(244, 244, 244, 0.98));
  color            : #1f3a1f;
  font-weight      : bold;
  font-size        : 18px;
  width            : auto;
  box-shadow       : 0 4px 12px rgba(0, 0, 0, 0.12);
  transition       : transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.option-toggle.active,
.option-toggle[aria-pressed="true"] {
  background       : linear-gradient(130deg, #278b69, #5dc08e);
  color            : #fff;
  border-color     : transparent;
  box-shadow       : 0 8px 16px rgba(39, 139, 105, 0.35);
}

.option-toggle:hover,
.option-toggle:focus-visible {
  transform        : translateY(-2px);
  box-shadow       : var(--button-shadow-hover);
}

.individual-settings-section {
  margin-bottom    : 16px;
}

.individual-settings-header {
  display          : flex;
  justify-content  : space-between;
  align-items      : center;
  margin-bottom    : 8px;
  padding-top      : 8px;
  border-top       : 1px dashed rgba(51, 102, 51, 0.4);
}

.link-button {
  background       : transparent;
  color            : #2f6fed;
  font-size        : 14px;
  font-weight      : bold;
  letter-spacing   : 0.02em;
  text-decoration  : underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  width            : auto;
  padding          : 0;
  transition       : color 0.2s ease;
}

.link-button:hover,
.link-button:focus-visible {
  color            : #1d4fd0;
}

.individual-settings-list {
  display          : grid;
  grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
  gap              : 6px;
}

button.individual-setting-button {
  max-width        : none;
  border-radius    : 12px;
  border           : 1px solid rgba(51, 102, 51, 0.3);
  background       : rgba(255, 255, 255, 0.96);
  color            : #1f1f1f;
  display          : flex;
  justify-content  : center;
  align-items      : center;
  padding          : 0px;
  font-size        : 14px;
  cursor           : pointer;
  transition       : transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
  min-height       : 48px;
  box-shadow       : 0 3px 10px rgba(0, 0, 0, 0.08);
}

button.individual-setting-button .kimariji {
  font-size        : 18px;
  font-weight      : bold;
}

button.individual-setting-button.is-on {
  border-color     : transparent;
  background       : linear-gradient(130deg, #2f6fed, #5d9dff);
  color            : #ffffff;
  box-shadow       : 0 8px 16px rgba(47, 111, 237, 0.35);
}

button.individual-setting-button.is-off {
  border-color     : #2f6fed;
  background-color : rgba(255, 255, 255, 0.98);
  color            : #1f1f1f;
}

button.individual-setting-button:hover,
button.individual-setting-button:focus-visible {
  transform        : translateY(-1px);
  box-shadow       : 0 6px 14px rgba(0, 0, 0, 0.12);
}

.bulk-settings {
  padding-top      : 12px;
  margin-top       : 16px;
  scroll-margin-top: 60px;
}

.bulk-description {
  margin           : 0 0 8px;
  font-size        : 14px;
  color            : #333;
}

#bulk-settings-list {
  display          : flex;
  flex-direction   : column;
  gap              : 0px;
}

.settings-group {
  margin-bottom    : 12px;
  text-align       : left;
}

.settings-group h3 {
  margin           : 4px 0 8px;
  font-size        : 18px;
}

.settings-grid {
  display          : grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap              : 6px;
}

.toggle-button {
  border           : 2px solid rgba(51, 102, 51, 0.35);
  border-radius    : 14px;
  background       : linear-gradient(130deg, rgba(255, 255, 255, 0.96), rgba(244, 244, 244, 0.98));
  color            : #333333;
  font-size        : 20px;
  font-weight      : bold;
  padding          : 6px 0;
  cursor           : pointer;
  transition       : transform 0.15s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.15s ease;
  width            : 100%;
  max-width        : none;
  box-shadow       : 0 4px 12px rgba(0, 0, 0, 0.08);
}

.toggle-button.letter-button {
  min-height       : 40px;
  display          : flex;
  align-items      : center;
  justify-content  : center;
  font-size        : 20px;
}

.toggle-button.bundle-button {
  margin-bottom    : 4px;
  font-size        : 20px;
  letter-spacing   : 0.05em;
}

.toggle-button.active {
  background       : linear-gradient(130deg, #278b69, #5dc08e);
  color            : #FFFFFF;
  border-color     : transparent;
  box-shadow       : 0 8px 16px rgba(39, 139, 105, 0.3);
}

.toggle-button:hover,
.toggle-button:focus-visible {
  transform        : translateY(-2px);
  box-shadow       : var(--button-shadow-hover);
}

.toggle-button:focus-visible {
  outline          : 3px solid rgba(51, 102, 51, 0.4);
  outline-offset   : 2px;
}

.study-description,
.study-message {
  margin           : 0;
  width            : 100%;
  font-size        : 20px;
  color            : #333;
}

.study-message {
  color            : #555;
}

.study-list-container {
  width            : 100%;
  display          : flex;
  flex-direction   : column;
  gap              : 12px;
}

.study-category {
  background-color : rgba(255, 255, 255, 0.92);
  border           : 1px solid rgba(51, 102, 51, 0.3);
  border-radius    : 10px;
  padding          : 10px;
}

.study-category-title {
  margin           : 0 0 10px;
  font-size        : 18px;
  color            : #1f3a1f;
}

.study-card-grid {
  display          : grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap              : 8px;
}

button.study-card-button {
  max-width        : none;
  width            : 100%;
  display          : flex;
  align-items      : center;
  gap              : 8px;
  background       : linear-gradient(120deg, rgba(255, 255, 255, 0.98), rgba(246, 246, 246, 0.98));
  color            : #1f1f1f;
  border           : 1px solid rgba(51, 102, 51, 0.4);
  border-radius    : 10px;
  padding          : 8px;
  font-size        : 16px;
  text-align       : left;
  cursor           : pointer;
  transition       : border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease, background 0.2s ease;
  box-shadow       : 0 4px 12px rgba(0, 0, 0, 0.08);
}

button.study-card-button.is-enabled,
.study-detail-info.is-enabled,
.study-image-wrapper.is-enabled {
  background       : linear-gradient(120deg, rgba(227, 244, 232, 0.98), rgba(196, 226, 206, 0.98));
}

button.study-card-button:hover,
button.study-card-button:focus-visible {
  border-color     : rgba(47, 111, 237, 0.4);
  box-shadow       : 0 8px 18px rgba(0, 0, 0, 0.12);
  transform        : translateY(-2px);
}

.study-card-button img {
  width            : 56px;
  height           : 56px;
  object-fit       : cover;
  border-radius    : 6px;
  border           : 1px solid rgba(0, 0, 0, 0.08);
  background-color : #f8f8f8;
}

.study-card-text {
  display          : flex;
  flex-direction   : column;
  gap              : 4px;
}

.study-card-kimariji {
  font-size        : 20px;
  font-weight      : bold;
  color            : #cc0000;
}

.study-card-goro {
  font-size        : 13px;
  color            : #333;
}

.study-detail-body {
  width            : 100%;
  display          : flex;
  flex-direction   : column;
  gap              : 12px;
}

.study-image-wrapper,
.study-detail-info {
  background-color : rgba(255, 255, 255, 0.9);
  border           : 1px solid #336633;
  border-radius    : 10px;
  padding          : 10px;
}

.study-detail-info--toggleable,
.study-image-wrapper--toggleable {
  cursor           : pointer;
}

.study-image-wrapper img {
  width            : 100%;
  height           : auto;
}

.study-detail-kimariji {
  margin           : 0 0 2px;
  font-size        : 28px;
  color            : #cc0000;
  font-weight      : bold;
}

.study-detail-info-header {
  display          : flex;
  justify-content  : space-between;
  align-items      : flex-start;
  gap              : 10px;
}

.study-detail-info-header .study-detail-kimariji {
  flex             : 1;
}

.study-detail-selection-toggle {
  background       : linear-gradient(130deg, #2f9e44, #59c16c);
  border           : none;
  border-radius    : var(--button-radius);
  padding          : 8px 18px;
  font-size        : 14px;
  width            : auto;
  color            : #ffffff;
  font-weight      : bold;
  letter-spacing   : 0.03em;
  box-shadow       : var(--button-shadow);
  transition       : transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease, color 0.2s ease;
}

.study-detail-selection-toggle.off {
  background       : linear-gradient(130deg, #f8f8f8, #ffffff);
  color            : #111111;
  border           : 1px solid rgba(51, 51, 51, 0.25);
  box-shadow       : 0 4px 12px rgba(0, 0, 0, 0.08);
}

.study-detail-selection-toggle:hover,
.study-detail-selection-toggle:focus-visible {
  transform        : translateY(-2px);
  box-shadow       : var(--button-shadow-hover);
}

.study-detail-selection-toggle:disabled {
  background       : #b7b7b7;
  color            : #f3f3f3;
  box-shadow       : none;
  cursor           : not-allowed;
  transform        : none;
}

.study-detail-list {
  margin           : 0;
  display          : grid;
  grid-template-columns: minmax(80px, 120px) 1fr;
  row-gap          : 4px;
  column-gap       : 10px;
  font-size        : 14px;
}

.study-detail-list dt {
  font-weight      : bold;
  color            : #2b2b2b;
}

.study-detail-list dd {
  margin           : 0;
  color            : #111;
}

.study-detail-nav-buttons {
  display          : flex;
  gap              : 8px;
  flex-wrap        : wrap;
  justify-content  : center;
}

@media (min-width: 720px) {
  .study-detail-body {
    flex-direction : row;
  }

  .study-image-wrapper,
  .study-detail-info {
    flex          : 1;
  }

  .study-detail-nav-buttons {
    flex          : 1;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .modal {
    width          : 94vw;
  }

  .toggle-button.letter-button {
    min-height     : 40px;
    font-size      : 20px;
  }

  .toggle-button.bundle-button {
    font-size      : 20px;
    padding        : 6px;
  }
}

@media (min-width: 481px) {
  .modal-footer {
    flex-direction : row;
  }
}
